Avoid any potential false positives resulting from rdmd_test being
accidentally built with -release.
Avoiding this situation is paramount, with the alternative being a
clunky runtime test to detect that rdmd_test was built with -release,
so this solution is preferable, even considering the semantic loss of
the distinction between assert/enforce and their existing usage.
Avoid using the default -O -release build flags when running the test
suite, and enable debug info generation instead, to ensure asserts are
enabled and meaningful stack traces are produced on failure.
Windows uses backslashes for string separators, which are rendered as
escaped in rdmd's --chatty output. Mirror this behavior to correctly
run this test on Windows, as well as other situations when the path
contains characters that would be escaped by std.format's "DSON"
formatting.
Use an empty file (instead of one containing a dummy string) to avoid
a GUI pop-up, which would otherwise need to be dismissed by an
interactive user. An empty file will just cause a "%s is not a valid
Win32 application" exception, which is similar enough to the Posix
behavior and handled properly by rdmd and the test suite.
Fixes some tests using the wrong model.
Also fixes running the test suite for DMD configurations supporting
just one model, which is not the default DMD model (e.g. those built
by Digger on Windows).
By checking only `value[0]`, the `dashOh` callback used to parse `-o...`
flags would give false positives (e.g. for `-o-foo` or `-opbar`). This
patch fixes the discrepancy by requiring exact comparison to `value`.
A few test cases have been added to `rdmd_test` to cover these failures.
Thanks to @CyberShadow for spotting the bug and proposing the fix.
This fixes a discrepancy between `rdmd` and `dmd` in terms of the output
flags they support: `dmd` now requests `-of=...` and `-od=...` in help
output but still supports the old `-of...` and `-od...` style, while
`rdmd` was still supporting only the older variant.
Thanks to @CyberShadow for suggesting the `skipOver`-based solution.
Extra test cases have been added to `rdmd_test` to cover this, although
the way this has been done is a little bit cheeky (it turns out the only
place where `-of` and `-od` are really tested rigorously is in tests for
the case where the output file is a library in a subdirectory). At some
point it would be a good idea to add some more rigorous test cases for
the `-o...` flags, but in the short term the tests added in this patch
should validate the changes to `rdmd` itself.
Since --rdmd is required, made it a "non-option" argument instead of an "option that is [REQUIRED]"
merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
Split compiler agnostic tests so they are only run once instead of once per compiler
merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
posix.mak, win32.mak: Ensure `clean` target removes all generated files and directories
merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
The `clean` target has been updated to remove the entire directory of
files generated by the build, together with all its contents. This
matches what is done in the dmd, druntime, and phobos makefiles, and
should be much more maintainable, since it no longer relies on correct
specification of all the individual files that need removing.
As a byproduct, this fixes an oversight in the old `clean` target which
meant that `rdmd_test.exe` was not being removed.
The `ROOT_OF_THEM_ALL` variable has been renamed to `GENERATED` to avoid
any nasty consequences for downstream users who might be overriding the
former in their build scripts.
The `clean` target has been updated to remove the entire directory of
files generated by the build, together with all its contents. This
matches what is done in the dmd, druntime, and phobos makefiles, and
should be much more maintainable, since it no longer relies on correct
specification of all the individual files that need removing.
As a byproduct, this fixes an oversight in the old `clean` target which
meant that `rdmd_test` and `tests_extractor` were not being removed.
The `ROOT_OF_THEM_ALL` variable has been renamed to `GENERATED` to avoid
any nasty consequences for downstream users who might be overriding the
former in their build scripts.
One key problem of the old `rdmd_test` was that it built its own rdmd
instance to test. This meant that technically, it was never actually
run against the rdmd executable generated in the regular tools build.
This rewrite fixes this by repurposing the `--rdmd` flag of `rdmd_test`
to require not a path to `rdmd.d` but a path to the rdmd executable for
which the test suite should be run. The provided executable is not used
directly, but is copied into a temporary directory: this is necessary in
order to run the fallback test, which involves copying a dummy compiler
into the same directory as the tested rdmd executable.
The `--compiler` flag has been removed (since `rdmd_test` no longer uses
it to build rdmd), but a new `--rdmd-default-compiler` flag is required
in order to specify the name of the default compiler for by the tested
rdmd. This is needed in order to carry out the fallback compiler test,
which will fail if the provided name does not match that of the default
compiler used by the rdmd executable.
The `test_rdmd` target in `posix.mak` has been reworked to use the new
`--rdmd` and `--rdmd-default-compiler` flags. By default these will be
invoked with the generated `rdmd` instance and the name of the compiler
used to build it, but these choices can be customized respectively with
the new `RDMD_TEST_EXECUTABLE` and `RDMD_TEST_DEFAULT_COMPILER` make
variables.
This should ensure that the rdmd instance generated by the regular build
is properly tested, while allowing `rdmd_test` to be used with arbitrary
`rdmd` instances if any developer should wish to do so.
Top-level module documentation has been tweaked to reflect the new flags
and intended usage, and help information has been added to the `getopt`
call, which will be output if the `-h|--help` flag is used, or if the
user fails to supply the required `--rdmd` or `--rdmd-default-compiler`
flags.
There is no need for `rdmd_test` to manually remove any pre-existing
`/tmp/rdmd_app_`, since we are going to overwrite it anyway, but it
is good housekeeping to clean it up on exit.
This is just a small piece of cleanup to group together all the various
make variables used with the `test_rdmd` target immediately prior to the
target itself, so they are easier to find and their purpose is easier to
understand.
It should help clarify that these variables are used only with tests and
do not impact application builds.