diff --git a/bopytex/worker/compile.py b/bopytex/worker/compile.py new file mode 100644 index 0000000..24a9531 --- /dev/null +++ b/bopytex/worker/compile.py @@ -0,0 +1,12 @@ +import subprocess + + +def latexmk(args: dict, deps, output): + compile_process = subprocess.Popen( + ["latexmk", deps[0]], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True + ) + yield from compile_process.stderr + diff --git a/test/worker/test_compile.py b/test/worker/test_compile.py new file mode 100644 index 0000000..7e1c96e --- /dev/null +++ b/test/worker/test_compile.py @@ -0,0 +1,35 @@ +import os + +from pathlib import Path +from bopytex.worker.compile import latexmk +import pytest + + +@pytest.fixture +def tex_path(tmp_path): + source = tmp_path / "source.tex" + with open(source, "w") as src: + src.write( + """ +\\documentclass{article} + +\\begin{document} +First document. This is a simple example, with no +extra parameters or packages included. +\\end{document} + """ + ) + return source + + +def test_compile(tex_path): + tmp_path = tex_path.parent + os.chdir(tmp_path) + + texfile = str(tex_path.name) + output = "source.pdf" + + for err in latexmk({}, [texfile], "source.pdf"): + assert 0 + + assert Path(output).exists