Skip to content

Commit 1d51d18

Browse files
committed
JS: Extractor: Explain how to make replaceExpectedOutput work now with bazel
1 parent 04a0740 commit 1d51d18

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

javascript/extractor/test/com/semmle/js/extractor/test/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ java_test(
1212
"TS_WRAPPER_ZIP": "$(rlocationpath //javascript/extractor/lib/typescript)",
1313
},
1414
test_class = "com.semmle.js.extractor.test.AllTests",
15+
# To use `replaceExpectedOutput` you need to uncomment the following line
16+
# (to be allowed to override the .trap files on disk)
17+
# tags = ["no-sandbox"],
1518
deps = [
1619
"//javascript/extractor",
1720
"//javascript/extractor:deps",

javascript/extractor/test/com/semmle/js/extractor/test/TrapTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ public void close() {
161161
byte[] actual_utf8_bytes = StringUtil.stringToBytes(sw.toString());
162162
String actual = new String(actual_utf8_bytes, Charset.forName("UTF-8"));
163163
File trap = new File(outputDir, f.getName() + ".trap");
164+
// NOTE: If you want to replace expected output, you MUST change
165+
// the way this test is run under bazel to escape the bazel
166+
// sandbox. Add `tags = ["no-sandbox"]` to the test rule in
167+
// javascript/extractor/test/com/semmle/js/extractor/test/BUILD.bazel
168+
//
169+
// if you have problems with too much caching, you need to find the right bazel command,
170+
// and run `./build --bazel test ... --cache_test_results=no`
171+
// (at least I had problems getting the "no-cache" tag to work)
164172
boolean replaceExpectedOutput = false;
165173
if (replaceExpectedOutput) {
166174
System.out.println("Replacing expected output for " + trap);

0 commit comments

Comments
 (0)