Removed the last use of sudo in the tests.
This commit is contained in:
parent
d4e375b1fb
commit
4d6632cd21
4 changed files with 29 additions and 35 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
Help on module hi3:
|
Help on module hi3:
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
hi3
|
hi3
|
||||||
|
|
||||||
FUNCTIONS
|
FUNCTIONS
|
||||||
hi()
|
hi()
|
||||||
|
|
||||||
FILE
|
FILE
|
||||||
/tmp/vigil/golden-files/input/hi3.py
|
/home/EVERY_USER/code/vigil/golden-files/input/hi3.py
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
Help on module hi:
|
Help on module hi:
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
hi
|
hi
|
||||||
|
|
||||||
FILE
|
FILE
|
||||||
/tmp/vigil/golden-files/input/hi.py
|
/home/EVERY_USER/code/vigil/golden-files/input/hi.py
|
||||||
|
|
||||||
FUNCTIONS
|
FUNCTIONS
|
||||||
hi()
|
hi()
|
||||||
|
|
||||||
|
|
||||||
1
test-all
1
test-all
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
|
|
||||||
CODEBASE_PATH=$(dirname $0)
|
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
|
for test in ${CODEBASE_PATH}/*_test.py; do
|
||||||
echo "Testing $test ..."
|
echo "Testing $test ..."
|
||||||
./${test} 2>&1
|
./${test} 2>&1
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import tools
|
||||||
|
|
||||||
os.environ["TZ"] = "GMT"
|
os.environ["TZ"] = "GMT"
|
||||||
VIGIL_ROOT = os.path.dirname(__file__)
|
VIGIL_ROOT = os.path.dirname(__file__)
|
||||||
TMP_ROOT = "/tmp/vigil"
|
|
||||||
|
|
||||||
|
|
||||||
def widget_to_string(widget):
|
def widget_to_string(widget):
|
||||||
|
|
@ -42,7 +41,7 @@ def result_path(tool, input_filename):
|
||||||
|
|
||||||
|
|
||||||
def run_tool(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))
|
return tool(os.path.join(".", "input", input_filename))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,7 +52,9 @@ class ToolsTestCase(unittest.TestCase):
|
||||||
with self.subTest(input_filename=input_filename):
|
with self.subTest(input_filename=input_filename):
|
||||||
status, result = run_tool(tool, input_filename)
|
status, result = run_tool(tool, input_filename)
|
||||||
golden_path = result_path(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)
|
self.assertEqual(status, expected_status)
|
||||||
|
|
||||||
def test_metadata(self):
|
def test_metadata(self):
|
||||||
|
|
@ -222,10 +223,4 @@ class LruCacheWithEvictionTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
os.makedirs(TMP_ROOT, exist_ok=True)
|
golden.main()
|
||||||
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)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue