Antilint
continuous-integration/drone the build was successful Details

This commit is contained in:
Olivier 'reivilibre' 2021-09-07 19:11:34 +01:00
parent 74d1528123
commit ef7595a06f
3 changed files with 42 additions and 12 deletions

View File

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

View File

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