prepare-mochitests-dev 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash -x -e
  2. #
  3. # -e means "exit on error", so that we don't have to constantly
  4. # check exit codes
  5. #
  6. # Forked from https://github.com/devtools-html/debugger.html/blob/master/bin/prepare-mochitests-dev
  7. #
  8. # This sets up a mozilla-central build for local mochitest development with an
  9. # exported activity-stream tree and test directory.
  10. # If AS_GIT_BIN_REPO (the git repo from which prepare-mochitests-dev and
  11. # friends will be executed) isn't set in the environment, just use the repo
  12. # we're running from.
  13. if [ -z ${AS_GIT_BIN_REPO+x} ]; then
  14. ROOT=`dirname $0`
  15. AS_GIT_BIN_REPO="../activity-stream" # as seen from mozilla-central
  16. else
  17. ROOT=${AS_GIT_BIN_REPO}/bin
  18. fi
  19. # Compute the mozilla-central path based on whether AS_PINE_TEST_DIR is set
  20. # (i.e. whether this script has been called from test-merges.js)
  21. if [ -z ${AS_PINE_TEST_DIR+x} ]; then
  22. FIREFOX_PATH="$ROOT/../../mozilla-central"
  23. else
  24. FIREFOX_PATH=${AS_PINE_TEST_DIR}/mozilla-central
  25. fi
  26. MC_MODULE_PATH="$FIREFOX_PATH/browser/components/newtab"
  27. # By default, just use mozilla-central + the export. If ENABLE_MC_AS is set to
  28. # 1, patch on top of mozilla-central + the export to turn on the AS pref and
  29. # turn on the tests. Once AS is on by default in mozilla-central, stuff
  30. # related to ENABLE_MC_AS can go away entirely.
  31. ENABLE_MC_AS=${ENABLE_MC_AS-0}
  32. # This will either download or update the local Firefox repo
  33. "$ROOT/download-firefox-artifact"
  34. # blow away any old bits in order to workaround bug 1335976 for users
  35. # who are using the default objdir-frontend
  36. rm -f ${FIREFOX_PATH}/objdir-frontend/dist/bin/browser/features/@activity-streams/*
  37. # Clean, package, and copy the activity stream files.
  38. npm run buildmc
  39. # Patch mozilla-central (on top of the export) so that AS is preffed on, and
  40. # the mochitests are turned on.
  41. shopt -s nullglob # don't explode if there are no patches right now
  42. if [ $ENABLE_MC_AS ]; then
  43. PATCHES=$AS_GIT_BIN_REPO/mozilla-central-patches/*.diff
  44. for p in $PATCHES
  45. do
  46. patch --directory="$FIREFOX_PATH" -p1 --force --no-backup-if-mismatch \
  47. --input=$p
  48. done
  49. fi
  50. shopt -u nullglob
  51. # Be sure that we've built, and that the test glop in the objdir has been
  52. # created.
  53. #
  54. cd "$FIREFOX_PATH"
  55. ./mach build
  56. exit $?