@@ -1367,69 +1367,83 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
13671367 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
13681368) ;
13691369
1370- it . effect ( "GitVcsDriver flushes checkpoint objects and refs to disk before publishing them" , ( ) => {
1371- const observedArgs : ReadonlyArray < string > [ ] = [ ] ;
1372-
1373- return Effect . gen ( function * ( ) {
1374- const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) ;
1370+ it . effect . each ( [
1371+ { platform : "linux" , fsyncMethods : [ "fsync" ] } ,
1372+ { platform : "darwin" , fsyncMethods : [ "fsync" , "batch" ] } ,
1373+ { platform : "win32" , fsyncMethods : [ "fsync" , "batch" ] } ,
1374+ ] as const ) (
1375+ "GitVcsDriver flushes checkpoint objects and refs to disk before publishing them on $platform" ,
1376+ ( { platform, fsyncMethods } ) => {
1377+ const observedArgs : ReadonlyArray < string > [ ] = [ ] ;
1378+
1379+ return Effect . gen ( function * ( ) {
1380+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) ;
13751381
1376- yield * driver . checkpoints . captureCheckpoint ( {
1377- cwd : "/repo" ,
1378- checkpointRef : CheckpointRef . make ( "refs/t3/checkpoints/thread/turn/1" ) ,
1379- } ) ;
1382+ yield * driver . checkpoints . captureCheckpoint ( {
1383+ cwd : "/repo" ,
1384+ checkpointRef : CheckpointRef . make ( "refs/t3/checkpoints/thread/turn/1" ) ,
1385+ } ) ;
13801386
1381- const writeCommands = [ "add" , "write-tree" , "commit-tree" , "update-ref" ] ;
1382- const writes = observedArgs . filter ( ( args ) =>
1383- writeCommands . some ( ( command ) => args . includes ( command ) ) ,
1384- ) ;
1385- assert . strictEqual ( writes . length , 4 ) ;
1386- for ( const args of writes ) {
1387- const command = args . findIndex ( ( arg ) => writeCommands . includes ( arg ) ) ;
1388- for ( const setting of [ "core.fsync=objects,reference" , "core.fsyncMethod=fsync" ] ) {
1389- const index = args . indexOf ( setting ) ;
1390- assert . strictEqual ( args [ index - 1 ] , "-c" , args . join ( " " ) ) ;
1391- assert . isBelow ( index , command ) ;
1387+ const writeCommands = [ "add" , "write-tree" , "commit-tree" , "update-ref" ] ;
1388+ const writes = observedArgs . filter ( ( args ) =>
1389+ writeCommands . some ( ( command ) => args . includes ( command ) ) ,
1390+ ) ;
1391+ assert . strictEqual ( writes . length , 4 ) ;
1392+ for ( const args of writes ) {
1393+ const command = args . findIndex ( ( arg ) => writeCommands . includes ( arg ) ) ;
1394+ assert . deepStrictEqual (
1395+ args . filter ( ( arg ) => arg . startsWith ( "core.fsyncMethod=" ) ) ,
1396+ fsyncMethods . map ( ( method ) => `core.fsyncMethod=${ method } ` ) ,
1397+ ) ;
1398+ for ( const setting of [
1399+ "core.fsync=objects,reference" ,
1400+ ...fsyncMethods . map ( ( method ) => `core.fsyncMethod=${ method } ` ) ,
1401+ ] ) {
1402+ const index = args . indexOf ( setting ) ;
1403+ assert . strictEqual ( args [ index - 1 ] , "-c" , args . join ( " " ) ) ;
1404+ assert . isBelow ( index , command ) ;
1405+ }
13921406 }
1393- }
1394- assert . deepStrictEqual ( observedArgs . at ( - 1 ) , [
1395- "-C ",
1396- "/repo ",
1397- "-c ",
1398- " core.fsync=objects,reference" ,
1399- "-c ",
1400- "core.fsyncMethod=fsync ",
1401- "update-ref ",
1402- "refs/t3/checkpoints/thread/turn/1" ,
1403- "commit0000" ,
1404- ] ) ;
1405- } ) . pipe (
1406- Effect . provide (
1407- Layer . mergeAll (
1408- NodeServices . layer ,
1409- Layer . mock ( VcsProcess . VcsProcess ) ( {
1410- run : ( input ) =>
1411- Effect . sync ( ( ) => {
1412- observedArgs . push ( input . args ) ;
1413- const stdout = input . args . includes ( "write-tree" )
1414- ? "tree0000\n"
1415- : input . args . includes ( "commit-tree" )
1416- ? "commit0000\n"
1417- : input . args . includes ( "-- git-common-dir" )
1418- ? ".git\n"
1419- : "" ;
1420- return {
1421- exitCode : ChildProcessSpawner . ExitCode ( 0 ) ,
1422- stdout ,
1423- stderr : "" ,
1424- stdoutTruncated : false ,
1425- stderrTruncated : false ,
1426- } ;
1427- } ) ,
1428- } ) ,
1407+ assert . deepStrictEqual ( observedArgs . at ( - 1 ) , [
1408+ "-C" ,
1409+ "/repo ",
1410+ "-c ",
1411+ "core.fsync=objects,reference ",
1412+ ... fsyncMethods . flatMap ( ( method ) => [ "-c" , ` core.fsyncMethod= ${ method } ` ] ) ,
1413+ "update-ref ",
1414+ "refs/t3/checkpoints/thread/turn/1 ",
1415+ "commit0000 ",
1416+ ] ) ;
1417+ } ) . pipe (
1418+ Effect . provideService ( HostProcess . Platform , platform ) ,
1419+ Effect . provide (
1420+ Layer . mergeAll (
1421+ NodeServices . layer ,
1422+ Layer . mock ( VcsProcess . VcsProcess ) ( {
1423+ run : ( input ) =>
1424+ Effect . sync ( ( ) => {
1425+ observedArgs . push ( input . args ) ;
1426+ const stdout = input . args . includes ( "write-tree" )
1427+ ? "tree0000\n"
1428+ : input . args . includes ( "commit-tree" )
1429+ ? "commit0000\n"
1430+ : input . args . includes ( "--git-common-dir" )
1431+ ? ". git\n"
1432+ : "" ;
1433+ return {
1434+ exitCode : ChildProcessSpawner . ExitCode ( 0 ) ,
1435+ stdout ,
1436+ stderr : "" ,
1437+ stdoutTruncated : false ,
1438+ stderrTruncated : false ,
1439+ } ;
1440+ } ) ,
1441+ } ) ,
1442+ ) ,
14291443 ) ,
1430- ) ,
1431- ) ;
1432- } ) ;
1444+ ) ;
1445+ } ,
1446+ ) ;
14331447
14341448it . effect . each ( [ "win32" , "linux" ] as const ) (
14351449 "checkpoint working-tree commands enable Git long paths only on Windows (%s)" ,
0 commit comments