Rtest not finding tests which it was finding before

I used to run ./rtest.py wh* and it would run all the tests which start with “wh”; but now when I do that, it reports that it ran 0 tests. I haven’t changed anything in the tests. What’s going on?

I had created a folder which also happens to start with “wh” in the directory in which rtest.py resides. This actually breaks things; rtest.py assumes that there is no rogue folders in its directory whose names clash with regression test names.

(Perhaps we could make it more robust at some point).

This isn’t something that rtest can be fixed for (well, see below). It’s part of the bash shell. When you use a * in bash arguments, it expands to all paths that match the pattern. If no such paths match, the original * character is passed as an argument to the command. As you’ve discovered, you now have a path starting with wh so wh* matches that path, whereas before it didn’t. Since rtest uses the asterisks to flexibly match tests via fnmatch, things break if the asterisks are expanded by bash.

The solution is to either escape the asterisk so bash won’t expand it: wh\*; alternatively, you can quote it: 'wh*'. I suggest always doing this when you want to pass an actual asterisk as an argument.

A solution where we alter rtest is to not use *, ?, or anything that bash expands. We would then need to replace it in rtest so fnmatch works again, or write our own path matching routine. I don’t recommend this route since we’d be doing more work (more room for bugs) with something unconventional while the other solution (escaping or quoting) is well defined and conventional (if non-obvious the first time you encounter it).

1 Like