blob: 8ea4168d1a8ebd79fbb22d0f94dc2143dfbe133f [file] [log] [blame]
Colin Crosscec81712017-07-13 14:43:27 -07001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
17import (
18 "fmt"
Paul Duffin9b478b02019-12-10 13:41:51 +000019 "path/filepath"
Logan Chienee97c3e2018-03-12 16:34:26 +080020 "regexp"
Martin Stjernholm4c021242020-05-13 01:13:50 +010021 "sort"
Colin Crosscec81712017-07-13 14:43:27 -070022 "strings"
Logan Chien42039712018-03-12 16:29:17 +080023 "testing"
Colin Crosscec81712017-07-13 14:43:27 -070024
25 "github.com/google/blueprint"
26)
27
28func NewTestContext() *TestContext {
Jeff Gaston088e29e2017-11-29 16:47:17 -080029 namespaceExportFilter := func(namespace *Namespace) bool {
30 return true
31 }
Jeff Gastonb274ed32017-12-01 17:10:33 -080032
33 nameResolver := NewNameResolver(namespaceExportFilter)
34 ctx := &TestContext{
Colin Cross4c83e5c2019-02-25 14:54:28 -080035 Context: &Context{blueprint.NewContext()},
Jeff Gastonb274ed32017-12-01 17:10:33 -080036 NameResolver: nameResolver,
37 }
38
39 ctx.SetNameInterface(nameResolver)
Jeff Gaston088e29e2017-11-29 16:47:17 -080040
Colin Cross1b488422019-03-04 22:33:56 -080041 ctx.postDeps = append(ctx.postDeps, registerPathDepsMutator)
42
Jeff Gaston088e29e2017-11-29 16:47:17 -080043 return ctx
Colin Crosscec81712017-07-13 14:43:27 -070044}
45
Colin Crossae4c6182017-09-15 17:33:55 -070046func NewTestArchContext() *TestContext {
47 ctx := NewTestContext()
48 ctx.preDeps = append(ctx.preDeps, registerArchMutator)
49 return ctx
50}
51
Colin Crosscec81712017-07-13 14:43:27 -070052type TestContext struct {
Colin Cross4c83e5c2019-02-25 14:54:28 -080053 *Context
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000054 preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc
55 NameResolver *NameResolver
56 config Config
Colin Crosscec81712017-07-13 14:43:27 -070057}
58
59func (ctx *TestContext) PreArchMutators(f RegisterMutatorFunc) {
60 ctx.preArch = append(ctx.preArch, f)
61}
62
Paul Duffina80ef842020-01-14 12:09:36 +000063func (ctx *TestContext) HardCodedPreArchMutators(f RegisterMutatorFunc) {
64 // Register mutator function as normal for testing.
65 ctx.PreArchMutators(f)
66}
67
Colin Crosscec81712017-07-13 14:43:27 -070068func (ctx *TestContext) PreDepsMutators(f RegisterMutatorFunc) {
69 ctx.preDeps = append(ctx.preDeps, f)
70}
71
72func (ctx *TestContext) PostDepsMutators(f RegisterMutatorFunc) {
73 ctx.postDeps = append(ctx.postDeps, f)
74}
75
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000076func (ctx *TestContext) FinalDepsMutators(f RegisterMutatorFunc) {
77 ctx.finalDeps = append(ctx.finalDeps, f)
78}
79
Colin Cross98be1bb2019-12-13 20:41:13 -080080func (ctx *TestContext) Register(config Config) {
81 ctx.SetFs(config.fs)
82 if config.mockBpList != "" {
83 ctx.SetModuleListFile(config.mockBpList)
84 }
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000085 registerMutators(ctx.Context.Context, ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.finalDeps)
Colin Crosscec81712017-07-13 14:43:27 -070086
Colin Cross4b49b762019-11-22 15:25:03 -080087 ctx.RegisterSingletonType("env", EnvSingleton)
Colin Cross31a738b2019-12-30 18:45:15 -080088
89 ctx.config = config
90}
91
92func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
93 // This function adapts the old style ParseFileList calls that are spread throughout the tests
94 // to the new style that takes a config.
95 return ctx.Context.ParseFileList(rootDir, filePaths, ctx.config)
96}
97
98func (ctx *TestContext) ParseBlueprintsFiles(rootDir string) (deps []string, errs []error) {
99 // This function adapts the old style ParseBlueprintsFiles calls that are spread throughout the
100 // tests to the new style that takes a config.
101 return ctx.Context.ParseBlueprintsFiles(rootDir, ctx.config)
Colin Cross4b49b762019-11-22 15:25:03 -0800102}
103
104func (ctx *TestContext) RegisterModuleType(name string, factory ModuleFactory) {
105 ctx.Context.RegisterModuleType(name, ModuleFactoryAdaptor(factory))
106}
107
108func (ctx *TestContext) RegisterSingletonType(name string, factory SingletonFactory) {
109 ctx.Context.RegisterSingletonType(name, SingletonFactoryAdaptor(factory))
Colin Crosscec81712017-07-13 14:43:27 -0700110}
111
112func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
113 var module Module
114 ctx.VisitAllModules(func(m blueprint.Module) {
115 if ctx.ModuleName(m) == name && ctx.ModuleSubDir(m) == variant {
116 module = m.(Module)
117 }
118 })
119
120 if module == nil {
Jeff Gaston294356f2017-09-27 17:05:30 -0700121 // find all the modules that do exist
Colin Crossbeae6ec2020-08-11 12:02:11 -0700122 var allModuleNames []string
123 var allVariants []string
Jeff Gaston294356f2017-09-27 17:05:30 -0700124 ctx.VisitAllModules(func(m blueprint.Module) {
Colin Crossbeae6ec2020-08-11 12:02:11 -0700125 allModuleNames = append(allModuleNames, ctx.ModuleName(m))
126 if ctx.ModuleName(m) == name {
127 allVariants = append(allVariants, ctx.ModuleSubDir(m))
128 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700129 })
Martin Stjernholm4c021242020-05-13 01:13:50 +0100130 sort.Strings(allModuleNames)
Colin Crossbeae6ec2020-08-11 12:02:11 -0700131 sort.Strings(allVariants)
Jeff Gaston294356f2017-09-27 17:05:30 -0700132
Colin Crossbeae6ec2020-08-11 12:02:11 -0700133 if len(allVariants) == 0 {
134 panic(fmt.Errorf("failed to find module %q. All modules:\n %s",
135 name, strings.Join(allModuleNames, "\n ")))
136 } else {
137 panic(fmt.Errorf("failed to find module %q variant %q. All variants:\n %s",
138 name, variant, strings.Join(allVariants, "\n ")))
139 }
Colin Crosscec81712017-07-13 14:43:27 -0700140 }
141
142 return TestingModule{module}
143}
144
Jiyong Park37b25202018-07-11 10:49:27 +0900145func (ctx *TestContext) ModuleVariantsForTests(name string) []string {
146 var variants []string
147 ctx.VisitAllModules(func(m blueprint.Module) {
148 if ctx.ModuleName(m) == name {
149 variants = append(variants, ctx.ModuleSubDir(m))
150 }
151 })
152 return variants
153}
154
Colin Cross4c83e5c2019-02-25 14:54:28 -0800155// SingletonForTests returns a TestingSingleton for the singleton registered with the given name.
156func (ctx *TestContext) SingletonForTests(name string) TestingSingleton {
157 allSingletonNames := []string{}
158 for _, s := range ctx.Singletons() {
159 n := ctx.SingletonName(s)
160 if n == name {
161 return TestingSingleton{
162 singleton: s.(*singletonAdaptor).Singleton,
163 provider: s.(testBuildProvider),
164 }
165 }
166 allSingletonNames = append(allSingletonNames, n)
167 }
168
169 panic(fmt.Errorf("failed to find singleton %q."+
170 "\nall singletons: %v", name, allSingletonNames))
171}
172
Colin Cross4c83e5c2019-02-25 14:54:28 -0800173type testBuildProvider interface {
174 BuildParamsForTests() []BuildParams
175 RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
176}
177
178type TestingBuildParams struct {
179 BuildParams
180 RuleParams blueprint.RuleParams
181}
182
183func newTestingBuildParams(provider testBuildProvider, bparams BuildParams) TestingBuildParams {
184 return TestingBuildParams{
185 BuildParams: bparams,
186 RuleParams: provider.RuleParamsForTests()[bparams.Rule],
187 }
188}
189
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200190func maybeBuildParamsFromRule(provider testBuildProvider, rule string) (TestingBuildParams, []string) {
191 var searchedRules []string
Colin Cross4c83e5c2019-02-25 14:54:28 -0800192 for _, p := range provider.BuildParamsForTests() {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200193 searchedRules = append(searchedRules, p.Rule.String())
Colin Cross4c83e5c2019-02-25 14:54:28 -0800194 if strings.Contains(p.Rule.String(), rule) {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200195 return newTestingBuildParams(provider, p), searchedRules
Colin Cross4c83e5c2019-02-25 14:54:28 -0800196 }
197 }
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200198 return TestingBuildParams{}, searchedRules
Colin Cross4c83e5c2019-02-25 14:54:28 -0800199}
200
201func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200202 p, searchRules := maybeBuildParamsFromRule(provider, rule)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800203 if p.Rule == nil {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200204 panic(fmt.Errorf("couldn't find rule %q.\nall rules: %v", rule, searchRules))
Colin Cross4c83e5c2019-02-25 14:54:28 -0800205 }
206 return p
207}
208
209func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
210 for _, p := range provider.BuildParamsForTests() {
Colin Crossb88b3c52019-06-10 15:15:17 -0700211 if strings.Contains(p.Description, desc) {
Colin Cross4c83e5c2019-02-25 14:54:28 -0800212 return newTestingBuildParams(provider, p)
213 }
214 }
215 return TestingBuildParams{}
216}
217
218func buildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
219 p := maybeBuildParamsFromDescription(provider, desc)
220 if p.Rule == nil {
221 panic(fmt.Errorf("couldn't find description %q", desc))
222 }
223 return p
224}
225
226func maybeBuildParamsFromOutput(provider testBuildProvider, file string) (TestingBuildParams, []string) {
227 var searchedOutputs []string
228 for _, p := range provider.BuildParamsForTests() {
229 outputs := append(WritablePaths(nil), p.Outputs...)
Colin Cross1d2cf042019-03-29 15:33:06 -0700230 outputs = append(outputs, p.ImplicitOutputs...)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800231 if p.Output != nil {
232 outputs = append(outputs, p.Output)
233 }
234 for _, f := range outputs {
235 if f.String() == file || f.Rel() == file {
236 return newTestingBuildParams(provider, p), nil
237 }
238 searchedOutputs = append(searchedOutputs, f.Rel())
239 }
240 }
241 return TestingBuildParams{}, searchedOutputs
242}
243
244func buildParamsFromOutput(provider testBuildProvider, file string) TestingBuildParams {
245 p, searchedOutputs := maybeBuildParamsFromOutput(provider, file)
246 if p.Rule == nil {
247 panic(fmt.Errorf("couldn't find output %q.\nall outputs: %v",
248 file, searchedOutputs))
249 }
250 return p
251}
252
253func allOutputs(provider testBuildProvider) []string {
254 var outputFullPaths []string
255 for _, p := range provider.BuildParamsForTests() {
256 outputs := append(WritablePaths(nil), p.Outputs...)
Colin Cross1d2cf042019-03-29 15:33:06 -0700257 outputs = append(outputs, p.ImplicitOutputs...)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800258 if p.Output != nil {
259 outputs = append(outputs, p.Output)
260 }
261 outputFullPaths = append(outputFullPaths, outputs.Strings()...)
262 }
263 return outputFullPaths
264}
265
Colin Crossb77ffc42019-01-05 22:09:19 -0800266// TestingModule is wrapper around an android.Module that provides methods to find information about individual
267// ctx.Build parameters for verification in tests.
Colin Crosscec81712017-07-13 14:43:27 -0700268type TestingModule struct {
269 module Module
270}
271
Colin Crossb77ffc42019-01-05 22:09:19 -0800272// Module returns the Module wrapped by the TestingModule.
Colin Crosscec81712017-07-13 14:43:27 -0700273func (m TestingModule) Module() Module {
274 return m.module
275}
276
Colin Crossb77ffc42019-01-05 22:09:19 -0800277// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
278// BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800279func (m TestingModule) MaybeRule(rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200280 r, _ := maybeBuildParamsFromRule(m.module, rule)
281 return r
Colin Crosscec81712017-07-13 14:43:27 -0700282}
283
Colin Crossb77ffc42019-01-05 22:09:19 -0800284// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800285func (m TestingModule) Rule(rule string) TestingBuildParams {
286 return buildParamsFromRule(m.module, rule)
Colin Crossb77ffc42019-01-05 22:09:19 -0800287}
288
289// MaybeDescription finds a call to ctx.Build with BuildParams.Description set to a the given string. Returns an empty
290// BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800291func (m TestingModule) MaybeDescription(desc string) TestingBuildParams {
292 return maybeBuildParamsFromDescription(m.module, desc)
Nan Zhanged19fc32017-10-19 13:06:22 -0700293}
294
Colin Crossb77ffc42019-01-05 22:09:19 -0800295// Description finds a call to ctx.Build with BuildParams.Description set to a the given string. Panics if no rule is
296// found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800297func (m TestingModule) Description(desc string) TestingBuildParams {
298 return buildParamsFromDescription(m.module, desc)
Colin Crossb77ffc42019-01-05 22:09:19 -0800299}
300
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800301// MaybeOutput finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
Colin Crossb77ffc42019-01-05 22:09:19 -0800302// value matches the provided string. Returns an empty BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800303func (m TestingModule) MaybeOutput(file string) TestingBuildParams {
304 p, _ := maybeBuildParamsFromOutput(m.module, file)
Colin Crossb77ffc42019-01-05 22:09:19 -0800305 return p
306}
307
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800308// Output finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
Colin Crossb77ffc42019-01-05 22:09:19 -0800309// value matches the provided string. Panics if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800310func (m TestingModule) Output(file string) TestingBuildParams {
311 return buildParamsFromOutput(m.module, file)
Colin Crosscec81712017-07-13 14:43:27 -0700312}
Logan Chien42039712018-03-12 16:29:17 +0800313
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800314// AllOutputs returns all 'BuildParams.Output's and 'BuildParams.Outputs's in their full path string forms.
315func (m TestingModule) AllOutputs() []string {
Colin Cross4c83e5c2019-02-25 14:54:28 -0800316 return allOutputs(m.module)
317}
318
319// TestingSingleton is wrapper around an android.Singleton that provides methods to find information about individual
320// ctx.Build parameters for verification in tests.
321type TestingSingleton struct {
322 singleton Singleton
323 provider testBuildProvider
324}
325
326// Singleton returns the Singleton wrapped by the TestingSingleton.
327func (s TestingSingleton) Singleton() Singleton {
328 return s.singleton
329}
330
331// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
332// BuildParams if no rule is found.
333func (s TestingSingleton) MaybeRule(rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200334 r, _ := maybeBuildParamsFromRule(s.provider, rule)
335 return r
Colin Cross4c83e5c2019-02-25 14:54:28 -0800336}
337
338// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
339func (s TestingSingleton) Rule(rule string) TestingBuildParams {
340 return buildParamsFromRule(s.provider, rule)
341}
342
343// MaybeDescription finds a call to ctx.Build with BuildParams.Description set to a the given string. Returns an empty
344// BuildParams if no rule is found.
345func (s TestingSingleton) MaybeDescription(desc string) TestingBuildParams {
346 return maybeBuildParamsFromDescription(s.provider, desc)
347}
348
349// Description finds a call to ctx.Build with BuildParams.Description set to a the given string. Panics if no rule is
350// found.
351func (s TestingSingleton) Description(desc string) TestingBuildParams {
352 return buildParamsFromDescription(s.provider, desc)
353}
354
355// MaybeOutput finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
356// value matches the provided string. Returns an empty BuildParams if no rule is found.
357func (s TestingSingleton) MaybeOutput(file string) TestingBuildParams {
358 p, _ := maybeBuildParamsFromOutput(s.provider, file)
359 return p
360}
361
362// Output finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
363// value matches the provided string. Panics if no rule is found.
364func (s TestingSingleton) Output(file string) TestingBuildParams {
365 return buildParamsFromOutput(s.provider, file)
366}
367
368// AllOutputs returns all 'BuildParams.Output's and 'BuildParams.Outputs's in their full path string forms.
369func (s TestingSingleton) AllOutputs() []string {
370 return allOutputs(s.provider)
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800371}
372
Logan Chien42039712018-03-12 16:29:17 +0800373func FailIfErrored(t *testing.T, errs []error) {
374 t.Helper()
375 if len(errs) > 0 {
376 for _, err := range errs {
377 t.Error(err)
378 }
379 t.FailNow()
380 }
381}
Logan Chienee97c3e2018-03-12 16:34:26 +0800382
383func FailIfNoMatchingErrors(t *testing.T, pattern string, errs []error) {
384 t.Helper()
385
386 matcher, err := regexp.Compile(pattern)
387 if err != nil {
388 t.Errorf("failed to compile regular expression %q because %s", pattern, err)
389 }
390
391 found := false
392 for _, err := range errs {
393 if matcher.FindStringIndex(err.Error()) != nil {
394 found = true
395 break
396 }
397 }
398 if !found {
399 t.Errorf("missing the expected error %q (checked %d error(s))", pattern, len(errs))
400 for i, err := range errs {
Colin Crossaede88c2020-08-11 12:17:01 -0700401 t.Errorf("errs[%d] = %q", i, err)
Logan Chienee97c3e2018-03-12 16:34:26 +0800402 }
403 }
404}
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700405
Paul Duffin91e38192019-08-05 15:07:57 +0100406func CheckErrorsAgainstExpectations(t *testing.T, errs []error, expectedErrorPatterns []string) {
407 t.Helper()
408
409 if expectedErrorPatterns == nil {
410 FailIfErrored(t, errs)
411 } else {
412 for _, expectedError := range expectedErrorPatterns {
413 FailIfNoMatchingErrors(t, expectedError, errs)
414 }
415 if len(errs) > len(expectedErrorPatterns) {
416 t.Errorf("additional errors found, expected %d, found %d",
417 len(expectedErrorPatterns), len(errs))
418 for i, expectedError := range expectedErrorPatterns {
419 t.Errorf("expectedErrors[%d] = %s", i, expectedError)
420 }
421 for i, err := range errs {
422 t.Errorf("errs[%d] = %s", i, err)
423 }
424 }
425 }
426
427}
428
Paul Duffin8c3fec42020-03-04 20:15:08 +0000429func SetInMakeForTests(config Config) {
430 config.inMake = true
431}
432
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900433func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) []AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700434 var p AndroidMkEntriesProvider
435 var ok bool
436 if p, ok = mod.(AndroidMkEntriesProvider); !ok {
Roland Levillaindfe75b32019-07-23 16:53:32 +0100437 t.Errorf("module does not implement AndroidMkEntriesProvider: " + mod.Name())
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700438 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900439
440 entriesList := p.AndroidMkEntries()
441 for i, _ := range entriesList {
442 entriesList[i].fillInEntries(config, bpPath, mod)
443 }
444 return entriesList
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700445}
Jooyung Han12df5fb2019-07-11 16:18:47 +0900446
447func AndroidMkDataForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkData {
448 var p AndroidMkDataProvider
449 var ok bool
450 if p, ok = mod.(AndroidMkDataProvider); !ok {
Roland Levillaindfe75b32019-07-23 16:53:32 +0100451 t.Errorf("module does not implement AndroidMkDataProvider: " + mod.Name())
Jooyung Han12df5fb2019-07-11 16:18:47 +0900452 }
453 data := p.AndroidMk()
454 data.fillInData(config, bpPath, mod)
455 return data
456}
Paul Duffin9b478b02019-12-10 13:41:51 +0000457
458// Normalize the path for testing.
459//
460// If the path is relative to the build directory then return the relative path
461// to avoid tests having to deal with the dynamically generated build directory.
462//
463// Otherwise, return the supplied path as it is almost certainly a source path
464// that is relative to the root of the source tree.
465//
466// The build and source paths should be distinguishable based on their contents.
467func NormalizePathForTesting(path Path) string {
468 p := path.String()
469 if w, ok := path.(WritablePath); ok {
470 rel, err := filepath.Rel(w.buildDir(), p)
471 if err != nil {
472 panic(err)
473 }
474 return rel
475 }
476 return p
477}
478
479func NormalizePathsForTesting(paths Paths) []string {
480 var result []string
481 for _, path := range paths {
482 relative := NormalizePathForTesting(path)
483 result = append(result, relative)
484 }
485 return result
486}