|
|
@@ -1,39 +1,31 @@
|
|
1
|
1
|
const _ = require('lodash');
|
|
2
|
|
-const shellUtils = require('shell-utils');
|
|
|
2
|
+const exec = require('shell-utils').exec;
|
|
3
|
3
|
|
|
4
|
4
|
const release = _.includes(process.argv, 'release');
|
|
5
|
5
|
|
|
6
|
6
|
function buildProjForDetox() {
|
|
7
|
7
|
const scheme = release ? `playground_release` : `playground`;
|
|
8
|
8
|
|
|
9
|
|
- const cmd = `RCT_NO_LAUNCH_PACKAGER=true
|
|
10
|
|
- cd ./playground/ios && xcodebuild
|
|
|
9
|
+ const cmd = `cd ./playground/ios && xcodebuild
|
|
11
|
10
|
-scheme ${scheme}
|
|
12
|
11
|
${release ? 'clean build' : 'build'}
|
|
13
|
12
|
-project playground.xcodeproj
|
|
14
|
13
|
-sdk iphonesimulator
|
|
15
|
14
|
-derivedDataPath ./DerivedData/playground`;
|
|
16
|
15
|
|
|
17
|
|
- if (isInstalled(`xcpretty`)) {
|
|
18
|
|
- shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
|
|
|
16
|
+ if (exec.which(`xcpretty`)) {
|
|
|
17
|
+ exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
|
|
19
|
18
|
} else {
|
|
20
|
|
- shellUtils.exec.execSync(`${cmd}`);
|
|
21
|
|
- }
|
|
22
|
|
-}
|
|
23
|
|
-function isInstalled(what) {
|
|
24
|
|
- try {
|
|
25
|
|
- return shellUtils.exec.execSyncRead(`which ${what}`);
|
|
26
|
|
- } catch (e) {
|
|
27
|
|
- return false;
|
|
|
19
|
+ exec.execSync(`${cmd}`);
|
|
28
|
20
|
}
|
|
29
|
21
|
}
|
|
30
|
22
|
|
|
31
|
23
|
function e2e() { //eslint-disable-line
|
|
32
|
24
|
try {
|
|
33
|
|
- shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
|
|
|
25
|
+ exec.execSyncSilent(`watchman watch-del-all || true`);
|
|
34
|
26
|
const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
|
|
35
|
27
|
|
|
36
|
|
- shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
|
|
|
28
|
+ exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
|
|
37
|
29
|
BABEL_ENV=test
|
|
38
|
30
|
./node_modules/mocha/bin/mocha e2e
|
|
39
|
31
|
--timeout ${2 * 60 * 1000}
|
|
|
@@ -41,24 +33,17 @@ function e2e() { //eslint-disable-line
|
|
41
|
33
|
--bail`);
|
|
42
|
34
|
} finally {
|
|
43
|
35
|
if (process.env.CI) {
|
|
44
|
|
- shellUtils.exec.kill(`Simulator`);
|
|
45
|
|
- shellUtils.exec.kill(`CoreSimulator`);
|
|
46
|
|
- shellUtils.exec.execSync(`sleep 5`);
|
|
|
36
|
+ exec.kill(`Simulator`);
|
|
|
37
|
+ exec.kill(`CoreSimulator`);
|
|
|
38
|
+ exec.execSync(`sleep 5`);
|
|
47
|
39
|
}
|
|
48
|
40
|
}
|
|
49
|
41
|
}
|
|
50
|
42
|
|
|
51
|
|
-function installFbsimctlIfNeeded() {
|
|
52
|
|
- if (!isInstalled(`fbsimctl`)) {
|
|
53
|
|
- console.log(`installing fbsimctl...`); //eslint-disable-line
|
|
54
|
|
- shellUtils.exec.execSyncSilent(`brew tap facebook/fb && brew install fbsimctl`);
|
|
55
|
|
- }
|
|
56
|
|
-}
|
|
57
|
|
-
|
|
58
|
43
|
function run() {
|
|
59
|
|
- shellUtils.exec.execSync(`./scripts/ignoreReactWarnings.rb`);
|
|
60
|
|
- shellUtils.exec.execSync(`node ./scripts/fixRN38.js`);
|
|
61
|
|
- installFbsimctlIfNeeded();
|
|
|
44
|
+ if (!exec.which(`fbsimctl`)) {
|
|
|
45
|
+ throw new Error(`fbsimctl must be installed: "brew tap facebook/fb && brew install fbsimctl"`);
|
|
|
46
|
+ }
|
|
62
|
47
|
buildProjForDetox();
|
|
63
|
48
|
e2e();
|
|
64
|
49
|
}
|