@@ -15,7 +15,7 @@ import { tmpdir } from 'node:os'
1515import { join , resolve } from 'node:path'
1616import { afterEach , describe , expect , it } from 'vitest'
1717
18- const script = resolve ( import . meta. dirname , 'prune-turbopack-cache.ts ' )
18+ const script = resolve ( import . meta. dirname , 'prune-turbopack-cache.mts ' )
1919const fixtures : string [ ] = [ ]
2020
2121function fixture ( ) {
@@ -33,7 +33,7 @@ function fixture() {
3333}
3434
3535function run ( root : string , args : string [ ] , maximum = '0.000001' ) {
36- return spawnSync ( 'bun ' , [ script , ...args ] , {
36+ return spawnSync ( 'node ' , [ script , ...args ] , {
3737 cwd : root ,
3838 encoding : 'utf8' ,
3939 timeout : 10_000 ,
@@ -46,17 +46,24 @@ afterEach(() => {
4646} )
4747
4848describe ( 'compiler cache maintenance through the real CLI' , ( ) => {
49- it . each ( [ 'size' , 'force' ] ) ( 'clears only build contents by %s while preserving its mount' , ( mode ) => {
50- const { root, build, dev, outside } = fixture ( )
51- const inode = statSync ( build ) . ino
52- const result = run ( root , mode === 'force' ? [ '--build' , '--force' ] : [ '--build' ] , mode === 'force' ? '1' : undefined )
53- expect ( result . status , result . stderr ) . toBe ( 0 )
54- expect ( existsSync ( build ) ) . toBe ( true )
55- expect ( statSync ( build ) . ino ) . toBe ( inode )
56- expect ( readdirSync ( build ) ) . toEqual ( [ ] )
57- expect ( existsSync ( join ( dev , 'state' ) ) ) . toBe ( true )
58- expect ( existsSync ( join ( outside , 'state' ) ) ) . toBe ( true )
59- } )
49+ it . each ( [ 'size' , 'force' ] ) (
50+ 'clears only build contents by %s while preserving its mount' ,
51+ ( mode ) => {
52+ const { root, build, dev, outside } = fixture ( )
53+ const inode = statSync ( build ) . ino
54+ const result = run (
55+ root ,
56+ mode === 'force' ? [ '--build' , '--force' ] : [ '--build' ] ,
57+ mode === 'force' ? '1' : undefined
58+ )
59+ expect ( result . status , result . stderr ) . toBe ( 0 )
60+ expect ( existsSync ( build ) ) . toBe ( true )
61+ expect ( statSync ( build ) . ino ) . toBe ( inode )
62+ expect ( readdirSync ( build ) ) . toEqual ( [ ] )
63+ expect ( existsSync ( join ( dev , 'state' ) ) ) . toBe ( true )
64+ expect ( existsSync ( join ( outside , 'state' ) ) ) . toBe ( true )
65+ }
66+ )
6067
6168 it ( 'retains useful build state without counting external symlink targets' , ( ) => {
6269 const { root, build, dev, outside } = fixture ( )
@@ -104,15 +111,18 @@ describe('compiler cache maintenance through the real CLI', () => {
104111 expect ( existsSync ( join ( dev , 'state' ) ) ) . toBe ( true )
105112 } )
106113
107- it . each ( [ true , false ] ) ( 'refuses a symlink build root when target existence is %s' , ( targetExists ) => {
108- const { root, build, dev, outside } = fixture ( )
109- rmSync ( build , { recursive : true } )
110- symlinkSync ( outside , build , process . platform === 'win32' ? 'junction' : 'dir' )
111- if ( ! targetExists ) rmSync ( outside , { recursive : true } )
112- const result = run ( root , [ '--build' , '--force' ] )
113- expect ( result . status , result . stderr ) . not . toBe ( 0 )
114- expect ( lstatSync ( build ) . isSymbolicLink ( ) ) . toBe ( true )
115- expect ( existsSync ( join ( outside , 'state' ) ) ) . toBe ( targetExists )
116- expect ( existsSync ( join ( dev , 'state' ) ) ) . toBe ( true )
117- } )
114+ it . each ( [ true , false ] ) (
115+ 'refuses a symlink build root when target existence is %s' ,
116+ ( targetExists ) => {
117+ const { root, build, dev, outside } = fixture ( )
118+ rmSync ( build , { recursive : true } )
119+ symlinkSync ( outside , build , process . platform === 'win32' ? 'junction' : 'dir' )
120+ if ( ! targetExists ) rmSync ( outside , { recursive : true } )
121+ const result = run ( root , [ '--build' , '--force' ] )
122+ expect ( result . status , result . stderr ) . not . toBe ( 0 )
123+ expect ( lstatSync ( build ) . isSymbolicLink ( ) ) . toBe ( true )
124+ expect ( existsSync ( join ( outside , 'state' ) ) ) . toBe ( targetExists )
125+ expect ( existsSync ( join ( dev , 'state' ) ) ) . toBe ( true )
126+ }
127+ )
118128} )
0 commit comments