Skip to content

Commit b8b0932

Browse files
committed
Fix expect test dependencies
When there is a custom runner, the rule that executes the test should have a dependency on the executable.
1 parent 18f2b8a commit b8b0932

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

src/dune_rules/test_rules.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,20 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
7070
| `js -> Jsoo_rules.js_of_ocaml_runtest_alias ~dir
7171
| `exe | `bc -> Memo.return Alias0.runtest
7272
in
73+
let deps =
74+
match custom_runner with
75+
| Some _ ->
76+
Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe))
77+
:: t.deps
78+
| None -> t.deps
79+
in
7380
let add_alias ~loc ~action ~locks =
7481
(* CR-rgrinberg: why are we going through the stanza api? *)
7582
let alias =
7683
{ Alias_conf.name = runtest_alias
7784
; locks
7885
; package = t.package
79-
; deps =
80-
(match custom_runner with
81-
| Some _ ->
82-
Bindings.Unnamed
83-
(Dep_conf.File (String_with_vars.make_text loc test_exe))
84-
:: t.deps
85-
| None -> t.deps)
86+
; deps
8687
; action = Some (loc, action)
8788
; enabled_if = t.enabled_if
8889
; loc
@@ -95,7 +96,7 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
9596
| `Expect diff ->
9697
let rule =
9798
{ Rule_conf.targets = Infer
98-
; deps = t.deps
99+
; deps
99100
; action =
100101
( loc
101102
, Action_unexpanded.Redirect_out (Stdout, diff.file2, Normal, run_action)

test/blackbox-tests/test-cases/jsoo/tests.t/run.t

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,3 @@ tests stanza with jsoo
22

33
$ dune build @default @runtest-js
44
a: ok
5-
File "dune", line 2, characters 11-12:
6-
2 | (names a b)
7-
^
8-
node:internal/modules/cjs/loader:1146
9-
throw err;
10-
^
11-
12-
Error: Cannot find module '$TESTCASE_ROOT/_build/default/b.bc.js'
13-
at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
14-
at Module._load (node:internal/modules/cjs/loader:984:27)
15-
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
16-
at node:internal/main/run_main_module:28:49 {
17-
code: 'MODULE_NOT_FOUND',
18-
requireStack: []
19-
}
20-
21-
Node.js v22.0.0-v8-canary20231204cf8ac0f493
22-
[1]

0 commit comments

Comments
 (0)