Commit Graph

26 Commits

Author SHA1 Message Date
Alex Hoppen
8ec8516893 Remove ByteTree serialization format
It was originally designed for faster trasmission of syntax trees from
C++ to SwiftSyntax, but superceded by the CLibParseActions. There's no
deserializer for it anymore, so let's just remove it.
2021-01-14 20:37:49 +01:00
Saleem Abdulrasool
1b6f377a1f test: restore Windows compatibility
The subprocess handling on Windows requires bytes-like objects rather
than strings.  Ensure that we don't convert on Windows.
2020-07-31 17:32:01 -07:00
Saleem Abdulrasool
fc8f4b7108 Update test_util.py
Appease python linter
2020-07-31 11:57:27 -07:00
Saleem Abdulrasool
162c5e1bc7 test: explicitly encode arguments for Python 3
The argument handling for `subprocess.check_output` differs between
Python 2.7, [3.0, 3.6], [3.7).

With Python 2.7, the list is implicitly decoded and we cannot use the
`encode` method as it will attempt to decode it as ASCII which will fail
with unicode data.

Python [3.0, 3.6] will attempt to encode the arguments before executing,
but will do so based on the system locale.  In the case that the locale
is `POSIX`, the encoding will be attempted in ASCII, which again fails
when unicode data is used.

Python [3.7) will accept the encoded strings and pass them through.  It
will implicitly encode the arguments using the file system encoding
(normally UTF-8), which will allow it to actually work with the content
encoded or decoded.

In order to provide maximal compatibility, pre-encode the arguments as
UTF-8 when using python 3.  Rely on the interpreter encoding the
argument implicitly on Python 2.  This allows running the
incrParse.simple test with python 2.7, python 3.6, python 3.7, python
3.8 with `LC_ALL=POSIX` as is the default on Ubuntu Server.

Thanks to @tbkka for the details on how to reproduce this issue and the
help with the python conversion!
2020-07-31 15:51:49 +00:00
Saleem Abdulrasool
09ee4a60b1 Update test_util.py
Appease the python linter.
2020-07-09 10:54:56 -07:00
Saleem Abdulrasool
6f97c7a2fb test: make test_util more python 3 friendly
The last set of changes to make it backwards compatible with Python 2
required converting the arguments.  That is not compatible on Python 3
unfortunately.  Only perform that on Python 2 to make the utility
compatible with 2 and 3.
2020-07-09 08:28:44 -07:00
Saleem Abdulrasool
c1ce8b6a67 Update test_util.py
Appease the python linter
2020-07-08 12:51:24 -07:00
Saleem Abdulrasool
2fad0259b6 test: make test_util more Python 3 friendly
This uses `io.open` to allow `test_util` to open with the encoding and
newline handling across python 2 and python 3.  With this change, the
test suite failures are within the single digits locally.
2020-07-07 15:18:36 -07:00
Saleem Abdulrasool
58d0cbcaea Update validate_parse.py
Attempt to appease the python linter
2020-07-03 12:41:47 -07:00
Saleem Abdulrasool
3ed6c994d2 test: make validate_parse more python3 friendly
Use `io.open` to open the files with the correct encoding and to allow
proper newline specification.  This allows the script to be python 2 and
python 3 compatible.
2020-07-02 12:47:27 -07:00
Argyrios Kyrtzidis
bea79d48c1 Fix python lint issue 2020-03-18 17:14:05 -07:00
Argyrios Kyrtzidis
1882b50555 [libSyntax] Enhance incremental re-parsing testing to also check whether unexpected diagnostics were emitted
Enhances `swift-syntax-test` to output the parser diagnostics so we can verify that
if the incremental parse resulted in parser diagnostics, those diagnostics were also emitted during the full parse.
2020-03-18 11:52:21 -07:00
Saleem Abdulrasool
ff7b2fb720 test: make incrParse tests pass on Win32
Use `w+b` mode for the files to avoid EOL style conversions on Windows.
2019-01-28 21:58:43 -08:00
Argyrios Kyrtzidis
8f4bb24dd1 [utils/incrparse] Fix python-lint issues 2019-01-09 22:36:48 -08:00
Argyrios Kyrtzidis
1dc288fb23 Introduce C parser library
Add a shared library with a C API that provides access to the syntactic parser with callbacks for the inference of raw syntax nodes.
This is primarily intended to be used by SwiftSyntax to speed-up source code parsing for it.
2019-01-09 18:30:45 -08:00
Argyrios Kyrtzidis
aba7fa1f15 [utils/incrparse] Introduce testWithParserLib() helper function
This is to allow swift-syntax to run its lit tests without needing to execute swift-syntax-test
for incremental reparsing.
2019-01-07 22:41:34 -08:00
Saleem Abdulrasool
0f0098265c incrparse: move include to top
Address feedback from ahoppen.  NFC.
2018-12-04 19:46:03 -08:00
Saleem Abdulrasool
2793b64491 incrparse: use python to diff rather than diff
Use the python library `difflib` which is part of a standard python
installation to generate the diff.  This allows us to run the tool on
Windows wihtout needing external tools installed.
2018-12-04 13:26:52 -08:00
Pavol Vaskovic
53cd115b0e [Gardening] Fix W291 trailing whitespace 2018-11-28 16:57:23 +01:00
Nathan Hawes
efa2c5475d [incrParse] Update text-util.py to handle multiple edits and reparse ranges on the same line
It wasn't accounting for the prefix length before a reparse tag previously when
keeping track of pre_column_offset and post_column_offset.
2018-10-11 14:31:32 -07:00
Alex Hoppen
5c44da5313 [incrParse] Rename swift-swiftsyntax-test to swiftsyntax-lit-test-helper 2018-08-30 11:46:23 -07:00
Alex Hoppen
da7cdbb122 [libSyntax] Add test cases for ByteTree serialization and deserialization 2018-08-21 10:55:15 -07:00
Xi Ge
571b29b64f SwiftSyntaxTest: refactor command-line argument parsing into a test utility module. NFC (#18418) 2018-07-31 17:05:47 -07:00
Alex Hoppen
52acc04fa7 [libSyntax] Add test case to match the incrementally transferred syntax tree 2018-07-25 09:58:53 -07:00
Alex Hoppen
d926b74836 [incrParse] Add test cases to test the incremental syntax tree transfer 2018-07-24 16:32:23 -07:00
Alex Hoppen
d9d5afd15a [incrParse] Refactor the test utility to be more modular
This way we can use the same core of the test utility to verify
round-tripness of incrementally transferring the syntax tree to
swiftSyntax.
2018-07-19 14:47:58 -07:00