From b8b0932cb84c37d1929bd6be5320081452703060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Wed, 26 Jun 2024 13:58:27 +0200 Subject: [PATCH] Fix expect test dependencies When there is a custom runner, the rule that executes the test should have a dependency on the executable. --- src/dune_rules/test_rules.ml | 17 +++++++++-------- .../test-cases/jsoo/tests.t/run.t | 18 ------------------ 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/dune_rules/test_rules.ml b/src/dune_rules/test_rules.ml index e27d34c934da..d63ea454be43 100644 --- a/src/dune_rules/test_rules.ml +++ b/src/dune_rules/test_rules.ml @@ -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 @@ -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) diff --git a/test/blackbox-tests/test-cases/jsoo/tests.t/run.t b/test/blackbox-tests/test-cases/jsoo/tests.t/run.t index 74fa4288a01d..1debd3da900e 100644 --- a/test/blackbox-tests/test-cases/jsoo/tests.t/run.t +++ b/test/blackbox-tests/test-cases/jsoo/tests.t/run.t @@ -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]