|
38 | 38 | NOT_DETERMINISTIC = { |
39 | 39 | str(name) |
40 | 40 | for name in [ |
41 | | - pathlib.Path("examples") / "granite" / "multi_round_chat.pdl", |
42 | | - pathlib.Path("examples") / "granite" / "single_round_chat.pdl", |
43 | | - pathlib.Path("examples") / "joke" / "Joke.pdl", |
44 | | - pathlib.Path("examples") / "react" / "multi-agent.pdl", |
45 | | - pathlib.Path("examples") / "react" / "wikipedia.pdl", |
46 | | - pathlib.Path("examples") / "talk" / "10-sdg.pdl", |
47 | | - pathlib.Path("examples") / "talk" / "7-chatbot-roles.pdl", |
48 | | - pathlib.Path("examples") / "chatbot" / "chatbot.pdl", |
49 | | - pathlib.Path("examples") / "talk" / "8-tools.pdl", |
50 | | - pathlib.Path("examples") / "talk" / "9-react.pdl", |
51 | | - pathlib.Path("examples") / "teacher" / "teacher.pdl", |
52 | | - pathlib.Path("examples") / "tools" / "calc.pdl", |
53 | | - pathlib.Path("examples") / "tutorial" / "include.pdl", |
54 | | - pathlib.Path("examples") / "hello" / "hello-roles-array.pdl", |
55 | 41 | pathlib.Path("examples") / "weather" / "weather.pdl", |
56 | 42 | pathlib.Path("examples") / "demo" / "3-weather.pdl", |
57 | | - pathlib.Path("examples") / "tutorial" / "conditionals_loops.pdl", |
58 | | - pathlib.Path("examples") / "chatbot" / "chatbot.pdl", |
59 | | - pathlib.Path("examples") / "fibonacci" / "fib.pdl", |
60 | 43 | ] |
61 | 44 | } |
62 | 45 |
|
@@ -179,28 +162,26 @@ def test_valid_programs(capsys: CaptureFixture[str], monkeypatch: MonkeyPatch) - |
179 | 162 | result_dir_name = ( |
180 | 163 | pathlib.Path(".") / "tests" / "results" / pdl_file_name.parent |
181 | 164 | ) |
182 | | - if UPDATE_RESULTS: |
183 | | - result_file_name_0 = pdl_file_name.stem + ".0.result" |
184 | | - result_dir_name.mkdir(parents=True, exist_ok=True) |
185 | | - with open( |
186 | | - result_dir_name / result_file_name_0, "w", encoding="utf-8" |
187 | | - ) as result_file: |
188 | | - print(str(result), file=result_file) |
189 | 165 | if str(pdl_file_name) in NOT_DETERMINISTIC: |
190 | 166 | continue |
191 | 167 | wrong_result = True |
192 | | - for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.pdl"): |
193 | | - with open( |
194 | | - result_dir_name / result_file_name, "r", encoding="utf-8" |
195 | | - ) as result_file: |
| 168 | + for result_file_name in result_dir_name.glob(pdl_file_name.stem + ".*.result"): |
| 169 | + with open(result_file_name, "r", encoding="utf-8") as result_file: |
196 | 170 | expected_result = str(result_file.read()) |
197 | 171 | if str(result).strip() == expected_result.strip(): |
198 | 172 | wrong_result = False |
199 | | - |
200 | 173 | if wrong_result: |
201 | | - wrong_results[str(pdl_file_name)] = { |
202 | | - "actual": str(result), |
203 | | - } |
| 174 | + if UPDATE_RESULTS: |
| 175 | + result_file_name_0 = pdl_file_name.stem + f".1.result" |
| 176 | + result_dir_name.mkdir(parents=True, exist_ok=True) |
| 177 | + with open( |
| 178 | + result_dir_name / result_file_name_0, "w", encoding="utf-8" |
| 179 | + ) as result_file: |
| 180 | + print(str(result), file=result_file) |
| 181 | + else: |
| 182 | + wrong_results[str(pdl_file_name)] = { |
| 183 | + "actual": str(result), |
| 184 | + } |
204 | 185 | except PDLParseError: |
205 | 186 | actual_parse_error |= {str(pdl_file_name)} |
206 | 187 | except PDLRuntimeError as exc: |
|
0 commit comments