Introduce the testsuite `--with-langkit-python` option so that it is
possible to have:
* one interpreter with the e3 distribution (to run the testsuite),
* one interpreter with Langkit installed (to run lkm and the various
scripts using Langkit modules),
* one bare interpreter to import Langkit-generated libraries.
Avoid calling `Format_GNU_Diagnostics` in the main program so that
backslashes are not escaped in the output, so that working directory
substitution works as expected on Windows. In addition, canonicalize
directory separators so that the test output is the same on Windows and
Unix systems.
Add data types and primitives to create a file fetcher that is based on
the filesystem plus stubs, i.e. a mapping from filenames to file
contents, so that it is possible to pretend a file exists/has changed
without writing on the filesystem.
Now that the Python DSL is gone, must line number hiding is
counter-productive: Python line numbers are not expected to show up in
test outputs in the general case, and hiding them hindes debugging when
there is a Python crash in a testcase. Rework the corresponding output
refiners so that this is done only when actually needed.
Also rework lkt_compile and lkt_build_and_run test drivers so that the
language spec configuration bits are stored in the testcase's test.yaml
file directly: no need to add glue code in various places (test driver,
lkt_compile.py/lkt_build_and_run.py scripts) to support a new kind of
language spec configuration.
Starting with Python 3.13, traceback entries may contain more than a
single line of quoted code:
File "...", line ..., in ...
some_multi_line_fn_call(
~~~~~~~~~~~~~~~~~~~~~~~^
arg1,
^^^^^
arg2,
^^^^^
...<X lines>...
argN,
^^^^^
)
^
Adapt the testuite's Python traceback collapsing code accordingly.
Add a --charset argument that the unparse main uses to decode the source
files to reformat, and to encode the reformatted content. Also enhance
the lkt_build_and_run driver so that it can run mains with heterogeneous
encodings (one that outputs UTF-8 and another that outputs ISO-8859-1,
for instance).
Rework the formatting for the listing of optional passes, refactor the
handling of --pass-on/--pass-off (to enable/disable optional passes), fix
a couple of crashes and add a testcase to exercise this little used part
of Langkit.
Whether or not case insensitivity should be enabled is tied to the
language itself, so this setting belongs to the language specification
better than to a CompileCtx argument.
Whether unparsers are generated or not has implications on legality
checks for the grammar, so it makes sense for this to be a property of
the grammar itself: introduce an Lkt annotation as well as a
langkit.parsers.Grammar argument for it, and remove the corresponding
CompileCtx argument.
Also rename "generate_unparser" to "generate_unparsers" for consistency
across the codebase.
Transition all relevant testcases to it. In the process, port
docstrings/comments from test.py files to expected_concrete_syntax.lkt
(now test.lkt) sources and fix stylechecks issues there.
Depending on the Python interpreter version that is used to exercise
generated libraries, the line number, and thus the quoted line of source
code that is present in baselines can vary. Introduce an output refiner
to hide these discrepancies and use them in tests where it is relevant.
TN: W306-034
All tests which just check the presence/absence of errors when compiling
Lkt language specs have the same "test.py" script: put a reference
script in "python_support", create a new test driver to let tests use
it easily and migrate relevant tests to it.
For GitHub issue #622