Commit Graph

106 Commits

Author SHA1 Message Date
Michael Hansen
f37caa8f2a Test runner refactor (#508)
* Port test runner script to Python.

This allows us to keep the test output in sorted order while still running the
tests in parallel.  It also now defaults to using the number of available CPU
threads for parallel execution, rather than the previously hard-coded default.

* Also port decompyle_test.sh script to python within run_tests.py

* Fix cmake check target for multi-config generators.

Adds testing of release builds on both MSVC and GCC.

* Fix diff comparisons on Windows

* Ubuntu runners don't have ninja by default
2024-08-08 15:55:35 -07:00
Michael Hansen
0b45b5fa07 Fix FORMAT_VALUE for values that have both a conversion and a format_spec.
Also output the conversion and flags in disassembly.
2024-08-01 13:28:43 -07:00
easyz
6ad3ceb67e Add support for swap bytecode and simple WITH_EXCEPT_START bytecode support. (#488)
* Modify .gitignore

* Added support for SWAP and WITH_EXCEPT_START, WITH_EXCEPT_START is simply added on top of SETUP_WITH_A so that it works properly.

* Resolve the warning about comparing size_t and int.

* Revert "Resolve the warning about comparing size_t and int."

This reverts commit 54dfe36629855ca557277572d307dacaf6a64fe9.

* Reapply "Resolve the warning about comparing size_t and int."

This reverts commit d21d1681ed6496856ea65151e5fd798f0a718416.

* Modify decompyle_test.sh

* Modify .gitignore

* Fix the logic error by placing the assignment inside the tuple

* Re-adding test files

* Fixing redundant brackets

* Add support for swap bytecode and simple WITH_EXCEPT_START bytecode support.

* Clean up some formatting issues

---------

Co-authored-by: Michael Hansen <zrax0111@gmail.com>
2024-06-23 11:59:30 -07:00
Michael Hansen
b9f3d145bb Merge pull request #490 from Levak/levak/tests-parallel
Run tests in parallel or only some with a filter
2024-06-23 11:49:06 -07:00
Michael Hansen
d10c47af1e Add some tests for #492 2024-06-23 11:36:20 -07:00
Levak Borok
d8f955d692 Run tests in parallel or only some with a filter
`make check JOBS=4` will spawn 4 workers and spread the tests among them.
`make check FILTER=try` will only run tests that contain `try` in their name.
2024-06-19 17:56:06 +02:00
MrDakik
ab80ec1d2c moved compiled tests of with stmt to xfail 2024-02-27 19:20:50 +02:00
MrDakik
e8be65b2f3 add support for WITH_CLEANUP_START,WITH_CLEANUP_FINISH 2024-02-27 10:54:07 +02:00
Michael Hansen
7559b782c1 Reindent test file 2024-02-26 14:27:20 -08:00
MrDakik
00d4b02d1e Added support for LOAD_CLASSDEREF
The opcode itself is exactly the same as `LOAD_DEREF`
1) The problem is when the class is a closure (e.g. defined inside a function body) then there is a `BUILD_TUPLE` after the `LOAD_BUILD_CLASS` which makes problems.
2) There is another problem which makes the `code->name()` of the class to be part of the function locals. (e.g. `func.<locals>.my_class` instead of `my_class`) which makes the check `srcString->isEqual(code->name().cast<PycObject>())` be invalid.
2024-02-26 16:52:31 +02:00
Michael Hansen
7929dbe6e0 Add test case for #437 2024-02-14 21:36:27 -08:00
Jack
5936412a6f fix #396 Unsupported Node type: 27 (#397)
* fix #396 Unsupported Node type: 27

* Add test file

* Modify a little comment

* Modify the test pyc file name

* Delete redundant pyc files

* retest

* Add newline at EOF

---------

