Skip to content

Commit 46f5003

Browse files
fix(test/codegen-node): correct false-positive in vscode-off-by-default e2e (Refs #116, #117) (#127)
The 2 long-standing red `dune runtest` cases (E2E Node-CJS Codegen 2 & 4, "no adapter require without the flag") were a **false positive**, not a real codegen defect: `emit_node_cjs` already emits the `--vscode-extension` wiring *only* when the flag is set. The failure was the assertion doing a bare-substring `contains cjs "@hyperpolymath/affine-vscode"` — which matched an *explanatory comment* in the default `_buildImports`, not any adapter `require`/wiring. Fix (both, defence-in-depth, behaviour unchanged): - Tighten the assertion to the actual wiring token `require("@hyperpolymath/affine-vscode")` so it tests intent ("no adapter *require* without the flag") and won't false-trip on docs. - Reword the default `_buildImports` comment so generated standalone shims no longer embed the resolvable adapter specifier (a grep/audit for the adapter shouldn't flag every standalone .cjs either). Result: `dune runtest` is now 214 tests / 0 failures (was 2 pre-existing failures present since before #123). Deno-ESM harness suite unaffected. Pre-existing since the #116/#117 --vscode-extension flag work; unrelated to the #122 Deno-ESM track but was the only red on affinescript main. Refs #116, #117. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent fdc7ba3 commit 46f5003

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/codegen_node.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ function _buildImports() {
228228
return 0;
229229
},
230230
};
231-
// Phase 2 hook: callers can replace exports.extraImports with a function
232-
// returning a `{ ModuleName: { exportName: fn, ... } }` map of concrete
233-
// host bindings (e.g. the @hyperpolymath/affine-vscode adapter). Default
234-
// is empty so the shim works standalone.
231+
// Phase 2 hook: a caller may install an `extraImports` factory on the
232+
// exports object returning a `{ ModuleName: { exportName: fn, ... } }`
233+
// map of concrete host bindings (this is what the --vscode-extension
234+
// wiring installs). Default is empty so the shim works standalone.
235235
const extras = (typeof exports.extraImports === "function")
236236
? exports.extraImports()
237237
: %s;

test/test_e2e.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2851,8 +2851,11 @@ let test_vscode_extension_off_by_default () =
28512851
let cjs = cjs_of activate_src in
28522852
Alcotest.(check bool) "no extraImports assignment without the flag"
28532853
false (contains cjs "exports.extraImports = function");
2854+
(* Assert the absence of the actual adapter *wiring* (the require
2855+
call), not the bare specifier string — the latter legitimately
2856+
appears in an explanatory comment and is not adapter wiring. *)
28542857
Alcotest.(check bool) "no adapter require without the flag"
2855-
false (contains cjs "@hyperpolymath/affine-vscode")
2858+
false (contains cjs {|require("@hyperpolymath/affine-vscode")|})
28562859

28572860
let test_vscode_extension_inlines_wiring () =
28582861
let cjs = cjs_of ~vscode_extension:true activate_src in

0 commit comments

Comments
 (0)