@@ -11,6 +11,12 @@ describe("tps agent logs runtime tail", () => {
1111 let originalError : typeof console . error ;
1212 let originalExit : typeof process . exit ;
1313
14+ function writeSessionLog ( agentId : string , content : string ) : void {
15+ const logDir = join ( tempHome , ".tps" , "agents" , agentId ) ;
16+ mkdirSync ( logDir , { recursive : true } ) ;
17+ writeFileSync ( join ( logDir , "session.log" ) , content , "utf-8" ) ;
18+ }
19+
1420 beforeEach ( ( ) => {
1521 tempHome = mkdtempSync ( join ( tmpdir ( ) , "tps-agent-runtime-logs-" ) ) ;
1622 originalHome = process . env . HOME ;
@@ -35,11 +41,9 @@ describe("tps agent logs runtime tail", () => {
3541 test ( "shows the last 50 lines by default" , async ( ) => {
3642 const { runAgent } = await import ( "../src/commands/agent.js" ) ;
3743 const output : string [ ] = [ ] ;
38- mkdirSync ( join ( tempHome , ".tps" , "logs" ) , { recursive : true } ) ;
39- writeFileSync (
40- join ( tempHome , ".tps" , "logs" , "ember.log" ) ,
44+ writeSessionLog (
45+ "ember" ,
4146 Array . from ( { length : 60 } , ( _ , index ) => `line-${ index + 1 } ` ) . join ( "\n" ) + "\n" ,
42- "utf-8" ,
4347 ) ;
4448 process . stdout . write = ( ( chunk : string | Uint8Array ) => {
4549 output . push ( typeof chunk === "string" ? chunk : Buffer . from ( chunk ) . toString ( "utf-8" ) ) ;
@@ -56,11 +60,9 @@ describe("tps agent logs runtime tail", () => {
5660 test ( "respects a custom line count" , async ( ) => {
5761 const { runAgent } = await import ( "../src/commands/agent.js" ) ;
5862 const output : string [ ] = [ ] ;
59- mkdirSync ( join ( tempHome , ".tps" , "logs" ) , { recursive : true } ) ;
60- writeFileSync (
61- join ( tempHome , ".tps" , "logs" , "ember.log" ) ,
63+ writeSessionLog (
64+ "ember" ,
6265 [ "alpha" , "beta" , "gamma" , "delta" ] . join ( "\n" ) ,
63- "utf-8" ,
6466 ) ;
6567 process . stdout . write = ( ( chunk : string | Uint8Array ) => {
6668 output . push ( typeof chunk === "string" ? chunk : Buffer . from ( chunk ) . toString ( "utf-8" ) ) ;
0 commit comments