diff --git a/test/test.ts b/test/test.ts index ddd5665..e9ad375 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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 { - 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 { // 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; }); } } @@ -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. */ @@ -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( - () => { 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(() => { return null; }); } }