[Work in progress] Command line tool refactor to run tests #241
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This PR is work in progress.
This PR is for refactoring the command line too (Launcher) to add the
xtc
command so that we can run tests usingxtc test
and add flexibility to be able to easily add other sub-commands toxtc
.The code in the PR introduces a new "command" framework to add a hierarchical command structure, where commands can have sub-commands, which could have more sub-commands and so on. For example,
xtc
is a command that has a sub-commandtest
so on the command line it is executed usingxtc test <flags...>
The PR also introduces code to represent command line flags. The
FlagSet
represents a set of flags parsed from the command line. Each command has a set of valid flags. EachFlag
in aFlagSet
is types, for example a boolean flag, string flag, etc. Flags and parsing aFlagSet
is posix compliant. Each flag must have a long name (which is used prefixed with--
on the command line. Optionally a Flag can have a single character shortcut (used prefixed with a-
on the command line). Single characters can be concatenated on the command line (e.g.-abc
is the same as-a -b -c
)Running Ecstasy Tests
The PR also add a simple test executor to make the
xtc test
command work. No-arg methods annotated with@Test
will be executed in a module that importsxunit
.The
FizzBuzz
module undermanualTests
has had tests added to it.If you build the local distribution, for example:
Then export
XDK_HOME
to point to the distribution (e.g. on my Arm Mac)Then build
FizzBuzz
and test itwhich should print something like...
Individual tests can be executed using the
--test
(or-t
) flag forxtc test
. The--test
flag can be used multiple times.The format of the value for the
--test
flag is<class-name>#<method-name>
where<class-name>
and<method-name>
can be exact name or a sort of reg-ex pattern. Any dot '.' character in the pattern will match a dot in the test name, so not the same ad dot in a normal regex. A star*
in the pattern is the same as(.*)
in a normal reg-ex.Either the class name or method name may be omitted, so
<class-name>
or#<method-name>
are also valid.If the value passed to the
--test
flag starts with a!
then matches to the filter will be excluded from the run. If a test matches both an include and and exclude filter, the include takes precedence.For example:
To execute all tests in the class
TestFizzBuzz
To execute the test shouldBeBuzz in class
TestFizzBuzz
To execute all tests methods containing
Fizz
To execute the test shouldBeBuzz in any class
To NOT execute the test shouldBeBuzz in class
TestFizzBuzz
prefix the pattern with the "!" character