|
@@ -1,43 +1,52 @@
|
1
|
|
-const cp = require('child_process');
|
|
1
|
+const _ = require('lodash');
|
|
2
|
+const exec = require('./exec');
|
|
3
|
+const fs = require('fs');
|
2
|
4
|
|
3
|
|
-function exec(cmd) {
|
4
|
|
- cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
|
5
|
|
-}
|
6
|
|
-
|
7
|
|
-function execSilent(cmd) {
|
8
|
|
- cp.execSync(cmd, {stdio: ['inherit', 'ignore', 'inherit']});
|
9
|
|
-}
|
|
5
|
+const release = _.includes(process.argv, 'release');
|
10
|
6
|
|
11
|
|
-function kill(process) {
|
12
|
|
- execSilent(`pkill -f "${process}" || true`);
|
|
7
|
+function hackReactXcodeScript() {
|
|
8
|
+ const fileToHack = `./node_modules/react-native/packager/react-native-xcode.sh`;
|
|
9
|
+ const lines = _.split(String(fs.readFileSync(fileToHack)), '\n');
|
|
10
|
+ lines[11] = release ? '' : `exit 0;`;
|
|
11
|
+ fs.writeFileSync(fileToHack, _.join(lines, '\n'));
|
13
|
12
|
}
|
14
|
13
|
|
15
|
14
|
function buildProjForDetox() {
|
16
|
|
- exec(`RCT_NO_LAUNCH_PACKAGER=true \
|
|
15
|
+ const scheme = release ? `playground_release_Detox` : `playground_Detox`;
|
|
16
|
+ const args = release ? '' : `GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`;
|
|
17
|
+
|
|
18
|
+ exec.exec(`RCT_NO_LAUNCH_PACKAGER=true \
|
17
|
19
|
cd ios && xcodebuild \
|
18
|
|
- -scheme playground_Detox build \
|
|
20
|
+ -scheme ${scheme} build \
|
19
|
21
|
-project playground.xcodeproj \
|
20
|
22
|
-sdk iphonesimulator \
|
21
|
23
|
-derivedDataPath ./DerivedData/playground \
|
22
|
|
- GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`);
|
|
24
|
+ ${args}`);
|
23
|
25
|
}
|
24
|
26
|
|
25
|
27
|
function e2e() {
|
26
|
28
|
try {
|
27
|
29
|
kill(`detox-server`);
|
28
|
|
- cp.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
|
29
|
|
- exec(`BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
|
|
30
|
+ exec.execAsync(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
|
|
31
|
+ exec.exec(`${release ? 'detoxMode=release' : ''} BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --compilers js:babel-register`);
|
30
|
32
|
} finally {
|
31
|
33
|
kill(`detox-server`);
|
32
|
|
- //kill(`Simulator`);
|
33
|
|
- //kill(`CoreSimulator`);
|
34
|
|
- exec(`cat ./detox-server.log`);
|
35
|
|
- exec(`rm -f ./detox-server.log`);
|
36
|
|
- exec(`sleep 5`);
|
|
34
|
+ if (release) {
|
|
35
|
+ kill(`Simulator`);
|
|
36
|
+ kill(`CoreSimulator`);
|
|
37
|
+ }
|
|
38
|
+ exec.exec(`cat ./detox-server.log`);
|
|
39
|
+ exec.exec(`rm -f ./detox-server.log`);
|
|
40
|
+ exec.exec(`sleep 5`);
|
37
|
41
|
}
|
38
|
42
|
}
|
39
|
43
|
|
|
44
|
+function kill(process) {
|
|
45
|
+ exec.execSilent(`pkill -f "${process}"`);
|
|
46
|
+}
|
|
47
|
+
|
40
|
48
|
function run() {
|
|
49
|
+ hackReactXcodeScript();
|
41
|
50
|
buildProjForDetox();
|
42
|
51
|
e2e();
|
43
|
52
|
}
|