Skip to content

Commit d979564

Browse files
committed
test: mocha fs sandbox tests
1 parent 2d1fba5 commit d979564

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

examples/macro/mocha.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ def mocha_test(name, srcs, args = [], data = [], env = {}, **kwargs):
2222
# to the location Bazel expects.
2323
"MOCHA_FILE": "$$XML_OUTPUT_FILE",
2424
}),
25+
preserve_symlinks_main = False,
26+
copy_data_to_bin = False,
2527
**kwargs
2628
)

examples/macro/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const assert = require('assert')
2+
const { dirname } = require('node:path')
23

34
describe('mocha', () => {
45
it('integrates with Bazel', () => {
@@ -8,4 +9,13 @@ describe('mocha', () => {
89
it('is in bazel-out', () => {
910
assert.match(__dirname, /bazel-out/)
1011
})
12+
13+
it('is sandboxed', () => {
14+
assert.match(__dirname, /examples\/macro\/test_\/test\.runfiles/)
15+
assert.match(
16+
__filename,
17+
/-sandbox\/\d+\/execroot\/_main\/bazel-out\/[^/]+\/bin\/examples\/macro\/test_\/test.runfiles\/_main\/examples\/macro\/test\.js/
18+
)
19+
assert.equal(__dirname, dirname(__filename))
20+
})
1121
})

0 commit comments

Comments
 (0)