@@ -9,36 +9,41 @@ import (
99// MapTestResultsToPaths maps test results to their corresponding file paths.
1010func MapTestResultsToPaths (report * TestReport , rootDir string ) error {
1111 // Scan the codebase for test functions
12+ rootDir , err := filepath .Abs (rootDir )
13+ if err != nil {
14+ return fmt .Errorf ("error normalizing rootDir: %v" , err )
15+ }
16+
1217 testFileMap , err := ScanTestFiles (rootDir )
1318 if err != nil {
1419 return err
1520 }
1621
22+ fmt .Printf ("Root Directory: %s\n " , rootDir )
23+ fmt .Printf ("Test File Map: %+v\n " , testFileMap )
24+
1725 // Assign file paths to each test result
1826 for i , result := range report .Results {
1927 testName := result .TestName
2028 var filePath string
2129
22- // Handle subtests
2330 if strings .Contains (testName , "/" ) {
24- parentTestName := strings .SplitN (testName , "/" , 2 )[0 ] // Extract parent test
31+ parentTestName := strings .SplitN (testName , "/" , 2 )[0 ]
2532 if path , exists := testFileMap [parentTestName ]; exists {
2633 filePath = path
2734 }
2835 } else if path , exists := testFileMap [testName ]; exists {
29- // Handle normal tests
3036 filePath = path
3137 }
3238
33- // Normalize filePath to be relative to the project root
3439 if filePath != "" {
3540 relFilePath , err := filepath .Rel (rootDir , filePath )
3641 if err != nil {
3742 return fmt .Errorf ("error getting relative path: %v" , err )
3843 }
39- report .Results [i ].TestPath = relFilePath
44+ report .Results [i ].TestPath = filepath . ToSlash ( relFilePath )
4045 } else {
41- // Log or mark tests not found in the codebase
46+ fmt . Printf ( "TestName not mapped: %s \n " , testName )
4247 report .Results [i ].TestPath = "NOT FOUND"
4348 }
4449 }
0 commit comments