diff --git a/testsuite/datmantests/test_mysql_helper.py b/testsuite/datmantests/test_mysql_helper.py index 5f6d1ea..3fa9fee 100644 --- a/testsuite/datmantests/test_mysql_helper.py +++ b/testsuite/datmantests/test_mysql_helper.py @@ -51,7 +51,7 @@ class TestPostgresHelper(TestCase): self.assertEqual(proc.wait(), 0) self.assertIn(b"CREATE TABLE", stdout) self.assertIn(b"INSERT INTO", stdout) - print(stdout) # TODO + print(stdout) # TODO def test_backup_and_extraction(self): td = TemporaryDirectory("test_my_bae") diff --git a/testsuite/helpers/yama_helpers.py b/testsuite/helpers/yama_helpers.py index 9954ea7..895194f 100644 --- a/testsuite/helpers/yama_helpers.py +++ b/testsuite/helpers/yama_helpers.py @@ -6,5 +6,7 @@ from pathlib import Path def set_up_simple_yama(path: Path): path.mkdir(exist_ok=True) subprocess.check_call(("yama", "init"), cwd=path) - example_zstd_path = Path(__file__).parent.parent.parent.joinpath("example_zstd.dict") + example_zstd_path = Path(__file__).parent.parent.parent.joinpath( + "example_zstd.dict" + ) shutil.copyfile(example_zstd_path, path.joinpath("important_zstd.dict")) diff --git a/testsuite/yamatests/test_check_and_gc.py b/testsuite/yamatests/test_check_and_gc.py index 25f4324..68d49e0 100644 --- a/testsuite/yamatests/test_check_and_gc.py +++ b/testsuite/yamatests/test_check_and_gc.py @@ -1,10 +1,12 @@ +import re import subprocess from pathlib import Path from random import Random from tempfile import TemporaryDirectory +from typing import Optional from unittest import TestCase -from helpers import generate_random_dir +from helpers import generate_random_dir, randomly_mutate_directory_in_descriptor from helpers.datman_helpers import set_up_simple_datman from helpers.yama_helpers import set_up_simple_yama @@ -15,7 +17,6 @@ class TestYamaCheck(TestCase): tdpath = Path(td.name) datman_path = tdpath.joinpath("datman") - _src_path = datman_path.joinpath("srca") yama_path = datman_path.joinpath("main") set_up_simple_datman(datman_path) @@ -23,9 +24,17 @@ class TestYamaCheck(TestCase): subprocess.check_call(("yama", "check", "--shallow"), cwd=yama_path) subprocess.check_call(("yama", "check", "--deep"), cwd=yama_path) - output = subprocess.check_output(("yama", "check", "--shallow", "--apply-gc"), cwd=yama_path, stderr=subprocess.STDOUT) + output = subprocess.check_output( + ("yama", "check", "--shallow", "--apply-gc"), + cwd=yama_path, + stderr=subprocess.STDOUT, + ) self.assertIn(b" 0 chunks", output) - output = subprocess.check_output(("yama", "check", "--deep", "--apply-gc"), cwd=yama_path, stderr=subprocess.STDOUT) + output = subprocess.check_output( + ("yama", "check", "--deep", "--apply-gc"), + cwd=yama_path, + stderr=subprocess.STDOUT, + ) self.assertIn(b" 0 chunks", output) td.cleanup() @@ -50,11 +59,25 @@ class TestYamaCheck(TestCase): subprocess.check_call(("yama", "check", "--shallow"), cwd=yama_path) subprocess.check_call(("yama", "check", "--deep"), cwd=yama_path) - output = subprocess.check_output(("yama", "check", "--shallow", "--apply-gc"), cwd=yama_path, - stderr=subprocess.STDOUT) + + ec_shallow = subprocess.Popen( + ("yama", "check", "--shallow"), cwd=yama_path + ).wait() + self.assertEqual(ec_shallow, 0) + ec_deep = subprocess.Popen(("yama", "check", "--deep"), cwd=yama_path).wait() + self.assertEqual(ec_deep, 0) + + output = subprocess.check_output( + ("yama", "check", "--shallow", "--apply-gc"), + cwd=yama_path, + stderr=subprocess.STDOUT, + ) self.assertIn(b" 0 chunks", output) - output = subprocess.check_output(("yama", "check", "--deep", "--apply-gc"), cwd=yama_path, - stderr=subprocess.STDOUT) + output = subprocess.check_output( + ("yama", "check", "--deep", "--apply-gc"), + cwd=yama_path, + stderr=subprocess.STDOUT, + ) self.assertIn(b" 0 chunks", output) td.cleanup() @@ -88,9 +111,14 @@ class TestYamaCheck(TestCase): fvictim.write(b"\x01") else: fvictim.write(b"\0") - print(f"Corrupted byte {byte_to_eat} of {size_in_bytes}. Was {existing_byte!r}.") + print( + f"Corrupted byte {byte_to_eat} of {size_in_bytes}." + f" Was {existing_byte!r}." + ) - ec_shallow = subprocess.Popen(("yama", "check", "--shallow"), cwd=yama_path).wait() + ec_shallow = subprocess.Popen( + ("yama", "check", "--shallow"), cwd=yama_path + ).wait() ec_deep = subprocess.Popen(("yama", "check", "--deep"), cwd=yama_path).wait() # shallow checks won't always raise the issue