Feat: latexmk worker to compile tex
This commit is contained in:
parent
76a033cf43
commit
ac8fe3dfdd
12
bopytex/worker/compile.py
Normal file
12
bopytex/worker/compile.py
Normal file
@ -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
|
||||
|
35
test/worker/test_compile.py
Normal file
35
test/worker/test_compile.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user