@@ -402,7 +402,7 @@ func getProcesses(t *gotesting.T, regex string) []runningProcess {
402
402
// - an error if any.
403
403
func (f * Fixture ) installDeb (ctx context.Context , installOpts * InstallOpts , opts []process.CmdOption ) ([]byte , error ) {
404
404
f .t .Logf ("[test %s] Inside fixture installDeb function" , f .t .Name ())
405
- //Prepare so that the f.srcPackage string is populated
405
+ // Prepare so that the f.srcPackage string is populated
406
406
err := f .EnsurePrepared (ctx )
407
407
if err != nil {
408
408
return nil , fmt .Errorf ("failed to prepare: %w" , err )
@@ -483,7 +483,7 @@ func (f *Fixture) installDeb(ctx context.Context, installOpts *InstallOpts, opts
483
483
// - an error if any.
484
484
func (f * Fixture ) installRpm (ctx context.Context , installOpts * InstallOpts , opts []process.CmdOption ) ([]byte , error ) {
485
485
f .t .Logf ("[test %s] Inside fixture installRpm function" , f .t .Name ())
486
- //Prepare so that the f.srcPackage string is populated
486
+ // Prepare so that the f.srcPackage string is populated
487
487
err := f .EnsurePrepared (ctx )
488
488
if err != nil {
489
489
return nil , fmt .Errorf ("failed to prepare: %w" , err )
@@ -649,12 +649,12 @@ func (f *Fixture) collectDiagnostics() {
649
649
ctx , cancel := context .WithTimeout (context .Background (), 1 * time .Minute )
650
650
defer cancel ()
651
651
652
- dir , err := findProjectRoot ( f . caller )
652
+ diagPath , err := f . DiagDir ( )
653
653
if err != nil {
654
- f .t .Logf ("failed to collect diagnostics; failed to find project root : %s " , err )
654
+ f .t .Logf ("failed to collect diagnostics: %v " , err )
655
655
return
656
656
}
657
- diagPath := filepath . Join ( dir , "build" , "diagnostics" )
657
+
658
658
err = os .MkdirAll (diagPath , 0755 )
659
659
if err != nil {
660
660
f .t .Logf ("failed to collect diagnostics; failed to create %s: %s" , diagPath , err )
@@ -699,6 +699,18 @@ func (f *Fixture) collectDiagnostics() {
699
699
}
700
700
}
701
701
702
+ // DiagDir returned {projectRoot}/build/diagnostics path. Files on this path
703
+ // are saved if any test fails. Use it to save files for further investigation.
704
+ func (f * Fixture ) DiagDir () (string , error ) {
705
+ dir , err := findProjectRoot (f .caller )
706
+ if err != nil {
707
+ return "" , fmt .Errorf ("failed to find project root: %w" , err )
708
+ }
709
+
710
+ diagPath := filepath .Join (dir , "build" , "diagnostics" )
711
+ return diagPath , nil
712
+ }
713
+
702
714
func (f * Fixture ) archiveInstallDirectory (installPath string , outputPath string ) error {
703
715
file , err := os .Create (outputPath )
704
716
if err != nil {
0 commit comments