mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Adapt code so it works for reporting script
Reporting script now parses JunitXML instead of a series of ".container_log" files. The script in in changed submodule. Additionally it makes failed tests actually fail so that this is recorded in the JunitXML report.
This commit is contained in:
parent
eb16285790
commit
75369cf621
5 changed files with 27 additions and 10 deletions
6
Makefile
6
Makefile
|
@ -23,7 +23,8 @@ MYPY_ARGS := --ignore-missing-imports \
|
||||||
--disallow-untyped-defs \
|
--disallow-untyped-defs \
|
||||||
--show-error-codes \
|
--show-error-codes \
|
||||||
--warn-unreachable \
|
--warn-unreachable \
|
||||||
--warn-unused-ignores
|
--warn-unused-ignores \
|
||||||
|
--exclude $(LARGE_TEST_REPO_DIR)/*.py
|
||||||
|
|
||||||
mypy-host:
|
mypy-host:
|
||||||
mypy $(MYPY_ARGS) dangerzone
|
mypy $(MYPY_ARGS) dangerzone
|
||||||
|
@ -57,12 +58,13 @@ test-large-init: test-large-requirements
|
||||||
@echo "initializing 'test_docs_large' submodule"
|
@echo "initializing 'test_docs_large' submodule"
|
||||||
git submodule init $(LARGE_TEST_REPO_DIR)
|
git submodule init $(LARGE_TEST_REPO_DIR)
|
||||||
git submodule update $(LARGE_TEST_REPO_DIR)
|
git submodule update $(LARGE_TEST_REPO_DIR)
|
||||||
git lfs pull $(LARGE_TEST_REPO_DIR)
|
cd $(LARGE_TEST_REPO_DIR) && $(MAKE) clone-docs
|
||||||
|
|
||||||
TEST_LARGE_RESULTS:=$(LARGE_TEST_REPO_DIR)/results/junit/commit_$(GIT_DESC).junit.xml
|
TEST_LARGE_RESULTS:=$(LARGE_TEST_REPO_DIR)/results/junit/commit_$(GIT_DESC).junit.xml
|
||||||
.PHONY: tests-large
|
.PHONY: tests-large
|
||||||
test-large: test-large-init ## Run large test set
|
test-large: test-large-init ## Run large test set
|
||||||
python -m pytest tests/test_large_set.py::TestLargeSet -v $(JUNIT_FLAGS) --junitxml=$(TEST_LARGE_RESULTS)
|
python -m pytest tests/test_large_set.py::TestLargeSet -v $(JUNIT_FLAGS) --junitxml=$(TEST_LARGE_RESULTS)
|
||||||
|
python $(TEST_LARGE_RESULTS)/report.py $(TEST_LARGE_RESULTS)
|
||||||
|
|
||||||
# Makefile self-help borrowed from the securedrop-client project
|
# Makefile self-help borrowed from the securedrop-client project
|
||||||
# Explaination of the below shell command should it ever break.
|
# Explaination of the below shell command should it ever break.
|
||||||
|
|
|
@ -388,5 +388,6 @@ async def main() -> int:
|
||||||
container_log.write(converter.captured_output)
|
container_log.write(converter.captured_output)
|
||||||
return error_code
|
return error_code
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(asyncio.run(main()))
|
sys.exit(asyncio.run(main()))
|
||||||
|
|
|
@ -11,6 +11,8 @@ from ..util import replace_control_chars
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
|
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
|
||||||
|
CONVERSION_LOG_START = "-----CONVERSION LOG START-----"
|
||||||
|
CONVERSION_LOG_END = "-----CONVERSION LOG END-----"
|
||||||
|
|
||||||
|
|
||||||
class IsolationProvider(ABC):
|
class IsolationProvider(ABC):
|
||||||
|
@ -88,8 +90,8 @@ class IsolationProvider(ABC):
|
||||||
conversion_string = replace_control_chars(untrusted_conversion_str)
|
conversion_string = replace_control_chars(untrusted_conversion_str)
|
||||||
|
|
||||||
# Add armor (gpg-style)
|
# Add armor (gpg-style)
|
||||||
armor_start = "-----CONVERSION LOG START-----\n"
|
armor_start = f"{CONVERSION_LOG_START}\n"
|
||||||
armor_end = "-----CONVERSION LOG END-----"
|
armor_end = CONVERSION_LOG_END
|
||||||
return armor_start + conversion_string + armor_end
|
return armor_start + conversion_string + armor_end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4cbf14ac31ac986ced60e83867aac8a6d2d4a81b
|
Subproject commit 51419aa36bd4701927d1610fb544e18a4692f1db
|
|
@ -10,6 +10,7 @@ from _pytest.fixtures import FixtureRequest
|
||||||
|
|
||||||
from dangerzone.document import SAFE_EXTENSION
|
from dangerzone.document import SAFE_EXTENSION
|
||||||
|
|
||||||
|
from .test_cli import TestCli
|
||||||
|
|
||||||
test_docs_repo_dir = Path(__file__).parent / "test_docs_large"
|
test_docs_repo_dir = Path(__file__).parent / "test_docs_large"
|
||||||
test_docs_dir = test_docs_repo_dir / "all_documents"
|
test_docs_dir = test_docs_repo_dir / "all_documents"
|
||||||
|
@ -59,16 +60,27 @@ for_each_100M_doc = pytest.mark.parametrize(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestLargeSet(TestCli):
|
||||||
class TestLargeSet():
|
|
||||||
def run_doc_test(self, doc: Path, tmp_path: Path) -> None:
|
def run_doc_test(self, doc: Path, tmp_path: Path) -> None:
|
||||||
output_file_path = str(tmp_path / "output.pdf")
|
output_file_path = str(tmp_path / "output.pdf")
|
||||||
p = subprocess.Popen([
|
p = subprocess.Popen(
|
||||||
"python", "dev_scripts/dangerzone-cli", "--output-filename", output_file_path, "--ocr-lang", "eng", str(doc)
|
[
|
||||||
], stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
|
"python",
|
||||||
|
"dev_scripts/dangerzone-cli",
|
||||||
|
"--output-filename",
|
||||||
|
output_file_path,
|
||||||
|
"--ocr-lang",
|
||||||
|
"eng",
|
||||||
|
str(doc),
|
||||||
|
],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
)
|
||||||
out, _ = p.communicate()
|
out, _ = p.communicate()
|
||||||
from strip_ansi import strip_ansi
|
from strip_ansi import strip_ansi
|
||||||
|
|
||||||
print(strip_ansi(out.decode()))
|
print(strip_ansi(out.decode()))
|
||||||
|
assert p.returncode == 0
|
||||||
|
|
||||||
@for_each_10K_doc
|
@for_each_10K_doc
|
||||||
def test_10K_docs(self, doc: Path, tmp_path: Path) -> None:
|
def test_10K_docs(self, doc: Path, tmp_path: Path) -> None:
|
||||||
|
|
Loading…
Reference in a new issue