From 110347733560b9f5abf4218c60e2656fbe60c2da Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 3 Dec 2018 18:57:11 +0100 Subject: [PATCH] e2e/framework: absolute test file paths Tests might want to use there own options for specifying a file path, while still using the abstract file access API. For example, framework.CreateFromManifests might be used to create a mixture of files under the repo root and from elsewhere. To support this, absolute paths can now be given to the testfiles package and they will be read directly. --- test/e2e/framework/testfiles/testfiles.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/e2e/framework/testfiles/testfiles.go b/test/e2e/framework/testfiles/testfiles.go index f0b0a8740c0..84f717ec935 100644 --- a/test/e2e/framework/testfiles/testfiles.go +++ b/test/e2e/framework/testfiles/testfiles.go @@ -129,9 +129,16 @@ type RootFileSource struct { } // ReadTestFile looks for the file relative to the configured -// root directory. +// root directory. If the path is already absolute, for example +// in a test that has its own method of determining where +// files are, then the path will be used directly. func (r RootFileSource) ReadTestFile(filePath string) ([]byte, error) { - fullPath := filepath.Join(r.Root, filePath) + var fullPath string + if path.IsAbs(filePath) { + fullPath = filePath + } else { + fullPath = filepath.Join(r.Root, filePath) + } data, err := ioutil.ReadFile(fullPath) if os.IsNotExist(err) { // Not an error (yet), some other provider may have the file.