react-native-navigation的迁移库

test-unit.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const includes = require('lodash/includes');
  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. exec.execSync('npm run build');
  23. exec.execSync('npm run pod-install');
  24. testTarget('playground', 'iPhone 11');
  25. testTarget('playgroundIOS12', 'iPhone X', '12.2');
  26. }
  27. function testTarget(scheme, device, OS = 'latest') {
  28. const conf = release ? `Release` : `Debug`;
  29. exec.execSync(`cd ./playground/ios &&
  30. RCT_NO_LAUNCH_PACKAGER=true
  31. xcodebuild build build-for-testing
  32. -scheme "${scheme}"
  33. -workspace playground.xcworkspace
  34. -sdk iphonesimulator
  35. -configuration ${conf}
  36. -derivedDataPath ./DerivedData/playground
  37. -quiet
  38. -UseModernBuildSystem=NO
  39. ONLY_ACTIVE_ARCH=YES`);
  40. exec.execSync(`cd ./playground/ios &&
  41. RCT_NO_LAUNCH_PACKAGER=true
  42. xcodebuild test-without-building
  43. -scheme "${scheme}"
  44. -workspace playground.xcworkspace
  45. -sdk iphonesimulator
  46. -configuration ${conf}
  47. -destination 'platform=iOS Simulator,name=${device},OS=${OS}'
  48. -derivedDataPath ./DerivedData/playground
  49. ONLY_ACTIVE_ARCH=YES`);
  50. }
  51. run();