latex3 / l3build

A testing and building system for LaTeX
LaTeX Project Public License v1.3c
90 stars 17 forks source link

Error on renaming when `engine` contains `/` #391

Open mgkurtz opened 2 weeks ago

mgkurtz commented 2 weeks ago

I am currently adding some regression tests to pdfjam using l3build. Indeed this works pretty well and needs only those two lines in l3build.lua:

checkengines = {"engine"} -- small wrapper script to use `pdfjam` with `l3build`
pvtext = ".args" -- *.args files contain command line arguments for `pdfjam`

as long as engine lies in my search PATH.

I would like this to work as well, if I put engine in testfiles/support and use checkengines = {"./engine"}. Alas at several places in l3build-check.lua, we compute a file name using "." .. engine which leads to the error

mv: cannot move './build/result/demo.pdf' to './build/result/demo../engine.pdf': No such file or directory

This should be avoidable by always using "." .. basename(engine) instead of "." .. engine.

josephwright commented 2 days ago

The expectation here was that engines are always on the path, so there's no question of a basename - how do you run your tool manually for an arbitrary file in your setup otherwise? (As in, not one in your development dir but just some test file somewhere on your system.)

mgkurtz commented 1 day ago

how do you run your tool manually for an arbitrary file in your setup otherwise? (As in, not one in your development dir but just some test file somewhere on your system.)

Well, I can run l3build install to install pdfjam. Besides needing a symlink from ~/bin/pdfjam to $TEXMFHOME/scripts/pdfjam/pdfjam this works analogous to l3build install for usual LaTeX packages.

Besides that, my “engines” are wrappers (lying in testfiles/support) which I specifically wrote for testing only. So, I only ever call them as e.g. l3build check example5. The test files consist of command line arguments only. E.g. example5.jam:

--nup 2x3 --frame true --noautoscale false --delta "0.2cm 0.3cm" --scale 0.95 beamer.pdf

I just thought that changing this issue from broken to working by issuing a simple

sed -i 's/"\." \.\. engine/"." .. basename(engine)/g' l3build-check.lua

seems fair enough. But of course that adds to the overall code and if you estimate that no one else needs this, we can also leave that as is. For now, I just use os.setenv to add . to PATH:

-- Set PATH for `l3build check` and `l3build save`
target_list.check.pre = function(_)
    return os.setenv("PATH",  os.getenv("PATH") .. ":.") and 0 or 1
end
target_list.save.pre = target_list.check.pre

So, I am fine either way.