react-native-navigation的迁移库

e2e.ios.js 2.4KB

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