diff --git a/internal/bazel_integration_test/BUILD.bazel b/internal/bazel_integration_test/BUILD.bazel index 8f1ce697a9..91d9672378 100644 --- a/internal/bazel_integration_test/BUILD.bazel +++ b/internal/bazel_integration_test/BUILD.bazel @@ -19,6 +19,7 @@ package(default_visibility = ["//visibility:public"]) nodejs_binary( name = "test_runner", + configuration_env_vars = ["BAZEL_INTEGRATION_TEST_DEBUG"], data = ["@npm//tmp"], entry_point = ":test_runner.js", # reduce memory usage by disabling source_map_support diff --git a/internal/bazel_integration_test/bazel_integration_test.bzl b/internal/bazel_integration_test/bazel_integration_test.bzl index c4df1c3bb9..8f5aa05c9a 100644 --- a/internal/bazel_integration_test/bazel_integration_test.bzl +++ b/internal/bazel_integration_test/bazel_integration_test.bzl @@ -244,7 +244,13 @@ is published on GitHub. bazel_integration_test = rule( implementation = _bazel_integration_test, - doc = """Runs an integration test by running a specified version of bazel against an external workspace.""", + doc = """Runs an integration test by running a specified version of bazel against an external workspace. + +Run with --define=BAZEL_INTEGRATION_TEST_DEBUG=1 to put the test in debug mode which will +preserve the workspace under test root /tmp folder and exit without running the test. This +allows you to change directory into the workspace under test root folder and run the integration +test manually. +""", attrs = BAZEL_INTEGRATION_TEST_ATTRS, test = True, ) diff --git a/internal/bazel_integration_test/test_runner.js b/internal/bazel_integration_test/test_runner.js index 70276caf6e..14c25dfbdf 100644 --- a/internal/bazel_integration_test/test_runner.js +++ b/internal/bazel_integration_test/test_runner.js @@ -24,7 +24,7 @@ const fs = require('fs'); const path = require('path'); const tmp = require('tmp'); -const DEBUG = process.env['COMPILATION_MODE'] === 'dbg'; +const DEBUG = !!process.env['BAZEL_INTEGRATION_TEST_DEBUG']; const VERBOSE_LOGS = !!process.env['VERBOSE_LOGS']; function log(...m) { @@ -283,18 +283,25 @@ const isWindows = process.platform === 'win32'; const bazelBinary = require.resolve(`${config.bazelBinaryWorkspace}/bazel${isWindows ? '.exe' : ''}`); -if (DEBUG || VERBOSE_LOGS) { - // If DEBUG is set then the tmp folders created by the `tmp.dirSync` are not - // cleaned up so we should log out the location of the workspace under test - // tmp folder in that case even if VERBOSE_LOGS is not set as it may be useful - // to `cd /path/to/workspace/tmp` for manual testing at that point. +if (DEBUG) { log(` -******************************************************************************** -bazel binary under test is ${bazelBinary} -workspace under test root is ${workspaceRoot} -******************************************************************************** +================================================================================ +Integration test put in DEBUG mode with BAZEL_INTEGRATION_TEST_DEBUG env set. + + bazel binary: ${bazelBinary} + workspace under test root: ${workspaceRoot} + +Change directory to workspace under test root folder, + + cd ${workspaceRoot} + +and run integration test manually. +================================================================================ `); + // Exit with error code so that BAZEL_INTEGRATION_TEST_DEBUG does not lead + // to a accidental passing test. + process.exit(1); } log(`running 'bazel version'`); diff --git a/package.json b/package.json index 4ee123399b..b35ebb1961 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "test_e2e": "bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m test --test_tag_filters=e2e --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0", "test_examples": "bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m test --test_tag_filters=examples --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0", "run_integration_test": "bazel --host_jvm_args=-Xms256m --host_jvm_args=-Xmx1280m run --local_resources=792,1.0,1.0 --test_arg=--local_resources=13288,1.0,1.0", - "run_integration_test_debug": "yarn run_integration_test --compilation_mode=dbg", + "run_integration_test_debug": "yarn run_integration_test --define=BAZEL_INTEGRATION_TEST_DEBUG=1", "test_all": "./scripts/test_all.sh", "clean_all": "./scripts/clean_all.sh", "// Unchecked warnings": "The following warnings are not checked as disabling them locally is broken",