On Fri, May 7, 2021 at 1:01 AM Elijah Newren <newren@xxxxxxxxx> wrote: > On Thu, May 6, 2021 at 9:27 PM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > > Is this expensive/slow loop needed because you'd otherwise run afoul > > of command-line length limits on some platforms if you tried creating > > the entire mess of directories with a single `mkdir -p`? > > The whole point is creating a path long enough that it runs afoul of > limits, yes. > > If we had an alternative way to check whether dir.c actually recursed > into a directory, then I could dispense with this and just have a > single directory (and it could be named a single character long for > that matter too), but I don't know of a good way to do that. (Some > possiibilities I considered along that route are mentioned at > https://lore.kernel.org/git/CABPp-BF3e+MWQAGb6ER7d5jqjcV=kYqQ2stM_oDyaqvonPPPSw@xxxxxxxxxxxxxx/) Thanks, I read that exchange (of course) immediately after sending the above question. > > > + while test ! -f directory-random-file.txt; do > > > + name=$(ls -d directory*) && > > > + mv $name/* . && > > > + rmdir $name > > > + done > > > > Shouldn't this cleanup loop be under the control of > > test_when_finished() to ensure it is invoked regardless of how the > > test exits? > > I thought about that, but if the test fails, it seems nicer to leave > everything behind so it can be inspected. It's similar to test_done, > which will only delete the $TRASH_DIRECTORY if all the tests passed. > So no, I don't think this should be under the control of > test_when_finished. I may be confused, but I'm not following this reasoning. If you're using `-i` to debug a failure within the test, then the test_when_finished() cleanup actions won't be triggered anyhow (they're suppressed by `-i`), so everything will be left behind as desired. The problem with not placing this under control of test_when_finished() is that, if something in the test proper does break, after the "test failed" message, you'll get the undesirable alpine-linux-musl behavior you explained in your earlier email where test_done() bombs out.