Skip to content

Commit

Permalink
Test extraction for a jobname containing spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
sasozivanovic committed Dec 6, 2023
1 parent 471c644 commit 1182edf
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 12 deletions.
1 change: 1 addition & 0 deletions testing/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/build
/temp
!/expected/**
*~
47 changes: 35 additions & 12 deletions testing/MakeTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def Test(targets, deps, title = '', remark = '', work_dirs = ('test', 'tmp')):
print('Up to date.')
else:
for d in work_dirs:
recursive_chmod('+w', d)
shutil.rmtree(d, ignore_errors = True)
if Path(d).exists():
recursive_chmod('+w', d)
shutil.rmtree(d, ignore_errors = True)
Path(d).mkdir(parents = True, exist_ok = True)
yield TestData(targets, deps, work_dirs)
Path(targets[0]).touch()
Expand Down Expand Up @@ -159,24 +160,37 @@ def rm(*files):
'Compiling sources', work_dirs = ['build/nomemodir']):
cp('src/nomemodir/doc.tex', 'build/nomemodir')
assert run('pdflatex -interaction batchmode doc'.split(), cwd = 'build/nomemodir')
assert diff('{expected/nomemodir,build/nomemodir}/doc.mmz')
assert diff('{expected/nomemodir,build/nomemodir}/doc.799CD96D5634EBEB7E30191285AF4082.memo')
assert diff('{expected/nomemodir,build/nomemodir}/doc.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected/nomemodir,build/nomemodir}/doc.7DBC7B29C0C49BCFD5C4A18740E06E80.memo')
assert diff('{expected/nomemodir,build/nomemodir}/doc.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected,build}/nomemodir/doc.mmz')
assert diff('{expected,build}/nomemodir/doc.799CD96D5634EBEB7E30191285AF4082.memo')
assert diff('{expected,build}/nomemodir/doc.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected,build}/nomemodir/doc.7DBC7B29C0C49BCFD5C4A18740E06E80.memo')
assert diff('{expected,build}/nomemodir/doc.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')


for test in Test(['memodir', 'build/memodir/doc.pdf'], ['src/memodir/doc.tex'],
'Compiling sources', work_dirs = ['build/memodir']):
cp('src/memodir/doc.tex', 'build/memodir')
assert run('pdflatex -interaction batchmode doc'.split(), cwd = 'build/memodir')
assert diff('{expected/memodir,build/memodir}/doc.mmz')
assert diff('{expected/memodir,build/memodir}/doc.memo.dir/799CD96D5634EBEB7E30191285AF4082.memo')
assert diff('{expected/memodir,build/memodir}/doc.memo.dir/799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected/memodir,build/memodir}/doc.memo.dir/7DBC7B29C0C49BCFD5C4A18740E06E80.memo')
assert diff('{expected/memodir,build/memodir}/doc.memo.dir/7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected,build}/memodir/doc.mmz')
assert diff('{expected,build}/memodir/doc.memo.dir/799CD96D5634EBEB7E30191285AF4082.memo')
assert diff('{expected,build}/memodir/doc.memo.dir/799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected,build}/memodir/doc.memo.dir/7DBC7B29C0C49BCFD5C4A18740E06E80.memo')
assert diff('{expected,build}/memodir/doc.memo.dir/7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')


for test in Test(['memodir with spaces', 'build/memodir with spaces/doc with spaces.pdf'],
['src/memodir with spaces/doc with spaces.tex'],
'Compiling sources', work_dirs = ['build/memodir with spaces']):
cp('src/memodir with spaces/doc with spaces.tex', 'build/memodir with spaces')
assert run('pdflatex -interaction batchmode'.split() + ['doc with spaces'],
cwd = 'build/memodir with spaces')
assert diff('{expected,build}/memodir with spaces/doc with spaces.mmz')
assert diff('{expected,build}/memodir with spaces/doc with spaces.memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082.memo')
assert diff('{expected,build}/memodir with spaces/doc with spaces.memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')
assert diff('{expected,build}/memodir with spaces/doc with spaces.memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80.memo')
assert diff('{expected,build}/memodir with spaces/doc with spaces.memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo')


for pyl in ('py', 'pl'):
inexisting_absolute = ('C:\\' if platform.system() == 'Windows' else '/') + 'inexisting'

Expand All @@ -200,6 +214,15 @@ def rm(*files):
assert exists('test/doc.memo.dir/7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf')


for test in Test([f'extract-memodir-with-spaces.{pyl}'],
[f'memoize-extract.{pyl}', f'build/memodir with spaces/doc with spaces.pdf'],
'Extract from a [memodir] document with spaces in paths'):
cp('build/memodir with spaces', 'test')
assert run([f'memoize-extract.{pyl}', 'doc with spaces.mmz'], cwd = 'test')
assert diff('expected/extract-memodir-with-spaces/doc with spaces.mmz', 'test/doc with spaces.mmz')
assert exists('test/doc with spaces.memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf')
assert exists('test/doc with spaces.memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf')

for test in Test([f'extract-from-subdir.{pyl}'],
[f'memoize-extract.{pyl}', f'build/nomemodir/doc.pdf'],
".mmz in a parent directory without -k"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\mmzPrefix {"doc with spaces".memo.dir/prefix with spaces.}
\mmzNewCMemo {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80.memo}
\mmzNewCCMemo {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo}
%\mmzNewExtern {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}{1}{172.06781pt}{150.69077pt}
\mmzNewCMemo {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082.memo}
\mmzNewCCMemo {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo}
%\mmzNewExtern {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}{2}{208.76233pt}{151.48442pt}
\endinput
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\mmzResource{prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}%
\mmzMemo
\quitvmode \mmzIncludeExtern {0}\hbox {64.22235pt}{6.94444pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}%
\mmzEndMemo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\mmzMemo
\global \mmzContextExtra {}%
%
\mmzSource
another extern
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\mmzResource{prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}%
\mmzMemo
\quitvmode \mmzIncludeExtern {0}\hbox {27.52783pt}{6.15079pt}{0.0pt}{72.26999pt}{72.26999pt}{72.26999pt}{72.26999pt}%
\mmzEndMemo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\mmzMemo
\global \mmzContextExtra {}%
%
\mmzSource
extern
8 changes: 8 additions & 0 deletions testing/expected/memodir with spaces/doc with spaces.mmz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\mmzPrefix {"doc with spaces".memo.dir/prefix with spaces.}
\mmzNewCMemo {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80.memo}
\mmzNewCCMemo {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo}
\mmzNewExtern {"doc with spaces".memo.dir/prefix with spaces.7DBC7B29C0C49BCFD5C4A18740E06E80-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}{1}{172.06781pt}{150.69077pt}
\mmzNewCMemo {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082.memo}
\mmzNewCCMemo {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.memo}
\mmzNewExtern {"doc with spaces".memo.dir/prefix with spaces.799CD96D5634EBEB7E30191285AF4082-E778DCCCB8AAB0BBD3F6CFEEFD2421F8.pdf}{2}{208.76233pt}{151.48442pt}
\endinput
23 changes: 23 additions & 0 deletions testing/src/memodir with spaces/doc with spaces.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
\documentclass{article}

\usepackage[
prefix=\jobname.memo.dir/prefix with spaces.,
recompile,
extract=no,
mkdir command=memoize-extract.py --mkdir,
]{memoize}

\begin{document}

This \mmz{extern} will be extracted into directory
\texttt{\string\jobname.memo.dir}.

This is \mmz{another extern} which will be extracted into folder
\texttt{\string\jobname.memo.dir}.

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

0 comments on commit 1182edf

Please sign in to comment.