diff --git a/src/tartex/tartex.py b/src/tartex/tartex.py index c71b820..f27ac74 100644 --- a/src/tartex/tartex.py +++ b/src/tartex/tartex.py @@ -385,9 +385,14 @@ def _do_tar(self, tar_obj): tinfo = tar_obj.tarinfo(fpath.name) tinfo.size = len(byt) tinfo.mtime = int(time.time()) + # Copy user/group names from main.tex file - tinfo.uname = tar_obj.getmember(self.main_file.name).uname - tinfo.gname = tar_obj.getmember(self.main_file.name).gname + tinfo.uname = tar_obj.getmember( + self.main_file.with_suffix(".tex").name + ).uname + tinfo.gname = tar_obj.getmember( + self.main_file.with_suffix(".tex").name + ).gname tar_obj.addfile(tinfo, BytesIO(byt)) diff --git a/tests/test_fls.py b/tests/test_fls.py new file mode 100644 index 0000000..c9cb97d --- /dev/null +++ b/tests/test_fls.py @@ -0,0 +1,24 @@ +# vim:set et sw=4 ts=4: + +""" +Tests for when source dir has .fls file +""" + +import pytest + +from tartex.tartex import TarTeX + + +def test_fls_main_arg(datadir, capsys): + """User passes a .fls filename as input""" + fls_name = "main.fls" + t = TarTeX( + [str(datadir / fls_name), "-o", str(datadir), "-x", "*.bbl", "-bs"], + ) + assert t.tar_file.name == fls_name.replace(".fls", ".tar") + # Note that this will throw because the .bbl file marked as INPUT in + # pre-generated .fls file does not exist in source dir + with pytest.raises(FileNotFoundError) as exc: + t.tar_files() + + assert exc.match("No such file or directory:") diff --git a/tests/test_fls/main.fls b/tests/test_fls/main.fls new file mode 100644 index 0000000..1b13fdf --- /dev/null +++ b/tests/test_fls/main.fls @@ -0,0 +1,72 @@ +PWD /home/badshah/Utilities/tartex/tests/test_fls +INPUT /etc/texmf/web2c/texmf.cnf +INPUT /usr/share/texmf/web2c/texmf.cnf +INPUT /var/lib/texmf/web2c/pdftex/pdflatex.fmt +INPUT main.tex +OUTPUT main.log +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/article.cls +INPUT /usr/share/texmf/tex/latex/base/size11.clo +INPUT /usr/share/texmf/tex/latex/base/size11.clo +INPUT /usr/share/texmf/tex/latex/base/size11.clo +INPUT /usr/share/texmf/tex/latex/base/size11.clo +INPUT /usr/share/texmf/fonts/map/fontname/texfonts.map +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr10.tfm +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT /usr/share/texmf/tex/latex/l3backend/l3backend-pdftex.def +INPUT ./main.aux +INPUT main.aux +INPUT main.aux +OUTPUT main.aux +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr17.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr12.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr8.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr6.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmmi12.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmmi8.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmmi6.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmsy10.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmsy8.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmsy6.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmr12.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmbx12.tfm +INPUT ./main.toc +INPUT main.toc +INPUT main.toc +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmbx10.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmmi10.tfm +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmsy10.tfm +OUTPUT main.toc +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmbx12.tfm +INPUT ./main.bbl +INPUT main.bbl +INPUT ./main.bbl +INPUT main.bbl +INPUT /usr/share/texmf/fonts/tfm/public/cm/cmti10.tfm +OUTPUT main.pdf +INPUT /var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map +INPUT main.aux +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmbx10.pfb +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmbx12.pfb +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmr10.pfb +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmr12.pfb +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmr17.pfb +INPUT /usr/share/texmf/fonts/type1/public/amsfonts/cm/cmti10.pfb diff --git a/tests/test_fls/main.tex b/tests/test_fls/main.tex new file mode 100644 index 0000000..39449f7 --- /dev/null +++ b/tests/test_fls/main.tex @@ -0,0 +1,19 @@ +\documentclass[11pt,a4paper]{article} + +\author{No Author} +\title{Test bib} +\date{\today} +\begin{document} +\maketitle +\tableofcontents + +\section{Only Section} + +This is a test document with a single citation \cite{testarticle}. + +\subsection{Empty subsection} + +\bibliographystyle{plain} +\bibliography{refs} + +\end{document} diff --git a/tests/test_fls/refs.bib b/tests/test_fls/refs.bib new file mode 100644 index 0000000..75e46ea --- /dev/null +++ b/tests/test_fls/refs.bib @@ -0,0 +1,8 @@ +@ARTICLE{testarticle, + author = {No Name}, + title = {No Title}, + journal = {No Journal}, + year = {2024}, + otherinfo = {Purely for testing} +} +