Update the Swift tests for Swift Package Manager 4.0.

SwiftPM has changed its default layout for new packages (i.e. when we
use "swift package init --type executable" during the test).  It now is
<projectName>/Sources/<projectName>/main.swift, so we need to adjust the
paths appropriately.

This includes a small change to print stdout as well as stderr if a
unit test fails to build.  swift-build-tool takes the compiler subprocess's
stderr and puts it on stdout.  *sheesh*  This meant that we were losing
critical error messages.
This commit is contained in:
Ewan Mellor 2017-10-12 15:54:02 -07:00
parent 7aa6b544d9
commit 39c01f6da7
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
1 changed files with 5 additions and 5 deletions

View File

@ -145,7 +145,7 @@ public class BaseSwiftTest implements RuntimeTestSupport {
String projectName = "testcase-" + System.currentTimeMillis();
String projectDir = getTmpDir() + "/" + projectName;
buildProject(projectDir);
buildProject(projectDir, projectName);
return execTest(projectDir, projectName);
}
@ -183,12 +183,12 @@ public class BaseSwiftTest implements RuntimeTestSupport {
Collections.addAll(this.sourceFiles, files);
}
private void buildProject(String projectDir) {
private void buildProject(String projectDir, String projectName) {
mkdir(projectDir);
fastFailRunProcess(projectDir, SWIFT_CMD, "package", "init", "--type", "executable");
for (String sourceFile: sourceFiles) {
String absPath = getTmpDir() + "/" + sourceFile;
fastFailRunProcess(getTmpDir(), "mv", "-f", absPath, projectDir + "/Sources/");
fastFailRunProcess(getTmpDir(), "mv", "-f", absPath, projectDir + "/Sources/" + projectName);
}
fastFailRunProcess(getTmpDir(), "mv", "-f", "input", projectDir);
@ -201,7 +201,7 @@ public class BaseSwiftTest implements RuntimeTestSupport {
"-Xlinker", "-rpath",
"-Xlinker", dylibPath);
if (buildResult.b.length() > 0) {
throw new RuntimeException("unit test build failed: " + buildResult.b);
throw new RuntimeException("unit test build failed: " + buildResult.a + "\n" + buildResult.b);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
@ -251,7 +251,7 @@ public class BaseSwiftTest implements RuntimeTestSupport {
addSourceFiles("main.swift");
String projectName = "testcase-" + System.currentTimeMillis();
String projectDir = getTmpDir() + "/" + projectName;
buildProject(projectDir);
buildProject(projectDir, projectName);
return execTest(projectDir, projectName);
}