Antilint
continuous-integration/drone the build was successful
Details
continuous-integration/drone the build was successful
Details
This commit is contained in:
parent
74d1528123
commit
ef7595a06f
|
@ -6,5 +6,7 @@ from pathlib import Path
|
||||||
def set_up_simple_yama(path: Path):
|
def set_up_simple_yama(path: Path):
|
||||||
path.mkdir(exist_ok=True)
|
path.mkdir(exist_ok=True)
|
||||||
subprocess.check_call(("yama", "init"), cwd=path)
|
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"))
|
shutil.copyfile(example_zstd_path, path.joinpath("important_zstd.dict"))
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from random import Random
|
from random import Random
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
|
from typing import Optional
|
||||||
from unittest import TestCase
|
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.datman_helpers import set_up_simple_datman
|
||||||
from helpers.yama_helpers import set_up_simple_yama
|
from helpers.yama_helpers import set_up_simple_yama
|
||||||
|
|
||||||
|
@ -15,7 +17,6 @@ class TestYamaCheck(TestCase):
|
||||||
tdpath = Path(td.name)
|
tdpath = Path(td.name)
|
||||||
|
|
||||||
datman_path = tdpath.joinpath("datman")
|
datman_path = tdpath.joinpath("datman")
|
||||||
_src_path = datman_path.joinpath("srca")
|
|
||||||
yama_path = datman_path.joinpath("main")
|
yama_path = datman_path.joinpath("main")
|
||||||
|
|
||||||
set_up_simple_datman(datman_path)
|
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", "--shallow"), cwd=yama_path)
|
||||||
subprocess.check_call(("yama", "check", "--deep"), 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)
|
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)
|
self.assertIn(b" 0 chunks", output)
|
||||||
td.cleanup()
|
td.cleanup()
|
||||||
|
|
||||||
|
@ -50,11 +59,25 @@ class TestYamaCheck(TestCase):
|
||||||
|
|
||||||
subprocess.check_call(("yama", "check", "--shallow"), cwd=yama_path)
|
subprocess.check_call(("yama", "check", "--shallow"), cwd=yama_path)
|
||||||
subprocess.check_call(("yama", "check", "--deep"), 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)
|
self.assertIn(b" 0 chunks", output)
|
||||||
output = subprocess.check_output(("yama", "check", "--deep", "--apply-gc"), cwd=yama_path,
|
output = subprocess.check_output(
|
||||||
stderr=subprocess.STDOUT)
|
("yama", "check", "--deep", "--apply-gc"),
|
||||||
|
cwd=yama_path,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
)
|
||||||
self.assertIn(b" 0 chunks", output)
|
self.assertIn(b" 0 chunks", output)
|
||||||
td.cleanup()
|
td.cleanup()
|
||||||
|
|
||||||
|
@ -88,9 +111,14 @@ class TestYamaCheck(TestCase):
|
||||||
fvictim.write(b"\x01")
|
fvictim.write(b"\x01")
|
||||||
else:
|
else:
|
||||||
fvictim.write(b"\0")
|
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()
|
ec_deep = subprocess.Popen(("yama", "check", "--deep"), cwd=yama_path).wait()
|
||||||
|
|
||||||
# shallow checks won't always raise the issue
|
# shallow checks won't always raise the issue
|
||||||
|
|
Loading…
Reference in New Issue