react-native-navigation的迁移库

e2e.ios.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 -en 'travis_fold:start:xcodebuild\n'`);
  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. console.log(`*********** 1`);
  27. shellUtils.exec.execSync(`echo -en 'travis_fold:end:xcodebuild\n'`);
  28. console.log(`*********** 2`);
  29. }
  30. function hasXcpretty() {
  31. try {
  32. return shellUtils.exec.execSyncRead(`which xcpretty`);
  33. } catch (e) {
  34. return false;
  35. }
  36. }
  37. function e2e() {
  38. try {
  39. console.log(`*********** 3`);
  40. //shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
  41. //shellUtils.exec.kill(`detox-server`);
  42. shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
  43. console.log(`*********** 4`);
  44. //const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
  45. //
  46. //shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  47. // BABEL_ENV=test
  48. // ./node_modules/mocha/bin/mocha e2e
  49. // --timeout 120000
  50. // --recursive
  51. // --compilers js:babel-register`);
  52. } finally {
  53. //shellUtils.exec.execSync(`./scripts/detoxDebugFix.rb`);
  54. //shellUtils.exec.kill(`detox-server`);
  55. //if (release) {
  56. // shellUtils.exec.kill(`Simulator`);
  57. // shellUtils.exec.kill(`CoreSimulator`);
  58. //}
  59. //shellUtils.exec.execSync(`cat ./detox-server.log`);
  60. //shellUtils.exec.execSync(`rm -f ./detox-server.log`);
  61. //shellUtils.exec.execSync(`sleep 5`);
  62. }
  63. }
  64. function run() {
  65. hackReactXcodeScript();
  66. buildProjForDetox();
  67. e2e();
  68. }
  69. run();