Skip to content

Commit

Permalink
Set agent requirements based on actual configuration. Fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpett committed Jul 24, 2016
1 parent 9b18c08 commit 46b1ede
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,29 @@ public Map<String, String> getDefaultRunnerProperties() {
@Override
public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {
List<Requirement> requirements = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));
// The console runner is compiled to AnyCPU, just pick x32 to be compatible with both 32/64 bit
// TODO: Revise
requirements.add(new Requirement(DotNetConstants.DOTNET_FRAMEWORK_4_0 + DotNetConstants.X32, null, RequirementType.EXISTS));

String runtime = runParameters.get(StringConstants.ParameterName_RuntimeVersion);
String frameworkMatcher = null;
if (runtime.equals(Runtime.dotNET35)) {
frameworkMatcher = "3.5"; // Match just 3.5
}
else if (runtime.equals(Runtime.dotNET40)) {
frameworkMatcher = "4.[0-9\\.]+"; // Match any 4.x
}
else if (runtime.equals(Runtime.dotNET45)) {
frameworkMatcher = "4.[56](\\.[0-9]+)?"; // Match 4.5+
}

String platform = runParameters.get(StringConstants.ParameterName_Platform);
String platformMatcher = null;
if (platform.equals(Platforms.MSIL)) {
platformMatcher = "(x86|x64)";
}
else {
platformMatcher = platform;
}

requirements.add(new Requirement("Exists=>DotNetFramework" + frameworkMatcher + "_" + platformMatcher, null, RequirementType.EXISTS));
requirements.add(new Requirement("teamcity.tool." + StringConstants.ToolName, null, RequirementType.EXISTS));

return requirements;
Expand Down

2 comments on commit 46b1ede

@carlpett
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekoshkin There are (currently) three supported versions of the test runner, compiled with .net 3.5, 4.0 and 4.5 respectively. A build agent which only has .net 4.0 should be marked as compatible with builds using the 4.0 test runner, but not the 4.5 one. If the agent has 4.5+ though, it can run both.
At least that is my understanding of the compatibility between the different versions, am I missing something?

@carlpett
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekoshkin Hm, possibly yes. But is there a good reason for making that assumption? Is there some cost to being (overly?) correct here?

Please sign in to comment.