Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 4 additions & 44 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,27 +163,15 @@ class RNAndroid extends Platform.Android implements RNPlatform {
return TestUtil.getProcessOutput("adb install -r " + this.getBinaryPath(projectDirectory), { cwd: androidDirectory }).then(() => { return null; });
}

/**
* Build function of the test application, the command depends on the OS
*/
buildFunction(androidDirectory: string): Q.Promise<void> {
const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew";
return TestUtil.getProcessOutput(`${gradlewCommand} assembleRelease`, { noLogStdOut: true, cwd: androidDirectory })
.then(() => { return null; });
}

/**
* Builds the binary of the project on this platform.
*/
buildApp(projectDirectory: string): Q.Promise<void> {
// In order to run on Android without the package manager, we must create a release APK and then sign it with the debug certificate.
const androidDirectory: string = path.join(projectDirectory, TestConfig.TestAppName, "android");
// If the build fails for the first time, try rebuild app again
try {
return this.buildFunction(androidDirectory);
} catch {
return this.buildFunction(androidDirectory);
}
const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew";
return TestUtil.getProcessOutput(`${gradlewCommand} assembleRelease`, { noLogStdOut: true, cwd: androidDirectory })
.then(() => { return null; });
}
}

Expand Down Expand Up @@ -262,19 +250,6 @@ class RNIOS extends Platform.IOS implements RNPlatform {
return TestUtil.getProcessOutput("xcrun simctl install booted " + this.getBinaryPath(projectDirectory)).then(() => { return null; });
}

/**
* Maps project directories to whether or not they have built an IOS project before.
*
* The first build of an IOS project does not always succeed, so we always try again when it fails.
*
* EXAMPLE:
* {
* "TEMP_DIR/test-run": true,
* "TEMP_DIR/updates": false
* }
*/
private static iosFirstBuild: any = {};

/**
* Builds the binary of the project on this platform.
*/
Expand All @@ -286,22 +261,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
return TestUtil.getProcessOutput("xcodebuild -workspace " + path.join(iOSProject, TestConfig.TestAppName) + ".xcworkspace -scheme " + TestConfig.TestAppName +
" -configuration Release -destination \"platform=iOS Simulator,id=" + targetEmulator + "\" -derivedDataPath build", { cwd: iOSProject, timeout: 10 * 60 * 1000, maxBuffer: 1024 * 1024 * 5000, noLogStdOut: true });
})
.then<void>(
() => { return null; },
(error: any) => {
console.info(error);
// The first time an iOS project is built, it fails because it does not finish building libReact.a before it builds the test app.
// Simply build again to fix the issue.
if (!RNIOS.iosFirstBuild[projectDirectory]) {
const iosBuildFolder = path.join(iOSProject, "build");
if (fs.existsSync(iosBuildFolder)) {
del.sync([iosBuildFolder], { force: true });
}
RNIOS.iosFirstBuild[projectDirectory] = true;
return this.buildApp(projectDirectory);
}
return null;
});
.then<void>(() => { return null; });
}
}

Expand Down