UpdateTestResourcesPaths updates the list of paths with their absolute paths as per their location in the testResourcesDir directory. This will allow the executable targets to locate and access the data dependencies needed to trigger the tests. For example: In case of Bazel, this method can be used
(testResourcesDir string, paths []*string)
| 103 | // |
| 104 | // UpdateTestResourcesPaths(os.Getenv("RUNFILES_DIR"), <file_paths_list>) |
| 105 | func UpdateTestResourcesPaths(testResourcesDir string, paths []*string) error { |
| 106 | if testResourcesDir == "" { |
| 107 | return nil |
| 108 | } |
| 109 | err := filepath.Walk(testResourcesDir, func(p string, info os.FileInfo, err error) error { |
| 110 | if err != nil { |
| 111 | return err |
| 112 | } |
| 113 | if info.IsDir() { |
| 114 | return nil |
| 115 | } |
| 116 | relPath, err := filepath.Rel(testResourcesDir, p) |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | for _, path := range paths { |
| 121 | if strings.Contains(relPath, *path) { |
| 122 | *path = p |
| 123 | } |
| 124 | } |
| 125 | return nil |
| 126 | }) |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | // TestRunnerOption is used to configure the following attributes of the Test Runner: |
| 131 | // - set the Compiler |
no test coverage detected