Removed the last use of sudo in the tests.

This commit is contained in:
Andrew Hamilton 2016-11-10 00:30:46 +01:00
parent d4e375b1fb
commit 4d6632cd21
4 changed files with 29 additions and 35 deletions

View file

@ -7,6 +7,6 @@ FUNCTIONS
hi()
FILE
/tmp/vigil/golden-files/input/hi3.py
/home/EVERY_USER/code/vigil/golden-files/input/hi3.py

View file

@ -4,7 +4,7 @@ NAME
hi
FILE
/tmp/vigil/golden-files/input/hi.py
/home/EVERY_USER/code/vigil/golden-files/input/hi.py
FUNCTIONS
hi()

View file

@ -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

View file

@ -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)