@@ -2601,6 +2601,40 @@ describe("FlatESLint", () => {
26012601 assert ( ! shell . test ( "-f" , cacheFilePath ) , "the cache for eslint should have been deleted since last run did not use the cache" ) ;
26022602 } ) ;
26032603
2604+ it ( "should not throw an error if the cache file to be deleted does not exist on a read-only file system" , async ( ) => {
2605+ cacheFilePath = getFixturePath ( ".eslintcache" ) ;
2606+ doDelete ( cacheFilePath ) ;
2607+ assert ( ! shell . test ( "-f" , cacheFilePath ) , "the cache file already exists and wasn't successfully deleted" ) ;
2608+
2609+ // Simulate a read-only file system.
2610+ sinon . stub ( fsp , "unlink" ) . rejects (
2611+ Object . assign ( new Error ( "read-only file system" ) , { code : "EROFS" } )
2612+ ) ;
2613+
2614+ const eslintOptions = {
2615+ overrideConfigFile : true ,
2616+
2617+ // specifying cache false the cache will be deleted
2618+ cache : false ,
2619+ cacheLocation : cacheFilePath ,
2620+ overrideConfig : {
2621+ rules : {
2622+ "no-console" : 0 ,
2623+ "no-unused-vars" : 2
2624+ }
2625+ } ,
2626+ cwd : path . join ( fixtureDir , ".." )
2627+ } ;
2628+
2629+ eslint = new FlatESLint ( eslintOptions ) ;
2630+
2631+ const file = getFixturePath ( "cache/src" , "test-file.js" ) ;
2632+
2633+ await eslint . lintFiles ( [ file ] ) ;
2634+
2635+ assert ( fsp . unlink . calledWithExactly ( cacheFilePath ) , "Expected attempt to delete the cache was not made." ) ;
2636+ } ) ;
2637+
26042638 it ( "should store in the cache a file that has lint messages and a file that doesn't have lint messages" , async ( ) => {
26052639 cacheFilePath = getFixturePath ( ".eslintcache" ) ;
26062640 doDelete ( cacheFilePath ) ;
0 commit comments