Skip to content

Commit 04b80a1

Browse files
committed
Added --enable_assertions to pcal translate script
Signed-off-by: Andrew Helwer <[email protected]>
1 parent 3428533 commit 04b80a1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

.github/scripts/translate_pluscal.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip converting', required=False, default=[])
1818
parser.add_argument('--only', nargs='+', help='If provided, only convert models in this space-separated list', required=False, default=[])
1919
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
20+
parser.add_argument('--enable_assertions', help='Enable Java assertions (pass -enableassertions to JVM)', action='store_true')
2021
args = parser.parse_args()
2122

2223
logging.basicConfig(level = logging.DEBUG if args.verbose else logging.INFO)
@@ -26,6 +27,7 @@
2627
examples_root = dirname(manifest_path)
2728
skip_modules = args.skip
2829
only_modules = args.only
30+
enable_assertions = args.enable_assertions
2931

3032
manifest = tla_utils.load_json(manifest_path)
3133

@@ -44,23 +46,21 @@
4446

4547
def translate_module(module_path):
4648
logging.info(f'Translating {module_path}')
47-
result = subprocess.run(
48-
['java', '-cp', tools_path, 'pcal.trans', '-nocfg', module_path],
49+
jvm_parameters = ['-cp', tools_path] + (['-enableassertions'] if enable_assertions else [])
50+
pcal_parameters = ['-nocfg', module_path]
51+
pcal = subprocess.run(
52+
['java'] + jvm_parameters + ['pcal.trans'] + pcal_parameters,
4953
stdout=subprocess.PIPE,
5054
stderr=subprocess.STDOUT,
5155
text=True
5256
)
53-
match result:
54-
case CompletedProcess():
55-
if result.returncode == 0:
56-
logging.debug(result.stdout)
57-
return True
58-
else:
59-
logging.error(f'Module {module_path} conversion failed with return code {result.returncode}; output:\n{result.stdout}')
60-
return False
61-
case _:
62-
logging.error(f'Unhandled result type {type(result)}: {result.stdout}')
63-
return False
57+
output = ' '.join(pcal.args) + '\n' + pcal.stdout
58+
if 0 == pcal.returncode:
59+
logging.debug(output)
60+
return True
61+
else:
62+
logging.error(output)
63+
return False
6464

6565
success = True
6666
thread_count = cpu_count() if not args.verbose else 1

0 commit comments

Comments
 (0)