Co-authored-by: Michael Hansen <zrax0111@gmail.com>
2023-11-11 10:22:49 -08:00
Michael Hansen
9b384ad1fa Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
TheHellTower
b32f231e33 Add GEN_START support (#392)
* Apparently should be enough ?

* Add `GEN_START` test

* Add `GEN_START` test compiled

* Add `GEN_START` test tokenized

* Smaller test since only POP is needed.

* Smaller test since only POP is needed.

* Smaller test since only POP is needed.

* dos2unix
2023-10-20 13:43:14 -07:00
MrDakik
da859f5a2b Added support for opcodes: (in DESC)
`KW_NAMES`
`POP_JUMP_FORWARD_IF_FALSE`
`POP_JUMP_FORWARD_IF_TRUE`
`LOAD_GLOBAL`
2023-07-18 18:33:03 +03:00
Michael Hansen
409f175827 Reduce code duplication for pre-3.11 binary ops, based on #348 2023-06-01 13:55:17 -07:00
Michael Hansen
90815b47ca Squash merge of #348
(Plus some whitespace cleanup)

commit ca302777438a6ac0ff00b9dbc87d2cf9e816b807
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 14:55:26 2023 -0400

    Test

commit 1764514e1dc4018abf050e2e2c3378b6ebaca2a2
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 14:46:49 2023 -0400

    Semi-Support

commit 104fa62355a18a071dae2d09db00af3b2fd22b6c
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 14:46:30 2023 -0400

    Semi-Support

commit 0809a71c725e3a92ece9348265f26f72fdb6664d
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 14:46:11 2023 -0400

    Semi-Support

commit bdf1695a57d2ad9eb1505a92ff4fa46c6f5ea90f
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 00:06:34 2023 -0400

    Updated Test

commit ea69a0b3be10568b70d02d744174e3bfc1d3546a
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 00:06:23 2023 -0400

    Updated Test

commit ecde2146208ea7a533267ace7293a49ce7a132bb
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Thu Jun 1 00:06:12 2023 -0400

    Updated Test

commit d5bbbe6224fc0aa8c5c3bc39b4f8845c8f941c7f
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 23:59:46 2023 -0400

    Feat: @zrax

    Co-authored-by: Michael Hansen <zrax0111@gmail.com>

commit f8d2299d14a3a0f69b40486006d629ccc5c719df
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 23:59:03 2023 -0400

    Feat: @zrax

    Co-authored-by: Michael Hansen <zrax0111@gmail.com>

commit 3fa8691f4c379dd10026227778ac60587fd07e68
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 23:58:53 2023 -0400

    Feat: @zrax

    Co-authored-by: Michael Hansen <zrax0111@gmail.com>

commit 6af17f0cffee31bc03ed8151e82b1720119d6a8d
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 23:58:45 2023 -0400

    Feat: @zrax

    Co-authored-by: Michael Hansen <zrax0111@gmail.com>

commit c7c76097fce1f45da0308b9f5e9cfffb5a323fd9
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 16:55:20 2023 -0400

    Remove `iostream`

commit 2edaec022f8cbcb36bffd7ec86b5f71b391fb372
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 16:54:48 2023 -0400

    Mistake

commit a36d4c5e62afe24691701f6d0b7c758b4113db91
Author: TheHellTower <thehelltower@tuta.io>
Date:   Wed May 31 16:52:12 2023 -0400

    Remove `iostream`

commit 1c3a5b02c95352a8e90247757df17d1563698fb6
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 16:43:30 2023 -0400

    Should be a bit better

commit 11603f1bb244c4d60ec34b675e1cd9c10945abf5
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 04:07:47 2023 -0400

    Update

commit 689b544fc1023ec60e4df257f3448064fdf84c2b
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 04:07:38 2023 -0400

    Update

commit 20bc5b820fb2ef6fd9199546e11ac02d78e5b6da
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 04:07:24 2023 -0400

    Update

commit c01e8251fac1577d25ab440ade4bfe2b42eb1860
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 04:05:28 2023 -0400

    Format problem ?

commit f35c494dd0d943323ec899cd8b2a236d11de67fc
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Wed May 31 04:02:03 2023 -0400

    Fix

commit 7f3265e4192e2b6eec81dc30a630691cead59694
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:57:01 2023 -0400

    BINARY_OP | Simplified

commit 045a6041f7a5abb7b5cdeaa4882b2620462e1927
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:56:53 2023 -0400

    BINARY_OP | Simplified

commit 0bfb76280e466e15c32ef42851d9981b9df57059
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:56:41 2023 -0400

    BINARY_OP | Simplified

commit 31159d69e8f802d7955244b258795563018c3eda
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:50:19 2023 -0400

    Fix Matching...

commit e4a978aeadebe9c574856c30928ec58da9e32639
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:50:06 2023 -0400

    Fix Matching...

commit d7a1b25b8f85886fcdc0a7c10c885e7e9e011281
Author: TheHellTower <thehelltower@tuta.io>
Date:   Mon May 29 00:41:43 2023 -0400

    Add `BINARY_OP` support

commit 6527299a67f043eb2b63e13ae43c4e9f060456e2
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:40:32 2023 -0400

    Add `BINARY_OP` test tokenized

commit c053cab7895f49a085a0797a98e28e87f4874d39
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:40:11 2023 -0400

    Add `BINARY_OP` test

commit e32f006f90a4e450099edd7d2f0bdbb0f1bbc612
Author: TheHellTower <dontbeshybuddy@gmail.com>
Date:   Mon May 29 00:39:53 2023 -0400

    Add `BINARY_OP` test compiled

Closes #333
Closes #348

Co-authored-by: TheHellTower <dontbeshybuddy@gmail.com>
2023-06-01 13:21:23 -07:00
TheHellTower
4d81a16638 Add PUSH_NULL, PRECALL_A, CALL_A support (#324)
* Add `PUSH_NULL`, `PRECALL_A`, `CALL_A` support

* feat: @zrax

Co-authored-by: Michael Hansen <zrax0111@gmail.com>

* Good suggested change to make the code shorter

* Add `PUSH_NULL`, `PRECALL`, `CALL` test tokenized

* Add `PUSH_NULL`, `PRECALL`, `CALL` test

* Add `PUSH_NULL`, `PRECALL`, `CALL` test compiled

* Delete push_null-precall-call.3.11.pyc

* Delete push_null-precall-call.py

* Delete push_null-precall-call.txt

* Update README.markdown

Blank commit to re-run the tests.

* Join all no-ops/"fake"-ops together

* Update ASTree.cpp

https://github.com/zrax/pycdc/pull/324#issuecomment-1449049283

* Add compiled test for #324

---------

Co-authored-by: Michael Hansen <zrax0111@gmail.com>
2023-02-28 15:48:33 -08:00
Michael Hansen
9f747e188c Add unit test for basic function calls (py3) 2023-02-27 11:59:01 -08:00
Michael Hansen
1fcbf4cd4b Keep PycSet objects marshalled from files in order too 2023-02-16 22:01:31 -08:00
Akash Munagala
66c46661d9 Add test 2023-02-12 17:01:37 -08:00
Michael Hansen
a6de2209fc Add simple_const tests for Python 3.8-3.11, and handle Python 3.11 RESUME opcode 2023-01-24 10:25:10 -08:00
TheHellTower
a3e5ebd481 Add GET_YIELD_FROM_ITER support (#312) 2023-01-19 10:51:08 -08:00
Adrian Haensler
5758634f81 support three digit versions in tests 2022-07-30 00:07:38 -05:00
Adrian Haensler
deebbb044d add a test 2022-07-30 00:02:47 -05:00
Michael Hansen
96ef91b5f9 Allow specifying an output filename on the command line, instead of forcing reliance on shell redirection.
Closes #31
2022-04-26 14:56:12 -07:00
Michael Hansen
4884b5447f Add additional versions of conditional_expressions test 2022-04-26 13:11:40 -07:00
Nenad Čaklović
38a1ee59c3 Support for conditonal expression (if-expression) - review findings 2022-04-02 13:57:10 +02:00
John Richards
25f44aa079 Adds support for CONTAINS_OP opcode
Mentioned in:
- #190
- #191
- #195
2021-10-10 00:40:39 -04:00
John Richards
588f24c872 Adds support for IS_OP opcode
Mentioned in:
- #190
- #191
- #195
2021-10-07 20:29:18 -04:00
John Richards
15f2a4013e Adds an extra test case 2021-10-07 02:02:00 -04:00
John Richards
a504452b7b Adds support for LIST_EXTEND opcode
Addresses #199
2021-10-07 01:51:53 -04:00
Michael Hansen
ac189cc916 Support LOAD_METHOD and CALL_METHOD from Python 3.7+
Fixes #163
2021-04-12 09:55:52 -07:00
Aralox
7a89b72260 Support chained assignment statements, e.g. a = b = c.
We know when we have begun a chained assignment when we process a DUP_TOP with non-null on the stack. Push a NODE_CHAINSTORE onto the stack when this happens, and keep it 'floating' on top of the stack for all STORE_X operations until the stack is empty.
To support versions of Python <= 2.5 which use DUP_TOP in more places, I modified ROT_TWO, ROT_THREE and ROT_FOUR to get rid of NODE_CHAINSTORE on the stack if it is present.
2020-10-23 21:19:01 +11:00
Aralox
1db8d28729 Add compiled test for python 2.7 2020-10-23 14:30:42 +11:00
Aralox
db94f3c257 CRLF -> LF 2020-10-23 11:28:42 +11:00
Aralox
8e8bb95592 Support unpacking empty list.
If UNPACK_SEQUENCE with operand 0 is encountered, treat it like a STORE_X and either assign the TOS to it or set it as the for-loop index.
Issue #183.
2020-10-23 11:23:46 +11:00
Michael Hansen
8eb18de269 Update tests to show that #39 is resolved, and add dummy support for
STORE_LOCALS used in Python 3.0-3.3.

Closes #39
Closes #63
2020-10-22 09:06:57 -07:00
Michael Hansen
0540b3991c Merge pull request #181 from Aralox/Issue-124-handle-async-for-GET_AITER_GET_ANEXT
Add support for `async for`
2020-10-22 08:24:56 -07:00
Aralox
7022db1bf6 Modify async for test to avoid known try-except problem with trailing unnecessary continue when the try-except is not followed by any other statements.
Add an xfail test to capture this failing scenario.
2020-10-22 15:35:59 +11:00
John Richards
345035b544 Adds support for SETUP_ANNOTATION op and variable annotations
Tests have also been added.

Fixes #169
2020-10-21 21:42:13 -04:00
Aralox
e80aa996fa Only initialize the async for once. 2020-10-22 09:11:51 +11:00
Aralox
5bdc0b5baf Merge remote-tracking branch 'upstream/master' into Issue-124-handle-async-for-GET_AITER_GET_ANEXT
Conflicts:
	ASTree.cpp
2020-10-21 19:34:37 +11:00
Aralox
91a23f914d Implement better handling for async for.
Instead of ignoring boilerplate when decompiling `async for`, build the loop semantically by deconstructing the BLK_WHILE -> BLK_CONTAINER -> BLK_TRY that python generates when compiling an `async for` (see https://www.python.org/dev/peps/pep-0492/#asynchronous-iterators-and-async-for).
When reading GET_AITER, convert the BLK_WHILE into a BLK_ASYNCFOR in the same way as a `for` loop.
Ignore GET_ANEXT.
Use END_FINALLY as the trigger to finish building the BLK_ASYNCFOR:
-> Extract the loop variable from the contents of the BLK_TRY.
-> Throw away the BLK_TRY and BLK_CONTAINER, leave the BLK_ASYNCFOR on top of the stack.
2020-10-21 19:32:20 +11:00
Michael Hansen
d3a46f711f Merge remote-tracking branch 'dotjrich/issue-172' into master 2020-10-20 21:10:55 -07:00
Aralox
db12d15e08 Fix token_dump for strings with single quotes in them. Update f-string test tokens. 2020-10-21 10:38:58 +11:00
Aralox
8933c9a4a9 Add support for async for. Issue #124
Ignore 'boilerplate' opcodes that set up the async iteration logic internally (https://www.python.org/dev/peps/pep-0492/#asynchronous-iterators-and-async-for) - We don’t need any of this as GET_AITER is enough to tell us that we are in an `async for`.
2020-10-20 20:39:23 +11:00
John Richards
5b819fa23e Adds support for BUILD_CONST_KEY_MAP opcode
Tests have also been added.

Fixes #172
2020-10-20 01:46:38 -04:00
Aralox
7af40a779f CRAs 2020-10-20 16:42:19 +11:00
Aralox
0c9fbd9caf Issue-165 Added support for f-strings (literal string interpolation https://www.python.org/dev/peps/pep-0498/)
Opcodes handled: FORMAT_VALUE, BUILD_STRING.
Added AST node classes for FormattedValue and JoinedStr.
2020-10-17 20:52:57 +11:00