Ensured tests can be run from any directory.
This commit is contained in:
parent
065d62d2fc
commit
c2aca79428
2 changed files with 4 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import unittest
|
||||||
|
|
||||||
|
|
||||||
tempfile.tempdir = os.getcwd() # This tests fails when using /tmp.
|
tempfile.tempdir = os.getcwd() # This tests fails when using /tmp.
|
||||||
|
VIGIL_ROOT = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
def _get_test_paths(temp_dir):
|
def _get_test_paths(temp_dir):
|
||||||
|
|
@ -26,7 +27,8 @@ class SandboxFilesystemTestCase(unittest.TestCase):
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
a_dir, foo_path, bar_path = _get_test_paths(temp_dir)
|
a_dir, foo_path, bar_path = _get_test_paths(temp_dir)
|
||||||
os.mkdir(a_dir)
|
os.mkdir(a_dir)
|
||||||
subprocess.check_call(["./sandbox_fs", a_dir, "--", __file__,
|
sandbox_fs_path = os.path.join(VIGIL_ROOT, "sandbox_fs")
|
||||||
|
subprocess.check_call([sandbox_fs_path, a_dir, "--", __file__,
|
||||||
temp_dir])
|
temp_dir])
|
||||||
self.assertTrue(os.path.exists(foo_path))
|
self.assertTrue(os.path.exists(foo_path))
|
||||||
self.assertFalse(os.path.exists(bar_path))
|
self.assertFalse(os.path.exists(bar_path))
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ def result_path(tool, input_filename):
|
||||||
|
|
||||||
|
|
||||||
def run_tool(tool, input_filename):
|
def run_tool(tool, input_filename):
|
||||||
with chdir("golden-files"):
|
with chdir(os.path.join(VIGIL_ROOT, "golden-files")):
|
||||||
return tool(os.path.join(".", "input", input_filename))
|
return tool(os.path.join(".", "input", input_filename))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue