blob: d83cecc4367e91c0259a3d3ee95cf2e73e3f5ef9 [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
Colin Crossae8600b2020-10-29 17:09:13 -070028func NewTestContext(config Config) *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 Crossae8600b2020-10-29 17:09:13 -070035 Context: &Context{blueprint.NewContext(), config},
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
Colin Crossae8600b2020-10-29 17:09:13 -070043 ctx.SetFs(ctx.config.fs)
44 if ctx.config.mockBpList != "" {
45 ctx.SetModuleListFile(ctx.config.mockBpList)
46 }
47
Jeff Gaston088e29e2017-11-29 16:47:17 -080048 return ctx
Colin Crosscec81712017-07-13 14:43:27 -070049}
50
Colin Crossae8600b2020-10-29 17:09:13 -070051func NewTestArchContext(config Config) *TestContext {
52 ctx := NewTestContext(config)
Colin Crossae4c6182017-09-15 17:33:55 -070053 ctx.preDeps = append(ctx.preDeps, registerArchMutator)
54 return ctx
55}
56
Colin Crosscec81712017-07-13 14:43:27 -070057type TestContext struct {
Colin Cross4c83e5c2019-02-25 14:54:28 -080058 *Context
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000059 preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc
60 NameResolver *NameResolver
Colin Crosscec81712017-07-13 14:43:27 -070061}
62
63func (ctx *TestContext) PreArchMutators(f RegisterMutatorFunc) {
64 ctx.preArch = append(ctx.preArch, f)
65}
66
Paul Duffina80ef842020-01-14 12:09:36 +000067func (ctx *TestContext) HardCodedPreArchMutators(f RegisterMutatorFunc) {
68 // Register mutator function as normal for testing.
69 ctx.PreArchMutators(f)
70}
71
Colin Crosscec81712017-07-13 14:43:27 -070072func (ctx *TestContext) PreDepsMutators(f RegisterMutatorFunc) {
73 ctx.preDeps = append(ctx.preDeps, f)
74}
75
76func (ctx *TestContext) PostDepsMutators(f RegisterMutatorFunc) {
77 ctx.postDeps = append(ctx.postDeps, f)
78}
79
Martin Stjernholm710ec3a2020-01-16 15:12:04 +000080func (ctx *TestContext) FinalDepsMutators(f RegisterMutatorFunc) {
81 ctx.finalDeps = append(ctx.finalDeps, f)
82}
83
Colin Crossae8600b2020-10-29 17:09:13 -070084func (ctx *TestContext) Register() {
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
90func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
91 // This function adapts the old style ParseFileList calls that are spread throughout the tests
92 // to the new style that takes a config.
93 return ctx.Context.ParseFileList(rootDir, filePaths, ctx.config)
94}
95
96func (ctx *TestContext) ParseBlueprintsFiles(rootDir string) (deps []string, errs []error) {
97 // This function adapts the old style ParseBlueprintsFiles calls that are spread throughout the
98 // tests to the new style that takes a config.
99 return ctx.Context.ParseBlueprintsFiles(rootDir, ctx.config)
Colin Cross4b49b762019-11-22 15:25:03 -0800100}
101
102func (ctx *TestContext) RegisterModuleType(name string, factory ModuleFactory) {
103 ctx.Context.RegisterModuleType(name, ModuleFactoryAdaptor(factory))
104}
105
106func (ctx *TestContext) RegisterSingletonType(name string, factory SingletonFactory) {
107 ctx.Context.RegisterSingletonType(name, SingletonFactoryAdaptor(factory))
Colin Crosscec81712017-07-13 14:43:27 -0700108}
109
110func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
111 var module Module
112 ctx.VisitAllModules(func(m blueprint.Module) {
113 if ctx.ModuleName(m) == name && ctx.ModuleSubDir(m) == variant {
114 module = m.(Module)
115 }
116 })
117
118 if module == nil {
Jeff Gaston294356f2017-09-27 17:05:30 -0700119 // find all the modules that do exist
Colin Crossbeae6ec2020-08-11 12:02:11 -0700120 var allModuleNames []string
121 var allVariants []string
Jeff Gaston294356f2017-09-27 17:05:30 -0700122 ctx.VisitAllModules(func(m blueprint.Module) {
Colin Crossbeae6ec2020-08-11 12:02:11 -0700123 allModuleNames = append(allModuleNames, ctx.ModuleName(m))
124 if ctx.ModuleName(m) == name {
125 allVariants = append(allVariants, ctx.ModuleSubDir(m))
126 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700127 })
Martin Stjernholm4c021242020-05-13 01:13:50 +0100128 sort.Strings(allModuleNames)
Colin Crossbeae6ec2020-08-11 12:02:11 -0700129 sort.Strings(allVariants)
Jeff Gaston294356f2017-09-27 17:05:30 -0700130
Colin Crossbeae6ec2020-08-11 12:02:11 -0700131 if len(allVariants) == 0 {
132 panic(fmt.Errorf("failed to find module %q. All modules:\n %s",
133 name, strings.Join(allModuleNames, "\n ")))
134 } else {
135 panic(fmt.Errorf("failed to find module %q variant %q. All variants:\n %s",
136 name, variant, strings.Join(allVariants, "\n ")))
137 }
Colin Crosscec81712017-07-13 14:43:27 -0700138 }
139
140 return TestingModule{module}
141}
142
Jiyong Park37b25202018-07-11 10:49:27 +0900143func (ctx *TestContext) ModuleVariantsForTests(name string) []string {
144 var variants []string
145 ctx.VisitAllModules(func(m blueprint.Module) {
146 if ctx.ModuleName(m) == name {
147 variants = append(variants, ctx.ModuleSubDir(m))
148 }
149 })
150 return variants
151}
152
Colin Cross4c83e5c2019-02-25 14:54:28 -0800153// SingletonForTests returns a TestingSingleton for the singleton registered with the given name.
154func (ctx *TestContext) SingletonForTests(name string) TestingSingleton {
155 allSingletonNames := []string{}
156 for _, s := range ctx.Singletons() {
157 n := ctx.SingletonName(s)
158 if n == name {
159 return TestingSingleton{
160 singleton: s.(*singletonAdaptor).Singleton,
161 provider: s.(testBuildProvider),
162 }
163 }
164 allSingletonNames = append(allSingletonNames, n)
165 }
166
167 panic(fmt.Errorf("failed to find singleton %q."+
168 "\nall singletons: %v", name, allSingletonNames))
169}
170
Colin Cross4c83e5c2019-02-25 14:54:28 -0800171type testBuildProvider interface {
172 BuildParamsForTests() []BuildParams
173 RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
174}
175
176type TestingBuildParams struct {
177 BuildParams
178 RuleParams blueprint.RuleParams
179}
180
181func newTestingBuildParams(provider testBuildProvider, bparams BuildParams) TestingBuildParams {
182 return TestingBuildParams{
183 BuildParams: bparams,
184 RuleParams: provider.RuleParamsForTests()[bparams.Rule],
185 }
186}
187
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200188func maybeBuildParamsFromRule(provider testBuildProvider, rule string) (TestingBuildParams, []string) {
189 var searchedRules []string
Colin Cross4c83e5c2019-02-25 14:54:28 -0800190 for _, p := range provider.BuildParamsForTests() {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200191 searchedRules = append(searchedRules, p.Rule.String())
Colin Cross4c83e5c2019-02-25 14:54:28 -0800192 if strings.Contains(p.Rule.String(), rule) {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200193 return newTestingBuildParams(provider, p), searchedRules
Colin Cross4c83e5c2019-02-25 14:54:28 -0800194 }
195 }
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200196 return TestingBuildParams{}, searchedRules
Colin Cross4c83e5c2019-02-25 14:54:28 -0800197}
198
199func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200200 p, searchRules := maybeBuildParamsFromRule(provider, rule)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800201 if p.Rule == nil {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200202 panic(fmt.Errorf("couldn't find rule %q.\nall rules: %v", rule, searchRules))
Colin Cross4c83e5c2019-02-25 14:54:28 -0800203 }
204 return p
205}
206
207func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
208 for _, p := range provider.BuildParamsForTests() {
Colin Crossb88b3c52019-06-10 15:15:17 -0700209 if strings.Contains(p.Description, desc) {
Colin Cross4c83e5c2019-02-25 14:54:28 -0800210 return newTestingBuildParams(provider, p)
211 }
212 }
213 return TestingBuildParams{}
214}
215
216func buildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
217 p := maybeBuildParamsFromDescription(provider, desc)
218 if p.Rule == nil {
219 panic(fmt.Errorf("couldn't find description %q", desc))
220 }
221 return p
222}
223
224func maybeBuildParamsFromOutput(provider testBuildProvider, file string) (TestingBuildParams, []string) {
225 var searchedOutputs []string
226 for _, p := range provider.BuildParamsForTests() {
227 outputs := append(WritablePaths(nil), p.Outputs...)
Colin Cross1d2cf042019-03-29 15:33:06 -0700228 outputs = append(outputs, p.ImplicitOutputs...)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800229 if p.Output != nil {
230 outputs = append(outputs, p.Output)
231 }
232 for _, f := range outputs {
233 if f.String() == file || f.Rel() == file {
234 return newTestingBuildParams(provider, p), nil
235 }
236 searchedOutputs = append(searchedOutputs, f.Rel())
237 }
238 }
239 return TestingBuildParams{}, searchedOutputs
240}
241
242func buildParamsFromOutput(provider testBuildProvider, file string) TestingBuildParams {
243 p, searchedOutputs := maybeBuildParamsFromOutput(provider, file)
244 if p.Rule == nil {
245 panic(fmt.Errorf("couldn't find output %q.\nall outputs: %v",
246 file, searchedOutputs))
247 }
248 return p
249}
250
251func allOutputs(provider testBuildProvider) []string {
252 var outputFullPaths []string
253 for _, p := range provider.BuildParamsForTests() {
254 outputs := append(WritablePaths(nil), p.Outputs...)
Colin Cross1d2cf042019-03-29 15:33:06 -0700255 outputs = append(outputs, p.ImplicitOutputs...)
Colin Cross4c83e5c2019-02-25 14:54:28 -0800256 if p.Output != nil {
257 outputs = append(outputs, p.Output)
258 }
259 outputFullPaths = append(outputFullPaths, outputs.Strings()...)
260 }
261 return outputFullPaths
262}
263
Colin Crossb77ffc42019-01-05 22:09:19 -0800264// TestingModule is wrapper around an android.Module that provides methods to find information about individual
265// ctx.Build parameters for verification in tests.
Colin Crosscec81712017-07-13 14:43:27 -0700266type TestingModule struct {
267 module Module
268}
269
Colin Crossb77ffc42019-01-05 22:09:19 -0800270// Module returns the Module wrapped by the TestingModule.
Colin Crosscec81712017-07-13 14:43:27 -0700271func (m TestingModule) Module() Module {
272 return m.module
273}
274
Colin Crossb77ffc42019-01-05 22:09:19 -0800275// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
276// BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800277func (m TestingModule) MaybeRule(rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200278 r, _ := maybeBuildParamsFromRule(m.module, rule)
279 return r
Colin Crosscec81712017-07-13 14:43:27 -0700280}
281
Colin Crossb77ffc42019-01-05 22:09:19 -0800282// 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 -0800283func (m TestingModule) Rule(rule string) TestingBuildParams {
284 return buildParamsFromRule(m.module, rule)
Colin Crossb77ffc42019-01-05 22:09:19 -0800285}
286
287// MaybeDescription finds a call to ctx.Build with BuildParams.Description set to a the given string. Returns an empty
288// BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800289func (m TestingModule) MaybeDescription(desc string) TestingBuildParams {
290 return maybeBuildParamsFromDescription(m.module, desc)
Nan Zhanged19fc32017-10-19 13:06:22 -0700291}
292
Colin Crossb77ffc42019-01-05 22:09:19 -0800293// Description finds a call to ctx.Build with BuildParams.Description set to a the given string. Panics if no rule is
294// found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800295func (m TestingModule) Description(desc string) TestingBuildParams {
296 return buildParamsFromDescription(m.module, desc)
Colin Crossb77ffc42019-01-05 22:09:19 -0800297}
298
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800299// 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 -0800300// value matches the provided string. Returns an empty BuildParams if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800301func (m TestingModule) MaybeOutput(file string) TestingBuildParams {
302 p, _ := maybeBuildParamsFromOutput(m.module, file)
Colin Crossb77ffc42019-01-05 22:09:19 -0800303 return p
304}
305
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800306// 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 -0800307// value matches the provided string. Panics if no rule is found.
Colin Cross4c83e5c2019-02-25 14:54:28 -0800308func (m TestingModule) Output(file string) TestingBuildParams {
309 return buildParamsFromOutput(m.module, file)
Colin Crosscec81712017-07-13 14:43:27 -0700310}
Logan Chien42039712018-03-12 16:29:17 +0800311
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800312// AllOutputs returns all 'BuildParams.Output's and 'BuildParams.Outputs's in their full path string forms.
313func (m TestingModule) AllOutputs() []string {
Colin Cross4c83e5c2019-02-25 14:54:28 -0800314 return allOutputs(m.module)
315}
316
317// TestingSingleton is wrapper around an android.Singleton that provides methods to find information about individual
318// ctx.Build parameters for verification in tests.
319type TestingSingleton struct {
320 singleton Singleton
321 provider testBuildProvider
322}
323
324// Singleton returns the Singleton wrapped by the TestingSingleton.
325func (s TestingSingleton) Singleton() Singleton {
326 return s.singleton
327}
328
329// MaybeRule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Returns an empty
330// BuildParams if no rule is found.
331func (s TestingSingleton) MaybeRule(rule string) TestingBuildParams {
ThiƩbaud Weksteen3600b802020-08-27 15:50:24 +0200332 r, _ := maybeBuildParamsFromRule(s.provider, rule)
333 return r
Colin Cross4c83e5c2019-02-25 14:54:28 -0800334}
335
336// Rule finds a call to ctx.Build with BuildParams.Rule set to a rule with the given name. Panics if no rule is found.
337func (s TestingSingleton) Rule(rule string) TestingBuildParams {
338 return buildParamsFromRule(s.provider, rule)
339}
340
341// MaybeDescription finds a call to ctx.Build with BuildParams.Description set to a the given string. Returns an empty
342// BuildParams if no rule is found.
343func (s TestingSingleton) MaybeDescription(desc string) TestingBuildParams {
344 return maybeBuildParamsFromDescription(s.provider, desc)
345}
346
347// Description finds a call to ctx.Build with BuildParams.Description set to a the given string. Panics if no rule is
348// found.
349func (s TestingSingleton) Description(desc string) TestingBuildParams {
350 return buildParamsFromDescription(s.provider, desc)
351}
352
353// MaybeOutput finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
354// value matches the provided string. Returns an empty BuildParams if no rule is found.
355func (s TestingSingleton) MaybeOutput(file string) TestingBuildParams {
356 p, _ := maybeBuildParamsFromOutput(s.provider, file)
357 return p
358}
359
360// Output finds a call to ctx.Build with a BuildParams.Output or BuildParams.Outputs whose String() or Rel()
361// value matches the provided string. Panics if no rule is found.
362func (s TestingSingleton) Output(file string) TestingBuildParams {
363 return buildParamsFromOutput(s.provider, file)
364}
365
366// AllOutputs returns all 'BuildParams.Output's and 'BuildParams.Outputs's in their full path string forms.
367func (s TestingSingleton) AllOutputs() []string {
368 return allOutputs(s.provider)
Jaewoong Jung9d22a912019-01-23 16:27:47 -0800369}
370
Logan Chien42039712018-03-12 16:29:17 +0800371func FailIfErrored(t *testing.T, errs []error) {
372 t.Helper()
373 if len(errs) > 0 {
374 for _, err := range errs {
375 t.Error(err)
376 }
377 t.FailNow()
378 }
379}
Logan Chienee97c3e2018-03-12 16:34:26 +0800380
381func FailIfNoMatchingErrors(t *testing.T, pattern string, errs []error) {
382 t.Helper()
383
384 matcher, err := regexp.Compile(pattern)
385 if err != nil {
386 t.Errorf("failed to compile regular expression %q because %s", pattern, err)
387 }
388
389 found := false
390 for _, err := range errs {
391 if matcher.FindStringIndex(err.Error()) != nil {
392 found = true
393 break
394 }
395 }
396 if !found {
397 t.Errorf("missing the expected error %q (checked %d error(s))", pattern, len(errs))
398 for i, err := range errs {
Colin Crossaede88c2020-08-11 12:17:01 -0700399 t.Errorf("errs[%d] = %q", i, err)
Logan Chienee97c3e2018-03-12 16:34:26 +0800400 }
401 }
402}
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700403
Paul Duffin91e38192019-08-05 15:07:57 +0100404func CheckErrorsAgainstExpectations(t *testing.T, errs []error, expectedErrorPatterns []string) {
405 t.Helper()
406
407 if expectedErrorPatterns == nil {
408 FailIfErrored(t, errs)
409 } else {
410 for _, expectedError := range expectedErrorPatterns {
411 FailIfNoMatchingErrors(t, expectedError, errs)
412 }
413 if len(errs) > len(expectedErrorPatterns) {
414 t.Errorf("additional errors found, expected %d, found %d",
415 len(expectedErrorPatterns), len(errs))
416 for i, expectedError := range expectedErrorPatterns {
417 t.Errorf("expectedErrors[%d] = %s", i, expectedError)
418 }
419 for i, err := range errs {
420 t.Errorf("errs[%d] = %s", i, err)
421 }
422 }
423 }
424
425}
426
Paul Duffin8c3fec42020-03-04 20:15:08 +0000427func SetInMakeForTests(config Config) {
428 config.inMake = true
429}
430
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900431func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) []AndroidMkEntries {
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700432 var p AndroidMkEntriesProvider
433 var ok bool
434 if p, ok = mod.(AndroidMkEntriesProvider); !ok {
Roland Levillaindfe75b32019-07-23 16:53:32 +0100435 t.Errorf("module does not implement AndroidMkEntriesProvider: " + mod.Name())
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700436 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900437
438 entriesList := p.AndroidMkEntries()
439 for i, _ := range entriesList {
440 entriesList[i].fillInEntries(config, bpPath, mod)
441 }
442 return entriesList
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -0700443}
Jooyung Han12df5fb2019-07-11 16:18:47 +0900444
445func AndroidMkDataForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkData {
446 var p AndroidMkDataProvider
447 var ok bool
448 if p, ok = mod.(AndroidMkDataProvider); !ok {
Roland Levillaindfe75b32019-07-23 16:53:32 +0100449 t.Errorf("module does not implement AndroidMkDataProvider: " + mod.Name())
Jooyung Han12df5fb2019-07-11 16:18:47 +0900450 }
451 data := p.AndroidMk()
452 data.fillInData(config, bpPath, mod)
453 return data
454}
Paul Duffin9b478b02019-12-10 13:41:51 +0000455
456// Normalize the path for testing.
457//
458// If the path is relative to the build directory then return the relative path
459// to avoid tests having to deal with the dynamically generated build directory.
460//
461// Otherwise, return the supplied path as it is almost certainly a source path
462// that is relative to the root of the source tree.
463//
464// The build and source paths should be distinguishable based on their contents.
465func NormalizePathForTesting(path Path) string {
466 p := path.String()
467 if w, ok := path.(WritablePath); ok {
468 rel, err := filepath.Rel(w.buildDir(), p)
469 if err != nil {
470 panic(err)
471 }
472 return rel
473 }
474 return p
475}
476
477func NormalizePathsForTesting(paths Paths) []string {
478 var result []string
479 for _, path := range paths {
480 relative := NormalizePathForTesting(path)
481 result = append(result, relative)
482 }
483 return result
484}