react-native-navigation的迁移库

e2e.ios.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const _ = require('lodash');
  2. const shellUtils = require('shell-utils');
  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. shellUtils.exec.execSync(`./scripts/detoxDebugFix.rb ${release ? '' : 'debug'}`);
  14. shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
  15. const cmd = `RCT_NO_LAUNCH_PACKAGER=true
  16. cd ios && xcodebuild
  17. -scheme ${scheme}
  18. ${release ? 'clean build' : 'build'}
  19. -project playground.xcodeproj
  20. -sdk iphonesimulator
  21. -derivedDataPath ./DerivedData/playground`;
  22. if (hasXcpretty()) {
  23. shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  24. } else {
  25. shellUtils.exec.execSync(`${cmd}`);
  26. }
  27. shellUtils.exec.execSync(`echo 'travis_fold:end:xcodebuild'`);
  28. }
  29. function hasXcpretty() {
  30. try {
  31. return shellUtils.exec.execSyncRead(`which xcpretty`);
  32. } catch (e) {
  33. return false;
  34. }
  35. }
  36. function e2e() {
  37. try {
  38. shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
  39. shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
  40. shellUtils.exec.kill(`detox-server`);
  41. shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
  42. const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
  43. shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  44. BABEL_ENV=test
  45. ./node_modules/mocha/bin/mocha e2e
  46. --timeout 240000
  47. --recursive
  48. --compilers js:babel-register`);
  49. } finally {
  50. shellUtils.exec.execSync(`./scripts/detoxDebugFix.rb`);
  51. shellUtils.exec.kill(`detox-server`);
  52. shellUtils.exec.execSync(`cat ./detox-server.log`);
  53. shellUtils.exec.execSync(`rm -f ./detox-server.log`);
  54. shellUtils.exec.execSync(`sleep 5`);
  55. shellUtils.exec.execSync(`echo 'travis_fold:end:detox-ios'`);
  56. }
  57. }
  58. function run() {
  59. hackReactXcodeScript();
  60. buildProjForDetox();
  61. e2e();
  62. }
  63. run();