Skip to content

Commit 9e69831

Browse files
committed
CI: Fix state count validation regex
When run under some system locales or Java versions, TLC will output the state count info with comma separators, like "1,000" instead of "1000". Before these changes, the Python regex used to extract & parse these values did not handle these comma separators. Now, it does. This was done by setting the Python locale to en_US.UTF-8 then using the locale.atoi() API. Signed-off-by: Andrew Helwer <[email protected]>
1 parent 53767a8 commit 9e69831

File tree

2 files changed

+8
-55
lines changed

2 files changed

+8
-55
lines changed

.github/scripts/tla_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import locale
12
from datetime import datetime
23
import json
34
from os.path import join, normpath, pathsep
@@ -223,19 +224,20 @@ def is_state_count_info_correct(model, distinct_states, total_states, state_dept
223224
# State depth not yet deterministic due to TLC bug: https://github.com/tlaplus/tlaplus/issues/883
224225
return none_or_equal(expected_distinct_states, distinct_states) and none_or_equal(expected_total_states, total_states) #and none_or_equal(expected_state_depth, state_depth)
225226

226-
state_count_regex = re.compile(r'(?P<total_states>\d+) states generated, (?P<distinct_states>\d+) distinct states found, 0 states left on queue.')
227-
state_depth_regex = re.compile(r'The depth of the complete state graph search is (?P<state_depth>\d+).')
227+
state_count_regex = re.compile(r'(?P<total_states>[\d,]+) states generated, (?P<distinct_states>[\d,]+) distinct states found, 0 states left on queue.')
228+
state_depth_regex = re.compile(r'The depth of the complete state graph search is (?P<state_depth>[\d,]+).')
228229

229230
def extract_state_count_info(tlc_output):
230231
"""
231232
Parse & extract state count info from TLC output.
232233
"""
234+
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
233235
state_count_findings = state_count_regex.search(tlc_output)
234236
state_depth_findings = state_depth_regex.search(tlc_output)
235237
if state_count_findings is None or state_depth_findings is None:
236238
return None
237-
distinct_states = int(state_count_findings.group('distinct_states'))
238-
total_states = int(state_count_findings.group('total_states'))
239-
state_depth = int(state_depth_findings.group('state_depth'))
239+
distinct_states = locale.atoi(state_count_findings.group('distinct_states'))
240+
total_states = locale.atoi(state_count_findings.group('total_states'))
241+
state_depth = locale.atoi(state_depth_findings.group('state_depth'))
240242
return (distinct_states, total_states, state_depth)
241243

.gitignore

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,2 @@
1-
## Ignore all files by default
1+
# Created by venv; see https://docs.python.org/3/library/venv.html
22
*
3-
4-
## Don't ignore TLA+ files
5-
!*.tla
6-
7-
## Don't ignore TLC model config and results
8-
!*.cfg
9-
!*.out ## Usually .out files are small
10-
11-
## Don't ignore Toolbox model metadata
12-
!*.launch
13-
14-
## Don't ignore Toolbox spec metadata
15-
!.project
16-
!*.prefs
17-
18-
## Don't ignore PDFs
19-
!*.pdf
20-
21-
## Don't ignore all folders
22-
!*/
23-
24-
## Ignore TLAPS cache folder
25-
## See https://github.com/tlaplus/tlapm/issues/16
26-
__tlacache__
27-
.tlacache
28-
29-
## Don't ignore CI files
30-
!.github/**
31-
32-
## Don't ignore READMEs
33-
!*.md
34-
35-
## Ignore Python artifacts
36-
__pycache__
37-
pyvenv.cfg
38-
39-
## Ignore directories used for local CI testing
40-
deps/
41-
tree-sitter-tlaplus/
42-
43-
# Ignore TTrace specs
44-
*_TTrace_*.tla
45-
46-
## Ignore tools/ folder created by .devcontainer.json
47-
tools/
48-
49-
# Ignore directory created by Apalache
50-
_apalache-out
51-

0 commit comments

Comments
 (0)