@@ -164,15 +164,13 @@ val ubuntu2404 = Distribution(
164164)
165165
166166val ubuntu2204 = Distribution (
167- wslId = " Ubuntu" ,
168- userId = " Ubuntu-22.04" ,
167+ wslId = " Ubuntu-22.04" ,
169168 matchPattern = " *Ubuntu*22.04*" ,
170169 defaultAbsentTool = " dos2unix"
171170)
172171
173172val ubuntu2004 = Distribution (
174- wslId = " Ubuntu" ,
175- userId = " Ubuntu-20.04" ,
173+ wslId = " Ubuntu-20.04" ,
176174 matchPattern = " *Ubuntu*20.04*" ,
177175 defaultAbsentTool = " dos2unix"
178176)
@@ -1054,7 +1052,7 @@ workflowWithCopyright(
10541052 )
10551053 verifyInstalledDistribution(
10561054 name = " Test - wsl-bash should use the last installed distribution with set-as-default true" ,
1057- expectedPatternExpression = " matrix.distributions.distribution2.match-pattern"
1055+ expectedPatternExpression = expr( " matrix.distributions.distribution2.match-pattern" )
10581056 )
10591057 }
10601058
@@ -1157,7 +1155,7 @@ workflowWithCopyright(
11571155 )
11581156 verifyInstalledDistribution(
11591157 name = """ Test - "${expr(" matrix.distribution2.user-id" )} " should be the default distribution after installation""" ,
1160- expectedPatternExpression = " matrix.distribution2.match-pattern"
1158+ expectedPatternExpression = expr( " matrix.distribution2.match-pattern" )
11611159 )
11621160 executeActionStep = usesSelfAfterSuccess(
11631161 name = " Re-execute action" ,
@@ -1167,7 +1165,7 @@ workflowWithCopyright(
11671165 )
11681166 verifyInstalledDistribution(
11691167 name = """ Test - "${expr(" matrix.distribution2.user-id" )} " should still be the default distribution after re-running for "${expr(" matrix.distribution.user-id" )} """" ,
1170- expectedPatternExpression = " matrix.distribution2.match-pattern"
1168+ expectedPatternExpression = expr( " matrix.distribution2.match-pattern" )
11711169 )
11721170 executeActionStep = usesSelfAfterSuccess(
11731171 name = " Set as default" ,
@@ -1183,74 +1181,41 @@ workflowWithCopyright(
11831181
11841182 testJob(
11851183 id = " test_distribution_specific_wsl_bash_scripts" ,
1186- name = " Test distribution specific wsl-bash scripts on ${expr(" matrix.environment" )} (without ${expr( " matrix.distributions.incompatibleUbuntu " )} ) " ,
1184+ name = " Test distribution specific wsl-bash scripts on ${expr(" matrix.environment" )} " ,
11871185 _customArguments = mapOf (
11881186 " strategy" to mapOf (
11891187 " fail-fast" to false ,
11901188 " matrix" to mapOf (
1191- " environment" to environments,
1192- // ubuntu2004 and ubuntu2204 currently have the same wsl-id
1193- // so their distribution specific wsl_bash scripts will clash
1194- // and thus cannot be tested together
1195- " distributions" to listOf (ubuntu2204, ubuntu2004)
1196- .map { incompatibleUbuntu ->
1197- distributions
1198- .filter { it != incompatibleUbuntu.asMap }
1199- .mapIndexed<Map <String , String >, Pair <String , Any >> { i, distribution ->
1200- " distribution${i + 1 } " to distribution
1201- }
1202- .toMutableList()
1203- .apply {
1204- add(0 , " incompatibleUbuntu" to incompatibleUbuntu.userId)
1205- }
1206- .toMap()
1207- }
1189+ " environment" to environments
12081190 )
12091191 )
12101192 )
12111193 ) {
1212- ( 1 until distributions.size)
1213- .associateWith {
1214- usesSelf(
1215- name = " Execute action for ${expr( " matrix.distributions. distribution$it . user-id" ) } " ,
1194+ distributions
1195+ .mapIndexed { i, distribution ->
1196+ distribution to usesSelf(
1197+ name = " Execute action for ${distribution[ " user-id" ] } " ,
12161198 action = SetupWsl (
1217- distribution = SetupWsl .Distribution .Custom (expr(" matrix.distributions.distribution$it .user-id" )),
1218- additionalPackages = listOf (
1219- expr(
1220- """
1221- (${getOnDistributionCondition(it, * alpineDistributions.toTypedArray())} )
1222- && 'bash'
1223- || ''
1224- """ .trimIndent()
1225- )
1199+ distribution = SetupWsl .Distribution .Custom (distribution[" user-id" ]!! ),
1200+ additionalPackages = listOfNotNull(
1201+ if (
1202+ alpineDistributions.any {
1203+ it.userId == distribution[" user-id" ]
1204+ }
1205+ ) " bash" else null ,
12261206 ),
1227- setAsDefault = if (it >= 3 ) false else null ,
1207+ setAsDefault = if (i >= 2 ) false else null ,
12281208 wslVersion = 1
12291209 )
12301210 )
12311211 }
1232- .forEach { (i , localExecuteActionStep) ->
1212+ .forEach { (distribution , localExecuteActionStep) ->
12331213 executeActionStep = localExecuteActionStep
12341214 verifyInstalledDistribution(
1235- name = " Test - wsl-bash_${expr(" matrix.distributions.distribution$i .user-id" )} should use the correct distribution" ,
1236- conditionTransformer = if (distributions[i] == ubuntu2004.asMap) {
1237- { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2004) }
1238- } else {
1239- { it }
1240- },
1241- // the formula adds 1 to the indices from ubuntu2004 on
1242- // to mitigate the double entry for the previous index
1243- shell = Shell .Custom (" wsl-bash_${distributions[min(1 , i / (distributions.indexOf(ubuntu2004.asMap) + 1 )) + i - 1 ][" user-id" ]} {0}" ),
1244- expectedPatternExpression = " matrix.distributions.distribution$i .match-pattern"
1215+ name = " Test - wsl-bash_${distribution[" user-id" ]} should use the correct distribution" ,
1216+ shell = Shell .Custom (" wsl-bash_${distribution[" user-id" ]} {0}" ),
1217+ expectedPatternExpression = distribution[" match-pattern" ]!!
12451218 )
1246- if (distributions[i] == ubuntu2004.asMap) {
1247- verifyInstalledDistribution(
1248- name = " Test - wsl-bash_${expr(" matrix.distributions.distribution$i .user-id" )} should use the correct distribution" ,
1249- conditionTransformer = { executeActionStep.getSuccessNotOnDistributionCondition(i, ubuntu2204) },
1250- shell = Shell .Custom (" wsl-bash_${distributions[i][" user-id" ]} {0}" ),
1251- expectedPatternExpression = " matrix.distributions.distribution$i .match-pattern"
1252- )
1253- }
12541219 }
12551220 }
12561221}
@@ -1398,7 +1363,7 @@ fun JobBuilder<*>.verifyInstalledDistribution(
13981363 name : String ,
13991364 conditionTransformer : (String ) -> String = { it },
14001365 shell : Shell = wslBash,
1401- expectedPatternExpression : String = "matrix.distribution.match-pattern"
1366+ expectedPatternExpression : String = expr( "matrix.distribution.match-pattern")
14021367) = verifyCommandResult(
14031368 name = name,
14041369 conditionTransformer = conditionTransformer,
@@ -1411,7 +1376,7 @@ fun JobBuilder<*>.verifyInstalledDistribution(
14111376 <([ -f /proc/version ] && cat /proc/version || true)
14121377 """ .trimIndent().replace(" \n " , " " ),
14131378 shell = shell,
1414- expectedPattern = expr( expectedPatternExpression)
1379+ expectedPattern = expectedPatternExpression
14151380)
14161381
14171382fun JobBuilder <* >.verifyCommandResult (
0 commit comments