Closed zerbina closed 3 weeks ago
Replacing the current runners with phy --tester
would reduce code duplication (the pass10
- pass1
test runners are slightly adjusted copies of each other), though it also has the downside of introducing some per-test overhead, which could be a problem in practice. It's worth trying out, I think.
@saem: I did consider embedding (i.e., importing the module) phy
into the runners, but there's a problem with this approach: for every runner, all passes and their satellite modules would be recompiled, instead of only the parts needed by the runners (which is how it works at the moment).
What I have in mind is to add a feature to the tester where, in addition to the current dedicated programs, a directory can specify a generic command for running the tests. For example, the expr
tests would use the following command bin/phy --source:source --target:vm --runner r $file
. This approach has the benefit that the phy
executable can be compiled once and then be reused for all pass tests.
Since creating the PR, I've also measured how long the command line processing takes for phy --source:L10 --target:vm --runner c file
on my machine (where phy
was compiled in debug mode with --opt:speed
), and it's ~0.015 milliseconds. For comparison, compiling phy.nim
without the command line processing and with an empty compilation cache takes ~14.5 seconds. I think it's quite safe to say that we won't reach the amount of tests per runner for embedding the phy
module into runners to ever amortize.
Summary
Bundle the passes,
source2il
, the assembler, and the VM into a single CLI application. The idea with it is to help with development, by providing a convenient way to invoke the passes/VM/etc. and inspect the (intermediate) output.Details
The
phy
program provides a small command line interface for specifying the source and target language are, what IRs to print, and what to do (only compile or also evaluate).Much of the implementation is copied from the various test runner:
source2il
invocation and comes from theexpr
test runnerpass0
test runner (intovmexec.nim
)The program also provides the
--runner
option, which makes it behave in a way such that it's suitable as being used as a test runner, by lifting some input restrictions and altering the output formatting, so that it can maybe replace the currently used custom test runners at some point.