diff options
-rw-r--r-- | src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py | 2 | ||||
-rw-r--r-- | src/tools/runfiles/runfiles.py | 19 | ||||
-rw-r--r-- | src/tools/runfiles/runfiles_test.py | 8 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py b/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py index 6d5493f561..1be07c4e8f 100644 --- a/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py +++ b/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py @@ -52,7 +52,7 @@ def main(): env = {"SYSTEMROOT": os.environ["SYSTEMROOT"]} else: env = {} - env.update(r.EnvVar()) + env.update(r.EnvVars()) p = subprocess.Popen( [r.Rlocation(ChildBinaryName("py"))], env=env, diff --git a/src/tools/runfiles/runfiles.py b/src/tools/runfiles/runfiles.py index f889def402..8b00539a00 100644 --- a/src/tools/runfiles/runfiles.py +++ b/src/tools/runfiles/runfiles.py @@ -40,7 +40,7 @@ right environment variables for them: r = runfiles.Create() env = {} ... - env.update(r.EnvVar()) + env.update(r.EnvVars()) p = subprocess.Popen([r.Rlocation("path/to/binary")], env, ...) """ @@ -132,19 +132,18 @@ class _Runfiles(object): raise ValueError("path is absolute: \"%s\"" % path) return self._strategy.RlocationChecked(path) - def EnvVar(self): - """Returns an environment variable for subprocesses. + def EnvVars(self): + """Returns environment variables for subprocesses. - The caller should set the returned key-value pair in the environment of + The caller should set the returned key-value pairs in the environment of subprocesses in case those subprocesses are also Bazel-built binaries that need to use runfiles. Returns: - {string: string}; a single-entry dict; key is an environment variable - name (either "RUNFILES_MANIFEST_FILE" or "RUNFILES_DIR"), value is the - value for this environment variable + {string: string}; a dict; keys are environment variable names, values are + the values for these environment variables """ - return self._strategy.EnvVar() + return self._strategy.EnvVars() class _ManifestBased(object): @@ -176,7 +175,7 @@ class _ManifestBased(object): result[tokens[0]] = tokens[1] return result - def EnvVar(self): + def EnvVars(self): return {"RUNFILES_MANIFEST_FILE": self._path} @@ -196,5 +195,5 @@ class _DirectoryBased(object): # runfiles strategy on those platforms. return posixpath.join(self._runfiles_root, path) - def EnvVar(self): + def EnvVars(self): return {"RUNFILES_DIR": self._runfiles_root} diff --git a/src/tools/runfiles/runfiles_test.py b/src/tools/runfiles/runfiles_test.py index 2255542d7e..eb022a675c 100644 --- a/src/tools/runfiles/runfiles_test.py +++ b/src/tools/runfiles/runfiles_test.py @@ -50,7 +50,7 @@ class RunfilesTest(unittest.TestCase): }) self.assertEqual(r.Rlocation("a/b"), "c/d") self.assertIsNone(r.Rlocation("foo")) - self.assertDictEqual(r.EnvVar(), {"RUNFILES_MANIFEST_FILE": mf.Path()}) + self.assertDictEqual(r.EnvVars(), {"RUNFILES_MANIFEST_FILE": mf.Path()}) def testCreatesDirectoryBasedRunfiles(self): r = runfiles.Create({ @@ -59,7 +59,7 @@ class RunfilesTest(unittest.TestCase): }) self.assertEqual(r.Rlocation("a/b"), "runfiles/dir/a/b") self.assertEqual(r.Rlocation("foo"), "runfiles/dir/foo") - self.assertDictEqual(r.EnvVar(), {"RUNFILES_DIR": "runfiles/dir"}) + self.assertDictEqual(r.EnvVars(), {"RUNFILES_DIR": "runfiles/dir"}) def testFailsToCreateManifestBasedBecauseManifestDoesNotExist(self): @@ -93,7 +93,7 @@ class RunfilesTest(unittest.TestCase): self.assertEqual( r.Rlocation("Foo/Bar/runfile3"), "D:\\the path\\run file 3.txt") self.assertIsNone(r.Rlocation("unknown")) - self.assertDictEqual(r.EnvVar(), {"RUNFILES_MANIFEST_FILE": mf.Path()}) + self.assertDictEqual(r.EnvVars(), {"RUNFILES_MANIFEST_FILE": mf.Path()}) def testDirectoryBasedRlocation(self): # The _DirectoryBased strategy simply joins the runfiles directory and the @@ -101,7 +101,7 @@ class RunfilesTest(unittest.TestCase): # nor does it check that the path exists. r = runfiles.CreateDirectoryBased("foo/bar baz//qux/") self.assertEqual(r.Rlocation("arg"), "foo/bar baz//qux/arg") - self.assertDictEqual(r.EnvVar(), {"RUNFILES_DIR": "foo/bar baz//qux/"}) + self.assertDictEqual(r.EnvVars(), {"RUNFILES_DIR": "foo/bar baz//qux/"}) @staticmethod def IsWindows(): |