diff --git a/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/main.tex b/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/main.tex new file mode 100644 index 00000000..e8a8685b --- /dev/null +++ b/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/main.tex @@ -0,0 +1,14 @@ +\documentclass{article} +\usepackage{amsmath} + +\begin{document} + +\section*{Hello World!} + +This is a simple LaTeX document saying Hello World! Below is a mathematical formula from linear algebra, representing the dot product of two vectors: + +\[ +\mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + \dots + a_nb_n +\] + +\end{document} diff --git a/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/test-texlive-version-auto-detect-set.tar.gz b/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/test-texlive-version-auto-detect-set.tar.gz new file mode 100644 index 00000000..06553050 Binary files /dev/null and b/tex2pdf-service/tests/fixture/tarballs/test-texlive-version-auto-detect-set/test-texlive-version-auto-detect-set.tar.gz differ diff --git a/tex2pdf-service/tests/test_docker.py b/tex2pdf-service/tests/test_docker.py index 9a2233cd..e2451628 100644 --- a/tex2pdf-service/tests/test_docker.py +++ b/tex2pdf-service/tests/test_docker.py @@ -752,3 +752,20 @@ def test_makeindex(docker_container): # pdflatex (creates .idx), makeindex (creates .ind), pdflatex, pdflatex assert len(meta["converters"][0]["runs"]) == 4 assert meta["converters"][0]["runs"][1]["step"] == "makeindex_run" + + +@pytest.mark.integration +def test_texlive_version_autodetect_set(docker_container): + """Test that texlive_version is correctly set in outcome and in zzrm when auto-detected.""" + url = docker_container + "/convert" + tarball = os.path.join( + SELF_DIR, "fixture/tarballs/test-texlive-version-auto-detect-set/test-texlive-version-auto-detect-set.tar.gz" + ) + outcome = os.path.join(SELF_DIR, "output/test-texlive-version-auto-detect-set.outcome.tar.gz") + meta, status = submit_tarball(url, tarball, outcome, api_args={"auto_detect": "true"}) + assert status == 200 + assert meta is not None + assert meta["texlive_version"] is not None + assert meta["texlive_version"].startswith("20") + assert "texlive_version" in meta["zzrm"]["generated"] + assert "texlive_version" in meta["zzrm"]["content"] diff --git a/tex2pdf-service/tex2pdf/converter_driver.py b/tex2pdf-service/tex2pdf/converter_driver.py index a19fcb63..f5c3194f 100644 --- a/tex2pdf-service/tex2pdf/converter_driver.py +++ b/tex2pdf-service/tex2pdf/converter_driver.py @@ -19,6 +19,7 @@ GIT_COMMIT_HASH, ID_TAG, MAX_TIME_BUDGET, + TEXLIVE_BASE_RELEASE, catalog_files, file_props, file_props_in_dir, @@ -161,6 +162,7 @@ def generate_pdf(self) -> str | None: # this might raise various exceptions, that should be reported to the API down the line self.zzrm = ZeroZeroReadMe(self.in_dir) + assert self.zzrm is not None self.outcome = { ID_TAG: self.tag, @@ -171,6 +173,7 @@ def generate_pdf(self) -> str | None: "use_addon_tree": self.use_addon_tree, "max_tex_files": self.max_tex_files, "max_appending_files": self.max_appending_files, + "texlive_version": TEXLIVE_BASE_RELEASE, } if self.water.text: self.outcome["watermark"] = self.water @@ -193,6 +196,8 @@ def generate_pdf(self) -> str | None: raise Exception("Preflight didn't succeed!") if not self.zzrm.update_from_preflight(preflight_response): raise ZZRMUnderspecified("Cannot determine compiler from preflight and sources") + if not self.zzrm.texlive_version or self.zzrm.texlive_version is None: + self.zzrm.texlive_version = int(TEXLIVE_BASE_RELEASE) # we should now be ready to go if not self.zzrm.is_ready_for_compilation: