@@ -14,32 +14,34 @@ import test from 'node:test';
1414const version = '1.0.79' ;
1515const integrity = 'sha512-test-integrity' ;
1616const runtimeContent = 'runtime content' ;
17- const cliContent = 'cli content' ;
1817const wrapperContent = 'wrapper content' ;
18+ const stagingSchema = 'hostless-runtime-v2' ;
1919const scriptPath = fileURLToPath ( new URL ( './fetch-native.mjs' , import . meta. url ) ) ;
2020
2121for ( const classifier of [ 'linux-x64' , 'win32-x64' , 'darwin-arm64' ] ) {
22- test ( `${ classifier } : missing CLI does not use incremental fast path` , ( t ) => {
22+ test ( `${ classifier } : complete hostless artifacts use incremental fast path without a CLI ` , ( t ) => {
2323 const fixture = createFixture ( t , classifier ) ;
24- fs . rmSync ( fixture . cliPath ) ;
2524
2625 const result = runScript ( fixture ) ;
2726
28- assertRestagingAttempted ( fixture , result ) ;
27+ assert . equal ( result . status , 0 , result . stderr ) ;
28+ assert . match ( result . stdout , / a l r e a d y s t a g e d / ) ;
29+ assert . equal ( fs . existsSync ( fixture . npmMarkerPath ) , false ) ;
2930 } ) ;
3031
31- test ( `${ classifier } : stale CLI does not use incremental fast path` , ( t ) => {
32+ test ( `${ classifier } : missing runtime wrapper does not use incremental fast path` , ( t ) => {
3233 const fixture = createFixture ( t , classifier ) ;
33- fs . writeFileSync ( fixture . cliPath , 'stale CLI content' ) ;
34+ fs . rmSync ( fixture . wrapperPath ) ;
3435
3536 const result = runScript ( fixture ) ;
3637
3738 assertRestagingAttempted ( fixture , result ) ;
3839 } ) ;
3940
40- test ( `${ classifier } : missing runtime wrapper does not use incremental fast path` , ( t ) => {
41+ test ( `${ classifier } : legacy staging schema does not use incremental fast path` , ( t ) => {
4142 const fixture = createFixture ( t , classifier ) ;
42- fs . rmSync ( fixture . wrapperPath ) ;
43+ const stampPath = path . join ( fixture . stagingDir , classifier , '.version' ) ;
44+ fs . writeFileSync ( stampPath , fs . readFileSync ( stampPath , 'utf8' ) . replace ( stagingSchema , 'hostless-runtime-v1' ) ) ;
4345
4446 const result = runScript ( fixture ) ;
4547
@@ -82,7 +84,7 @@ test('stages retained package assets and excludes CLI-only content', (t) => {
8284 fs . mkdirSync ( path . join ( packageRoot , 'prebuilds' , classifier ) , { recursive : true } ) ;
8385 fs . mkdirSync ( path . join ( packageRoot , 'ripgrep' , 'bin' , classifier ) , { recursive : true } ) ;
8486 fs . mkdirSync ( path . join ( packageRoot , 'definitions' ) , { recursive : true } ) ;
85- fs . writeFileSync ( path . join ( packageRoot , 'copilot' ) , cliContent ) ;
87+ fs . writeFileSync ( path . join ( packageRoot , 'copilot' ) , 'excluded' ) ;
8688 fs . writeFileSync ( path . join ( packageRoot , 'prebuilds' , classifier , 'runtime.node' ) , runtimeContent ) ;
8789 fs . writeFileSync ( path . join ( packageRoot , 'prebuilds' , classifier , 'copilot-runtime' ) , wrapperContent ) ;
8890 fs . writeFileSync ( path . join ( packageRoot , 'ripgrep' , 'bin' , classifier , 'rg' ) , 'ripgrep content' ) ;
@@ -116,6 +118,7 @@ test('stages retained package assets and excludes CLI-only content', (t) => {
116118 assert . equal ( fs . readFileSync ( path . join ( resourceDir , 'ripgrep' , 'bin' , classifier , 'rg' ) , 'utf8' ) , 'ripgrep content' ) ;
117119 assert . equal ( fs . readFileSync ( path . join ( resourceDir , 'definitions' , 'future.json' ) , 'utf8' ) , '{}' ) ;
118120 assert . equal ( fs . existsSync ( path . join ( resourceDir , 'app.js' ) ) , false ) ;
121+ assert . equal ( fs . existsSync ( path . join ( resourceDir , 'copilot' ) ) , false ) ;
119122 assert . equal ( fs . existsSync ( path . join ( resourceDir , 'LICENSE.md' ) ) , false ) ;
120123 assert . equal ( fs . existsSync ( path . join ( resourceDir , 'README.md' ) ) , false ) ;
121124 assert . match ( fs . readFileSync ( path . join ( resourceDir , 'runtime-assets.list' ) , 'utf8' ) , / r i p g r e p \/ b i n \/ l i n u x - x 6 4 \/ r g / ) ;
@@ -144,7 +147,6 @@ function createFixture(t, classifier) {
144147 ) ;
145148
146149 const runtimePath = path . join ( resourceDir , 'runtime.node' ) ;
147- const cliPath = path . join ( resourceDir , classifier . startsWith ( 'win32' ) ? 'copilot.exe' : 'copilot' ) ;
148150 const wrapperPath = path . join (
149151 resourceDir ,
150152 classifier . startsWith ( 'win32' ) ? 'copilot-runtime.exe' : 'copilot-runtime' ,
@@ -154,17 +156,16 @@ function createFixture(t, classifier) {
154156 const inventoryPath = path . join ( resourceDir , 'runtime-assets.list' ) ;
155157 fs . mkdirSync ( path . dirname ( ripgrepPath ) , { recursive : true } ) ;
156158 fs . writeFileSync ( runtimePath , runtimeContent ) ;
157- fs . writeFileSync ( cliPath , cliContent ) ;
158159 fs . writeFileSync ( wrapperPath , wrapperContent ) ;
159160 fs . writeFileSync ( ripgrepPath , 'ripgrep content' ) ;
160161 fs . writeFileSync (
161162 inventoryPath ,
162- `644\truntime.node\n755\tcopilot\n755\tcopilot -runtime\n755\tripgrep/bin/${ classifier } /rg\n` ,
163+ `644\truntime.node\n755\tcopilot-runtime\n755\tripgrep/bin/${ classifier } /rg\n` ,
163164 ) ;
164165 fs . writeFileSync ( platformPropertiesPath , `classifier=${ classifier } \nversion=${ version } \n` ) ;
165166 fs . writeFileSync (
166167 path . join ( stagingDir , classifier , '.version' ) ,
167- `${ version } \n${ integrity } \n${ digestTree ( resourceDir ) } \n` ,
168+ `${ stagingSchema } \n ${ version } \n${ integrity } \n${ digestTree ( resourceDir ) } \n` ,
168169 ) ;
169170
170171 const fakeNpmPath = path . join ( fakeBinDir , process . platform === 'win32' ? 'npm.cmd' : 'npm' ) ;
@@ -182,7 +183,6 @@ function createFixture(t, classifier) {
182183 fakeBinDir,
183184 npmMarkerPath,
184185 runtimePath,
185- cliPath,
186186 wrapperPath,
187187 ripgrepPath,
188188 platformPropertiesPath,
0 commit comments