react-native-navigation的迁移库

e2e.ios.js 1.6KB

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