Skip to content

Commit

Permalink
Fix expect test dependencies
Browse files Browse the repository at this point in the history
When there is a custom runner, the rule that executes the test should
have a dependency on the executable.
  • Loading branch information
vouillon committed Jun 26, 2024
1 parent 18f2b8a commit b8b0932
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
17 changes: 9 additions & 8 deletions src/dune_rules/test_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
| `js -> Jsoo_rules.js_of_ocaml_runtest_alias ~dir
| `exe | `bc -> Memo.return Alias0.runtest
in
let deps =
match custom_runner with
| Some _ ->
Bindings.Unnamed (Dep_conf.File (String_with_vars.make_text loc test_exe))
:: t.deps
| None -> t.deps
in
let add_alias ~loc ~action ~locks =
(* CR-rgrinberg: why are we going through the stanza api? *)
let alias =
{ Alias_conf.name = runtest_alias
; locks
; package = t.package
; deps =
(match custom_runner with
| Some _ ->
Bindings.Unnamed
(Dep_conf.File (String_with_vars.make_text loc test_exe))
:: t.deps
| None -> t.deps)
; deps
; action = Some (loc, action)
; enabled_if = t.enabled_if
; loc
Expand All @@ -95,7 +96,7 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
| `Expect diff ->
let rule =
{ Rule_conf.targets = Infer
; deps = t.deps
; deps
; action =
( loc
, Action_unexpanded.Redirect_out (Stdout, diff.file2, Normal, run_action)
Expand Down
18 changes: 0 additions & 18 deletions test/blackbox-tests/test-cases/jsoo/tests.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,3 @@ tests stanza with jsoo

$ dune build @default @runtest-js
a: ok
File "dune", line 2, characters 11-12:
2 | (names a b)
^
node:internal/modules/cjs/loader:1146
throw err;
^

Error: Cannot find module '$TESTCASE_ROOT/_build/default/b.bc.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v22.0.0-v8-canary20231204cf8ac0f493
[1]

0 comments on commit b8b0932

Please sign in to comment.