40 Commits

Author SHA1 Message Date
Pierre-Marie de Rodat
b950d445c9 Testsuite: decorrelate Python distribs for e3-testsuite and Langkit
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.
2026-02-02 11:25:47 +00:00
Pierre-Marie de Rodat
f72a0a3d5d misc/file_reader: fix output canonicalization on Windows
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.
2025-05-13 15:26:17 +00:00
Pierre-Marie de Rodat
c40bb4ab8a Langkit_Support.File_Readers: add support for file stubbing
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.
2025-04-22 15:30:06 +00:00
Pierre-Marie de Rodat
6cefc74c93 Set up pre-commit checks and reformat the Python sources with black 2025-03-26 14:04:20 +00:00
Pierre-Marie de Rodat
4bae239699 Testsuite: rework obsolete output refiners
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.
2025-02-17 12:02:08 +01:00
Pierre-Marie de Rodat
7bfbc5dc8f Move contrib/lkt to lkt 2025-02-06 09:31:49 +00:00
Pierre-Marie de Rodat
389d78a6e7 langkit.config: introduce JSON deserialization
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.
2025-01-07 15:09:51 +00:00
Pierre-Marie de Rodat
13378a252b Testsuite: adapt Python traceback collapser for Python 3.13
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.
2024-12-03 14:01:54 +00:00
Pierre-Marie de Rodat
636c6b9bf3 Unparsing: fix the handling of non-UTF-8 sources in the unparse main
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).
2024-11-28 14:47:19 +00:00
Pierre-Marie de Rodat
ce476fdb8a Unparsing: add auto-check to the unparsing main 2024-11-27 09:27:42 +00:00
Pierre-Marie de Rodat
f9326d1ffe Unparsing: add an option to complain when a node config is missing 2024-11-20 09:31:16 +00:00
Pierre-Marie de Rodat
8cfcffd96a Rehaul the handling of optional passes
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.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
d3df67b642 Let language specs enable case insensitivity with a lexer annotation
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.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
9514b56cf6 Let language specs enable unparsers with a grammar annotation
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.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
e1c4fe5804 Introduce the lkt_build_and_run test driver
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.
2024-10-15 14:13:10 +00:00
Pierre-Marie de Rodat
dcd469d783 Unparsing: make the config file argument optional for the unparsing main 2024-08-21 15:44:53 +00:00
Pierre-Marie de Rodat
4d4960ff34 Testsuite: fix lkt_unparse tests for Valgrind runs on x86-linux 2024-07-23 20:38:50 +00:00
Pierre-Marie de Rodat
3bc64dd70f Lkt: add a default unparsing configuration
Also add a test driver and a bunch of testcases to exercise it.
2024-07-22 11:37:38 +00:00
Pierre-Marie de Rodat
a1ae4d9cda properties/warn_public_doc: transition to the lkt_compile driver 2023-12-13 13:36:33 +00:00
Pierre-Marie de Rodat
2f0f07acbe lkt_compile driver: add support to run post-compilation test.py scripts
Some test will use this script to perform arbitrary checks on the result
of the compilation.
2023-12-13 13:36:32 +00:00
Romain Beguet
add1137dd8 Allow factorizing common code in Java bindings tests. 2023-06-21 11:49:07 +02:00
Pierre-Marie de Rodat
d4fb87f1b6 Testsuite: add an output refiner for Python tracebacks
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
2023-03-14 10:48:38 +00:00
Pierre-Marie de Rodat
c6adec40a2 Python API: bind the event handler API
TN: VA12-016
2022-11-23 12:37:21 +00:00
Pierre-Marie de Rodat
fa79e76f46 Testsuite: create a new "lkt_compile" test driver
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
2022-06-08 12:24:31 +00:00
Pierre-Marie de Rodat
bb34e95df2 Lkt: fix the lexing of doc comments
TN: V112-051
2022-05-23 14:19:04 +00:00