mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 21:12:15 +00:00
[JENKINS-20280] Use topological sorting to decide the order to override variables.
This commit is contained in:
1 parent
562c64bbdb
commit
6d56de71cb
2 files changed
+106
-120
No files matched your search
@@ -118,13 +118,18 @@ public class EnvVarsTest extends TestCase {
|
||||
|
||||
public void testOverrideOrderCalculatorCyclic() {
|
||||
EnvVars env = new EnvVars();
|
||||
env.put("C", "Existing");
|
||||
EnvVars overrides = new EnvVars();
|
||||
overrides.put("A", "${B}");
|
||||
overrides.put("B", "${C}");
|
||||
overrides.put("B", "${C}"); // This will be ignored.
|
||||
overrides.put("C", "${A}");
|
||||
|
||||
overrides.put("D", "${C}${E}");
|
||||
overrides.put("E", "${C}${D}");
|
||||
|
||||
OverrideOrderCalculator calc = new OverrideOrderCalculator(env, overrides);
|
||||
List<String> order = calc.getOrderedVariableNames();
|
||||
assertEquals(Sets.newHashSet("A", "B", "C"), new HashSet<String>(order));
|
||||
assertEquals(Arrays.asList("B", "A", "C"), order.subList(0, 3));
|
||||
assertEquals(Sets.newHashSet("E", "D"), new HashSet<String>(order.subList(3, order.size())));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user