Skip to content

Commit

Permalink
Fix ITs on VS2017 slaves
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Mar 24, 2017
1 parent e17e814 commit a8c7e1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -x
get_version() {
if [ "DEV" == "$1" ]; then
local assemblyInfoFile=../AssemblyInfo.Shared.cs
local version=`sed -bn "s|\[assembly: AssemblyVersion(\"\([0-9.]*\)\")\]|\1|p" $assemblyInfoFile | sed 's/\r//'`
local version=`sed -n "s|\[assembly: AssemblyVersion(\"\([0-9.]*\)\")\]|\1|p" $assemblyInfoFile | sed 's/\r//'`

if [ -z $version ]; then
echo "Failed to find assembly version in $assemblyInfoFile"
Expand All @@ -33,4 +33,4 @@ get_version $SCANNER_PAYLOAD_VERSION
SCANNER_PAYLOAD_VERSION=$output

# default versions of csharp and vbnet plugin are defined in the pom file
mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -DfxcopVersion=LATEST_RELEASE
mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -DfxcopVersion=LATEST_RELEASE -Dmsbuild.path=$MSBUILD_PATH
14 changes: 6 additions & 8 deletions its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.CheckForNull;

import org.apache.commons.io.FileUtils;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
Expand All @@ -55,7 +53,7 @@
import static org.assertj.core.api.Assertions.assertThat;

public class TestUtils {
public static final String MSBUILD_HOME = "msbuild.home";
public static final String MSBUILD_PATH = "msbuild.path";
private final static Logger LOG = LoggerFactory.getLogger(ScannerMSBuildTest.class);

public static Path prepareCSharpPlugin(TemporaryFolder temp) {
Expand All @@ -73,7 +71,7 @@ public static Path prepareCSharpPlugin(TemporaryFolder temp) {
if (locators.copyToFile(csharp, modifiedCs.toFile()) == null) {
throw new IllegalStateException("Couldn't locate csharp plugin in the local maven repository: " + csharp);
}

String scannerPayloadVersion = getScannerPayloadVersion();

Path scannerImpl;
Expand Down Expand Up @@ -164,13 +162,13 @@ public static Path projectDir(TemporaryFolder temp, String projectName) throws I
}

public static void runMSBuild(Orchestrator orch, Path projectDir, String... arguments) {
String msBuildHome = orch.getConfiguration().getString(MSBUILD_HOME, "C:\\Program Files (x86)\\MSBuild\\14.0");
Path msBuildPath = Paths.get(msBuildHome).toAbsolutePath();
String msBuildPathStr = orch.getConfiguration().getString(MSBUILD_PATH, "C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\MSBuild.exe");
Path msBuildPath = Paths.get(msBuildPathStr).toAbsolutePath();
if (!Files.exists(msBuildPath)) {
throw new IllegalStateException("Unable to find MSBuild at " + msBuildPath.toString() + ". Please configure property '" + MSBUILD_HOME + "'");
throw new IllegalStateException("Unable to find MSBuild at " + msBuildPath.toString() + ". Please configure property '" + MSBUILD_PATH + "'");
}

int r = CommandExecutor.create().execute(Command.create(msBuildPath.resolve("bin/MSBuild.exe").toString())
int r = CommandExecutor.create().execute(Command.create(msBuildPath.toString())
.addArguments(arguments)
.setDirectory(projectDir.toFile()), 60 * 1000);
assertThat(r).isEqualTo(0);
Expand Down

0 comments on commit a8c7e1a

Please sign in to comment.