From 4d6632cd21eca426dd88857671238eb6d2aad94b Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 10 Nov 2016 00:30:46 +0100 Subject: [PATCH] Removed the last use of sudo in the tests. --- golden-files/results/pydoc-hi3_py | 24 ++++++++++++------------ golden-files/results/pydoc-hi_py | 24 ++++++++++++------------ test-all | 1 - tools_test.py | 15 +++++---------- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/golden-files/results/pydoc-hi3_py b/golden-files/results/pydoc-hi3_py index e033fda..b23b009 100644 --- a/golden-files/results/pydoc-hi3_py +++ b/golden-files/results/pydoc-hi3_py @@ -1,12 +1,12 @@ -Help on module hi3: - -NAME - hi3 - -FUNCTIONS - hi() - -FILE - /tmp/vigil/golden-files/input/hi3.py - - \ No newline at end of file +Help on module hi3: + +NAME + hi3 + +FUNCTIONS + hi() + +FILE + /home/EVERY_USER/code/vigil/golden-files/input/hi3.py + + \ No newline at end of file diff --git a/golden-files/results/pydoc-hi_py b/golden-files/results/pydoc-hi_py index 6ebd5d4..612017b 100644 --- a/golden-files/results/pydoc-hi_py +++ b/golden-files/results/pydoc-hi_py @@ -1,12 +1,12 @@ -Help on module hi: - -NAME - hi - -FILE - /tmp/vigil/golden-files/input/hi.py - -FUNCTIONS - hi() - - \ No newline at end of file +Help on module hi: + +NAME + hi + +FILE + /home/EVERY_USER/code/vigil/golden-files/input/hi.py + +FUNCTIONS + hi() + + \ No newline at end of file diff --git a/test-all b/test-all index 45146b3..28d77ba 100755 --- a/test-all +++ b/test-all @@ -2,7 +2,6 @@ CODEBASE_PATH=$(dirname $0) -sudo -p "Some tests need sudo to run... [sudo] password for %u: " true for test in ${CODEBASE_PATH}/*_test.py; do echo "Testing $test ..." ./${test} 2>&1 diff --git a/tools_test.py b/tools_test.py index 21377c6..c992ffb 100755 --- a/tools_test.py +++ b/tools_test.py @@ -18,7 +18,6 @@ import tools os.environ["TZ"] = "GMT" VIGIL_ROOT = os.path.dirname(__file__) -TMP_ROOT = "/tmp/vigil" def widget_to_string(widget): @@ -42,7 +41,7 @@ def result_path(tool, input_filename): def run_tool(tool, input_filename): - with chdir(os.path.join(TMP_ROOT, "golden-files")): + with chdir("golden-files"): return tool(os.path.join(".", "input", input_filename)) @@ -53,7 +52,9 @@ class ToolsTestCase(unittest.TestCase): with self.subTest(input_filename=input_filename): status, result = run_tool(tool, input_filename) golden_path = result_path(tool, input_filename) - golden.assertGolden(widget_to_string(result), golden_path) + text = widget_to_string(result) + text = text.replace(os.environ["HOME"], "/home/EVERY_USER") + golden.assertGolden(text, golden_path) self.assertEqual(status, expected_status) def test_metadata(self): @@ -222,10 +223,4 @@ class LruCacheWithEvictionTestCase(unittest.TestCase): if __name__ == "__main__": - os.makedirs(TMP_ROOT, exist_ok=True) - subprocess.check_call(["sudo", "mount", "--bind", VIGIL_ROOT, TMP_ROOT]) - try: - golden.main() - finally: - subprocess.check_call(["sudo", "umount", "--lazy", TMP_ROOT]) - os.rmdir(TMP_ROOT) + golden.main()