@@ -50,15 +50,12 @@ func TestE2ESingleURLSuccess(t *testing.T) {
5050 t .Fatalf ("Run() error = %v; stderr=%s" , err , stderr .String ())
5151 }
5252
53- matches , err := filepath .Glob (filepath .Join (tmpDir , "out" , "*.md" ))
54- if err != nil {
55- t .Fatalf ("glob output file: %v" , err )
56- }
57- if len (matches ) != 1 {
58- t .Fatalf ("output files len=%d, want 1" , len (matches ))
53+ paths := outputPathsFromStdout (stdout .String ())
54+ if len (paths ) == 0 {
55+ t .Fatalf ("stdout missing output path: %s" , stdout .String ())
5956 }
6057
61- content , err := os .ReadFile (matches [0 ])
58+ content , err := os .ReadFile (paths [0 ])
6259 if err != nil {
6360 t .Fatalf ("read output: %v" , err )
6461 }
@@ -111,7 +108,7 @@ func TestE2EMultiURLPartialFailure(t *testing.T) {
111108 t .Fatalf ("Run() error = nil, want partial-failure error" )
112109 }
113110
114- summaryPath := filepath . Join ( tmpDir , "out" , "_summary.json" )
111+ summaryPath := summaryPathFromStdout ( t , stdout . String () )
115112 summaryData , readErr := os .ReadFile (summaryPath )
116113 if readErr != nil {
117114 t .Fatalf ("read summary: %v" , readErr )
@@ -295,3 +292,39 @@ func sampleLongArticle(title string) string {
295292 b .WriteString ("</article></body></html>" )
296293 return b .String ()
297294}
295+
296+ func summaryPathFromStdout (t * testing.T , stdout string ) string {
297+ t .Helper ()
298+
299+ for _ , line := range strings .Split (stdout , "\n " ) {
300+ trimmed := strings .TrimSpace (line )
301+ if strings .HasPrefix (trimmed , "Summary: " ) {
302+ path := strings .TrimSpace (strings .TrimPrefix (trimmed , "Summary: " ))
303+ if path != "" {
304+ return path
305+ }
306+ }
307+ }
308+ t .Fatalf ("stdout missing summary path: %s" , stdout )
309+ return ""
310+ }
311+
312+ func outputPathsFromStdout (stdout string ) []string {
313+ paths := make ([]string , 0 , 2 )
314+ for _ , line := range strings .Split (stdout , "\n " ) {
315+ trimmed := strings .TrimSpace (line )
316+ if idx := strings .Index (trimmed , "Output: " ); idx >= 0 {
317+ path := strings .TrimSpace (trimmed [idx + len ("Output: " ):])
318+ if path != "" {
319+ paths = append (paths , path )
320+ }
321+ }
322+ if idx := strings .Index (trimmed , "Output (HTML): " ); idx >= 0 {
323+ path := strings .TrimSpace (trimmed [idx + len ("Output (HTML): " ):])
324+ if path != "" {
325+ paths = append (paths , path )
326+ }
327+ }
328+ }
329+ return paths
330+ }
0 commit comments