@@ -23,6 +23,8 @@ import { Execution } from "@executablemd/core/api";
2323import type { Plugin , PluginInstallation } from "@executablemd/core/api" ;
2424import { cwd } from "@executablemd/runtime" ;
2525import { cliBase } from "@executablemd/test-support/launch" ;
26+ import { runCli , runShell , shellQuote } from "@executablemd/test-support/launch" ;
27+ import { writeTextFile } from "@effectionx/fs" ;
2628import { useTempDirectory } from "@executablemd/test-support/temp" ;
2729import type { HelperAssembly } from "@executablemd/git/credential-helper" ;
2830import { planComponentDeclaration } from "../src/plan-component.ts" ;
@@ -48,6 +50,50 @@ import { denoRunRepositories } from "../src/deno-repositories.ts";
4850 * configured.
4951 */
5052describe ( "C1 — the native host a run child initializes" , ( ) => {
53+ it ( "L4: source entrypoints install the loader and carry it into detached run children" , function * ( ) {
54+ const project = yield * useTempDirectory ( "xmd-module-host-" ) ;
55+ const repository = fileURLToPath ( new URL ( "../../../" , import . meta. url ) ) ;
56+ yield * writeTextFile (
57+ join ( project , "helper.ts" ) ,
58+ 'export const value: string = "host-typed-component";' ,
59+ ) ;
60+ yield * writeTextFile (
61+ join ( project , "Typed.ts" ) ,
62+ 'import { value } from "./helper.ts";\nexport default function*() { const typed: string = value; return typed; }' ,
63+ ) ;
64+ yield * writeTextFile (
65+ join ( project , "README.test.md" ) ,
66+ [
67+ '<Test name="host module selection">' ,
68+ '<Typed as="direct" />' ,
69+ '<AssertEquals actual={direct} expected="host-typed-component" />' ,
70+ '<Execution host="run" source={"<Typed />"} as="child">' ,
71+ '<CollectOutput as="output" />' ,
72+ '<AssertStringIncludes actual={output} expected="host-typed-component" />' ,
73+ "</Execution>" ,
74+ "</Test>" ,
75+ ] . join ( "\n" ) ,
76+ ) ;
77+ const args = [ "test" , "README.test.md" , "--include" , project ] ;
78+ console . log ( JSON . stringify ( { argv : [ ...cliBase ( ) , ...args ] , cwd : project } ) ) ;
79+ const deno = yield * runCli ( args , { cwd : project } ) . join ( ) ;
80+ expect ( { code : deno . code , stderr : deno . stderr } ) . toEqual ( { code : 0 , stderr : "" } ) ;
81+ for ( const argv of [
82+ [
83+ "tsx" ,
84+ "--tsconfig" ,
85+ join ( repository , "tsconfig.node.json" ) ,
86+ join ( repository , "packages/cli/src/node.ts" ) ,
87+ ...args ,
88+ ] ,
89+ [ "bun" , join ( repository , "packages/cli/src/bun.ts" ) , ...args ] ,
90+ ] ) {
91+ console . log ( JSON . stringify ( { argv, cwd : project } ) ) ;
92+ const result = yield * runShell ( argv . map ( shellQuote ) . join ( " " ) , { cwd : project } ) . join ( ) ;
93+ expect ( { argv, code : result . code , stderr : result . stderr } ) . toMatchObject ( { argv, code : 0 } ) ;
94+ }
95+ } ) ;
96+
5197 /** A bare remote a child may clone without reaching a network. */
5298 function * useBareRemote ( home : string ) : Operation < string > {
5399 const parent = yield * until ( realpath ( yield * useTempDirectory ( "xmd-c1-remote-" ) ) ) ;
0 commit comments