Open mtmiller opened 5 years ago
This should be doable. I'm already abbreviating the paths for files that are discovered under the Octave installation or under installed pkg
packages. I could extend that for user-supplied paths.
I'd even say this should maybe be the default behavior, and not require an explicit -prefix
option from the user?
Runtests2 accepts multiple paths as arguments. It could do some combination of the following:
a) When only a single path argument is given, display all the file paths as relative to that directory, like in your inst/foo.m.....
example.
b) If multiple path arguments are given, find some common prefix and use that? Or include just the last element of the path in each argument, instead of the full path?
c) Check the filesystem and see if the test files exist under a pkg
-structured Octave package layout (based on a DESCRIPTION
file and inst
directory); if so, display them relative to that package directory, using the package name as the abbreviation for it.
This gets more complicated when:
cd
'ed into a subdirectory of a large package, and run tests on just that subdir. In that case, it would probably be better to display the path relative to the package root directory, and not your current subdirqualified.namespace.name
) and it discovers tests under there, it may not be readily apparent where those tests were found. In those cases, probably it should display either the full path, or a path relative to some hopefully-unambiguous abbreviation that would indicate where they were found.I'd even say this should maybe be the default behavior, and not require an explicit
-prefix
option from the user?
Sure, that would be easiest on the user.
You might even want to have a format similar to doctest
, which prints indented recursive output that looks like this by default
>> doctest .
inst/
func1.m .............................................. PASS 1/1
func2.m .............................................. PASS 1/1
...
src/
defun1.oct ........................................... PASS 1/1
defun2.oct ........................................... PASS 1/1
...
>> doctest /path/to/proj
/path/to/proj/
inst/
func1.m ............................................ PASS 1/1
func2.m ............................................ PASS 1/1
...
src/
defun1.oct ......................................... PASS 1/1
defun2.oct ......................................... PASS 1/1
...
I could see the argument for showing a path relative to the package top-level directory even if you're in a subdirectory. Similar to how git diff
shows the file name relative to the project root I suppose.
But for me the most important thing is removing the root directory, and whether that's done relative to the working dir, the argument dir, the package top dir, or an extra argument is details.
Current output
It would be nice to have an option to strip a common prefix from all file names. This would only be for the console output, the full output in the optional log file can keep the full file name. Or it can apply the filter to both if it's preferable to be consistent.
Example desired output
Option name ideas include base, elide, prefix, root, strip, or some combination of those. GNU utilities like patch and tar refer to it as "stripping" file name "components", git archive adds a "prefix" to relative file names, gcc also uses the term "prefix".