MCPcopy Create free account
hub / github.com/cel-expr/cel-go / UpdateTestResourcesPaths

Function UpdateTestResourcesPaths

tools/celtest/test_runner.go:105–128  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

103//
104// UpdateTestResourcesPaths(os.Getenv("RUNFILES_DIR"), <file_paths_list>)
105func 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

Callers 1

Calls 1

ContainsMethod · 0.65

Tested by

no test coverage detected