Skip to content

Commit

Permalink
test: bazel_integration_test should use --define=BAZEL_INTEGRATION_TE…
Browse files Browse the repository at this point in the history
…ST_DEBUG=1 to go into debug mode

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 so that
you can change directory into the workspace under test root folder and run the integration
test manually.

This is a different concept from --compilation_mode as this is meant to put the test into a debug mode rather than generate debug build artifacts.
  • Loading branch information
gregmagolan committed Jan 2, 2020
1 parent c1b97d6 commit 0abc7f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions internal/bazel_integration_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion internal/bazel_integration_test/bazel_integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
27 changes: 17 additions & 10 deletions internal/bazel_integration_test/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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'`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0abc7f2

Please sign in to comment.