diff --git a/packages/nextjs/test/integration_test_utils.sh b/packages/nextjs/test/integration_test_utils.sh new file mode 100644 index 000000000000..48d76685f234 --- /dev/null +++ b/packages/nextjs/test/integration_test_utils.sh @@ -0,0 +1,51 @@ +function link_package() { + local package_abs_path=$1 + local package_name=$2 + + echo "Setting up @sentry/${package_name} for linking" + pushd $package_abs_path + yarn link + popd + + echo "Linking @sentry/$package_name" + yarn link "@sentry/$package_name" + +} + +# Note: LINKED_CLI_REPO and LINKED_PLUGIN_REPO in the functions below should be set to the absolute path of each local repo + +function linkcli() { + if [[ ! $LINKED_CLI_REPO ]]; then + return + fi + + # check to make sure the repo directory exists + if [[ -d $LINKED_CLI_REPO ]]; then + link_package $LINKED_CLI_REPO "cli" + else + # the $1 lets us insert a string in that spot if one is passed to `linkcli` (useful for when we're calling this from + # within another linking function) + echo "ERROR: Can't link @sentry/cli $1because directory $LINKED_CLI_REPO does not exist." + fi +} + +function linkplugin() { + if [[ ! $LINKED_PLUGIN_REPO ]]; then + return + fi + + # check to make sure the repo directory exists + if [[ -d $LINKED_PLUGIN_REPO ]]; then + link_package $LINKED_PLUGIN_REPO "webpack-plugin" + + # the webpack plugin depends on `@sentry/cli`, so if we're also using a linked version of the cli package, the + # plugin needs to link to it, too + if [[ $LINKED_CLI_REPO ]]; then + pushd $LINKED_PLUGIN_REPO + link_cli "in webpack plugin repo " + popd + fi + else + echo "ERROR: Can't link @sentry/wepack-plugin because $LINKED_PLUGIN_REPO does not exist." + fi +} diff --git a/packages/nextjs/test/run-integration-tests.sh b/packages/nextjs/test/run-integration-tests.sh index e98e2602201e..b44a617e1ed6 100755 --- a/packages/nextjs/test/run-integration-tests.sh +++ b/packages/nextjs/test/run-integration-tests.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source test/integration_test_utils.sh + set -e START_TIME=$(date -R) @@ -55,6 +57,9 @@ for NEXTJS_VERSION in 10 11; do sed -i /"next.*latest"/s/latest/"${NEXTJS_VERSION}.x"/ package.json fi yarn --no-lockfile --silent >/dev/null 2>&1 + # if applicable, use local versions of `@sentry/cli` and/or `@sentry/webpack-plugin` (these commands no-op unless + # LINKED_CLI_REPO and/or LINKED_PLUGIN_REPO is set) + linkcli && linkplugin mv -f package.json.bak package.json 2>/dev/null || true for RUN_WEBPACK_5 in false true; do @@ -72,9 +77,10 @@ for NEXTJS_VERSION in 10 11; do echo "[nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION] Building..." yarn build | grep "Using webpack" + # if the user hasn't passed any args, use the default one, which restricts each test to only outputting success and + # failure messages args=$* if [[ ! $args ]]; then - # restrict each test to only output success and failure messages args="--silent" fi