react-native-navigation的迁移库

test-unit.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const _ = require('lodash');
  2. const exec = require('shell-utils').exec;
  3. const android = _.includes(process.argv, '--android');
  4. const release = _.includes(process.argv, '--release');
  5. function run() {
  6. if (android) {
  7. runAndroidUnitTests();
  8. } else {
  9. runIosUnitTests();
  10. }
  11. }
  12. function runAndroidUnitTests() {
  13. const conf = release ? 'testReactNative60ReleaseUnitTest' : 'testReactNative60DebugUnitTest';
  14. if (android && process.env.JENKINS_CI) {
  15. const sdkmanager = '/usr/local/share/android-sdk/tools/bin/sdkmanager';
  16. exec.execSync(`yes | ${sdkmanager} --licenses`);
  17. // exec.execSync(`echo y | ${sdkmanager} --update && echo y | ${sdkmanager} --licenses`);
  18. }
  19. exec.execSync(`cd lib/android && ./gradlew ${conf}`);
  20. }
  21. function runIosUnitTests() {
  22. const conf = release ? `Release` : `Debug`;
  23. exec.execSync('npm run build');
  24. exec.execSync('npm run pod-install');
  25. exec.execSync(`cd ./playground/ios &&
  26. RCT_NO_LAUNCH_PACKAGER=true
  27. xcodebuild build build-for-testing
  28. -scheme "playground"
  29. -workspace playground.xcworkspace
  30. -sdk iphonesimulator
  31. -configuration ${conf}
  32. -derivedDataPath ./DerivedData/playground
  33. -quiet
  34. -UseModernBuildSystem=NO
  35. ONLY_ACTIVE_ARCH=YES`);
  36. exec.execSync(`cd ./playground/ios &&
  37. RCT_NO_LAUNCH_PACKAGER=true
  38. xcodebuild test-without-building
  39. -scheme "playground"
  40. -workspace playground.xcworkspace
  41. -sdk iphonesimulator
  42. -configuration ${conf}
  43. -destination 'platform=iOS Simulator,name=iPhone 11'
  44. -derivedDataPath ./DerivedData/playground
  45. ONLY_ACTIVE_ARCH=YES`);
  46. }
  47. run();