char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
cb11725
main
1import { assertEquals , assertMatch } from "@std/assert" ; 2import { join } from "@std/path" ; 3import { denoExecutable } from "./deno.ts" ; 4import { tempDir } from "@berry/util" ; 5 6Deno . test ({ 7name :"subprocesses use the installed Deno before and after an atomic update" , 8ignore :Deno . build . os !== "linux" , 9async fn () { 10await usingdirectoryDir = await tempDir ({ prefix :"berry-deno-test-" }); 11const directory = directoryDir . path ; 12const executable = join ( directory , "deno" ); 13const replacement = join ( directory , "replacement" ); 14await Deno . copyFile ( denoExecutable (), executable ); 15await Deno . chmod ( executable , 0o755 ); 16await Deno . writeTextFile ( replacement , "#!/bin/sh\nprintf 'updated deno\\n'\n" ); 17await Deno . chmod ( replacement , 0o755 ); 18 19const { success, stdout, stderr} = await new Deno . Command ( executable , { 20args :[ 21"eval" , 22`import { denoExecutable } from ${ 23JSON . stringify ( new URL ( "./deno.ts" , import . meta . url ). href ) 24} ; 25const before = await new Deno.Command(denoExecutable(), { args: ["--version"] }).output(); 26await Deno.rename( ${ JSON . stringify ( replacement )} , ${ JSON . stringify ( executable )} ); 27const after = await new Deno.Command(denoExecutable(), { args: ["--version"] }).output(); 28console.log(JSON.stringify({ 29before: new TextDecoder().decode(before.stdout), 30after: new TextDecoder().decode(after.stdout), 31success: before.success && after.success, 32}));` , 33], 34stdout :"piped" , 35stderr :"piped" , 36}). output (); 37assertEquals ( success , true , new TextDecoder (). decode ( stderr )); 38const result = JSON . parse ( new TextDecoder (). decode ( stdout )); 39assertEquals ( result . success , true ); 40assertMatch ( result . before , / ^deno / ); 41assertEquals ( result . after , "updated deno\n" ); 42}, 43});