File tree Expand file tree Collapse file tree 2 files changed +55
-5
lines changed Expand file tree Collapse file tree 2 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 140140 },
141141 "problemMatcher" : []
142142 },
143+ {
144+ "label" : " 🧪 Standards Automation: Build Case Test DB from test file" ,
145+ "type" : " shell" ,
146+ "windows" : {
147+ "command" : " .${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}Scripts${pathSeparator}python.exe scripts${pathSeparator}build_test_database.py ${file}"
148+ },
149+ "linux" : {
150+ "command" : " .${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}bin${pathSeparator}python3 scripts${pathSeparator}build_test_database.py ${file}"
151+ },
152+ "osx" : {
153+ "command" : " .${pathSeparator}scripts${pathSeparator}.venv${pathSeparator}bin${pathSeparator}python3 scripts${pathSeparator}build_test_database.py ${file}"
154+ },
155+ "presentation" : {
156+ "reveal" : " always" ,
157+ "panel" : " new" ,
158+ "focus" : true
159+ },
160+ "runOptions" : {
161+ "reevaluateOnRerun" : false
162+ },
163+ "problemMatcher" : []
164+ },
143165 {
144166 "label" : " 📝 Standards Automation: Format CodeQL" ,
145167 "type" : " shell" ,
Original file line number Diff line number Diff line change 33import os
44import subprocess
55import json
6+ from pathlib import Path
67
7- if len (sys .argv ) < 4 :
8- print ("Usage: build_test_database.py LANGUAGE STANDARD RULE" , file = sys .stderr )
8+ if len (sys .argv ) != 4 and len ( sys . argv ) != 2 :
9+ print ("Usage: build_test_database.py TEST_FILE | LANGUAGE STANDARD RULE" , file = sys .stderr )
910 exit (1 )
1011
11- LANGUAGE = sys .argv [1 ]
12- STANDARD = sys .argv [2 ]
13- RULE = sys .argv [3 ]
12+ if len (sys .argv ) == 4 :
13+ LANGUAGE = sys .argv [1 ]
14+ STANDARD = sys .argv [2 ]
15+ RULE = sys .argv [3 ]
16+
17+ if len (sys .argv ) == 2 :
18+ TEST_FILE_PATH = Path (sys .argv [1 ])
19+ if not TEST_FILE_PATH .exists ():
20+ print (f"The test file { TEST_FILE_PATH } does not exist!" , file = sys .stderr )
21+ exit (1 )
22+ RULE_PATH = TEST_FILE_PATH .parent
23+ while True :
24+ if len (list (RULE_PATH .glob ("*.expected" ))) > 0 :
25+ break
26+ if RULE_PATH .parent != RULE_PATH :
27+ RULE_PATH = RULE_PATH .parent
28+ else :
29+ print (f"The test file { TEST_FILE_PATH } is not a test because we couldn't find an expected file!" , file = sys .stderr )
30+ exit (1 )
31+ RULE = RULE_PATH .name
32+ TESTS_PATH = RULE_PATH .parent .parent
33+ if TESTS_PATH .name != "test" :
34+ print (f"The test file { TEST_FILE_PATH } is not in the expected test layout, cannot determine standard or language!" , file = sys .stderr )
35+ exit (1 )
36+
37+ STANDARD_PATH = TESTS_PATH .parent
38+ STANDARD = STANDARD_PATH .name
39+
40+ LANGUAGE_PATH = STANDARD_PATH .parent
41+ LANGUAGE = LANGUAGE_PATH .name
1442
1543if shutil .which ("codeql" ) is None :
1644 print ("Please install codeql." , file = sys .stderr )
You can’t perform that action at this time.
0 commit comments