@@ -249,6 +249,38 @@ assert.equal(saveCap.stats.cacheSaveSkippedBySize, true);
249249assert . equal ( saveCap . stats . cacheEntriesSaved , 0 ) ;
250250assert . equal ( saveCap . totals . totalTokens , 7000 ) ;
251251
252+ const blockedCacheHome = path . join ( root , 'blocked-cache-codex-home' ) ;
253+ const blockedCacheSessions = path . join ( blockedCacheHome , 'sessions/2026/05/16' ) ;
254+ await mkdir ( blockedCacheSessions , { recursive : true } ) ;
255+ await writeFile (
256+ path . join ( blockedCacheSessions , 'blocked-cache.jsonl' ) ,
257+ [
258+ JSON . stringify ( { timestamp : '2026-05-16T00:00:00.000Z' , type : 'turn_context' , payload : { model : 'gpt-test' } } ) ,
259+ JSON . stringify ( {
260+ timestamp : '2026-05-16T00:00:01.000Z' ,
261+ type : 'event_msg' ,
262+ payload : {
263+ type : 'token_count' ,
264+ info : { last_token_usage : { input_tokens : 3 , cached_input_tokens : 1 , output_tokens : 2 , total_tokens : 5 } } ,
265+ } ,
266+ } ) ,
267+ '' ,
268+ ] . join ( '\n' ) ,
269+ ) ;
270+ const cachePathBlocker = path . join ( root , 'cache-path-blocker' ) ;
271+ await writeFile ( cachePathBlocker , 'not a directory' ) ;
272+ const blockedCacheReport = await collectUsage ( {
273+ codexHome : blockedCacheHome ,
274+ cacheFile : path . join ( cachePathBlocker , 'index.json' ) ,
275+ timezone : 'UTC' ,
276+ includePricing : false ,
277+ } ) ;
278+ assert . equal ( blockedCacheReport . totals . totalTokens , 5 ) ;
279+ assert . equal ( blockedCacheReport . stats . cacheSaveSkippedByError , true ) ;
280+ assert . match ( blockedCacheReport . stats . cacheSaveError , / E E X I S T | E N O T D I R | n o t a d i r e c t o r y / i) ;
281+ assert . equal ( blockedCacheReport . stats . cacheEntriesSaved , 0 ) ;
282+ assert . equal ( blockedCacheReport . stats . cacheFile , null ) ;
283+
252284assert . throws ( ( ) => normalizeDate ( '2026-02-30' ) , / I n v a l i d d a t e / ) ;
253285assert . throws ( ( ) => normalizeDate ( '2026-99-99' ) , / I n v a l i d d a t e / ) ;
254286
0 commit comments