Skip to content

Commit 3837952

Browse files
committed
Strengthen expert checkpoint smoke assertions
1 parent 3c0ec5d commit 3837952

8 files changed

Lines changed: 128 additions & 30 deletions

File tree

languages/csharp/assessments/04-expert/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ Write a program that:
2323
dotnet run --project assessment-04-expert.csproj
2424
```
2525

26-
## Expected Output (shape)
26+
## Expected Output
2727

2828
```text
29-
Worker 0 partial sum: ...
30-
Worker 1 partial sum: ...
31-
...
29+
Worker 0 partial sum: 48
30+
Worker 1 partial sum: 97
31+
Worker 2 partial sum: 60
32+
3233
Final summary:
33-
Total: ...
34-
Minimum: ...
35-
Maximum: ...
34+
Total: 205
35+
Minimum: 2
36+
Maximum: 45
3637
```
3738

39+
The worker lines may appear in a different order, but the three partial sums and the final totals should match these values.
40+
3841
## What To Check
3942

4043
- Shared updates happen only inside the `lock`.

languages/csharp/projects/04-expert/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ dotnet run --project expert-project.csproj
1717
- Measure pipeline duration with `Stopwatch`.
1818
- Print per-step execution summary.
1919

20-
## Sample Output
20+
## Expected Output
2121

2222
```text
2323
Running 3 jobs through 2 steps...
2424
Step load processed 3 jobs
2525
Step transform processed 3 jobs
26-
Elapsed (microseconds): 42
26+
Elapsed (microseconds): <positive integer>
2727
```
2828

29+
The first three lines should stay exact. Only the measured microsecond value should vary.
30+
2931
## Extension Ideas
3032

3133
- Add optional logging levels.

languages/go/assessments/04-expert/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ Write a program that:
2323
go run main.go
2424
```
2525

26-
## Expected Output (shape)
26+
## Expected Output
2727

2828
```text
29-
Worker 0 partial sum: ...
30-
Worker 1 partial sum: ...
31-
...
29+
Worker 0 partial sum: 48
30+
Worker 1 partial sum: 97
31+
Worker 2 partial sum: 60
32+
3233
Final summary:
33-
Total: ...
34-
Minimum: ...
35-
Maximum: ...
34+
Total: 205
35+
Minimum: 2
36+
Maximum: 45
3637
```
3738

39+
The worker lines may appear in a different order, but the three partial sums and the final totals should match these values.
40+
3841
## What To Check
3942

4043
- Shared updates happen only while the mutex is held.

languages/go/projects/04-expert/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ go run main.go
1717
- Measure pipeline duration with `time`.
1818
- Print per-step execution summary.
1919

20-
## Sample Output
20+
## Expected Output
2121

2222
```text
2323
Running 3 jobs through 2 steps...
2424
Step load processed 3 jobs
2525
Step transform processed 3 jobs
26-
Elapsed (microseconds): 42
26+
Elapsed (microseconds): <positive integer>
2727
```
2828

29+
The first three lines should stay exact. Only the measured microsecond value should vary.
30+
2931
## Extension Ideas
3032

3133
- Add optional logging levels.

languages/python/assessments/04-expert/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ Write a program that:
2323
python main.py
2424
```
2525

26-
## Expected Output (shape)
26+
## Expected Output
2727

2828
```text
29-
Worker 0 partial sum: ...
30-
Worker 1 partial sum: ...
31-
...
29+
Worker 0 partial sum: 48
30+
Worker 1 partial sum: 97
31+
Worker 2 partial sum: 60
32+
3233
Final summary:
33-
Total: ...
34-
Minimum: ...
35-
Maximum: ...
34+
Total: 205
35+
Minimum: 2
36+
Maximum: 45
3637
```
3738

39+
The worker lines may appear in a different order, but the three partial sums and the final totals should match these values.
40+
3841
## What To Check
3942

4043
- Shared updates happen only while the lock is held.

languages/python/projects/04-expert/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ python main.py
1717
- Measure pipeline duration with `time.perf_counter`.
1818
- Print per-step execution summary.
1919

20-
## Sample Output
20+
## Expected Output
2121

2222
```text
2323
Running 3 jobs through 2 steps...
2424
Step load processed 3 jobs
2525
Step transform processed 3 jobs
26-
Elapsed (microseconds): 42
26+
Elapsed (microseconds): <positive integer>
2727
```
2828

29+
The first three lines should stay exact. Only the measured microsecond value should vary.
30+
2931
## Extension Ideas
3032

3133
- Add optional logging levels.

scripts/automation_core/ops.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,23 @@ def run_command(
228228
cwd: Path | None = None,
229229
input_text: str | None = None,
230230
quiet_stdout: bool = False,
231+
capture_stdout: bool = False,
231232
action: str | None = None,
232233
timeout_seconds: float | None = None,
233234
) -> subprocess.CompletedProcess[str]:
234235
try:
236+
stdout_target: int | None = None
237+
if capture_stdout:
238+
stdout_target = subprocess.PIPE
239+
elif quiet_stdout:
240+
stdout_target = subprocess.DEVNULL
241+
235242
completed = subprocess.run(
236243
command,
237244
cwd=str(cwd) if cwd else None,
238245
input=input_text,
239246
text=True,
240-
stdout=subprocess.DEVNULL if quiet_stdout else None,
247+
stdout=stdout_target,
241248
stderr=None,
242249
check=False,
243250
timeout=timeout_seconds,
@@ -818,15 +825,34 @@ def smoke_runtime_job(
818825
elif "input_file" in job:
819826
input_text = str((working_dir / job["input_file"]).resolve()) + "\n"
820827

821-
run_command(
828+
capture_stdout = bool(
829+
job.get("required_stdout_contains") or job.get("required_stdout_patterns")
830+
)
831+
832+
completed = run_command(
822833
command_builder(job, working_dir),
823834
cwd=working_dir,
824835
input_text=input_text,
825-
quiet_stdout=True,
836+
quiet_stdout=not capture_stdout,
837+
capture_stdout=capture_stdout,
826838
action=label,
827839
timeout_seconds=timeout_seconds,
828840
)
829841

842+
if capture_stdout:
843+
output = completed.stdout or ""
844+
for expected in job.get("required_stdout_contains", []):
845+
if expected not in output:
846+
raise AutomationError(
847+
f"{label} did not print expected text: {expected}\nActual output:\n{output}"
848+
)
849+
for pattern in job.get("required_stdout_patterns", []):
850+
if not re.search(pattern, output, re.MULTILINE):
851+
raise AutomationError(
852+
f"{label} did not match expected pattern: "
853+
f"{pattern}\nActual output:\n{output}"
854+
)
855+
830856
for output_name in job.get("required_outputs", []):
831857
if not (working_dir / output_name).exists():
832858
raise AutomationError(f"{label} did not create {output_name}")

scripts/automation_manifest.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,31 @@
174174
},
175175
{
176176
"program": "languages/python/assessments/04-expert/main.py"
177+
,
178+
"required_stdout_contains": [
179+
"Worker 0 partial sum: 48",
180+
"Worker 1 partial sum: 97",
181+
"Worker 2 partial sum: 60",
182+
"Final summary:",
183+
"Total: 205",
184+
"Minimum: 2",
185+
"Maximum: 45"
186+
]
177187
},
178188
{
179189
"program": "languages/python/projects/03-advanced/main.py"
180190
},
181191
{
182192
"program": "languages/python/projects/04-expert/main.py"
193+
,
194+
"required_stdout_contains": [
195+
"Running 3 jobs through 2 steps...",
196+
"Step load processed 3 jobs",
197+
"Step transform processed 3 jobs"
198+
],
199+
"required_stdout_patterns": [
200+
"Elapsed \\(microseconds\\): \\d+"
201+
]
183202
},
184203
{
185204
"working_dir": "languages/python/projects/02-core",
@@ -237,12 +256,31 @@
237256
},
238257
{
239258
"program": "languages/go/assessments/04-expert/main.go"
259+
,
260+
"required_stdout_contains": [
261+
"Worker 0 partial sum: 48",
262+
"Worker 1 partial sum: 97",
263+
"Worker 2 partial sum: 60",
264+
"Final summary:",
265+
"Total: 205",
266+
"Minimum: 2",
267+
"Maximum: 45"
268+
]
240269
},
241270
{
242271
"program": "languages/go/projects/03-advanced/main.go"
243272
},
244273
{
245274
"program": "languages/go/projects/04-expert/main.go"
275+
,
276+
"required_stdout_contains": [
277+
"Running 3 jobs through 2 steps...",
278+
"Step load processed 3 jobs",
279+
"Step transform processed 3 jobs"
280+
],
281+
"required_stdout_patterns": [
282+
"Elapsed \\(microseconds\\): \\d+"
283+
]
246284
},
247285
{
248286
"working_dir": "languages/go/projects/02-core",
@@ -300,12 +338,31 @@
300338
},
301339
{
302340
"project": "languages/csharp/assessments/04-expert/assessment-04-expert.csproj"
341+
,
342+
"required_stdout_contains": [
343+
"Worker 0 partial sum: 48",
344+
"Worker 1 partial sum: 97",
345+
"Worker 2 partial sum: 60",
346+
"Final summary:",
347+
"Total: 205",
348+
"Minimum: 2",
349+
"Maximum: 45"
350+
]
303351
},
304352
{
305353
"project": "languages/csharp/projects/03-advanced/advanced-project.csproj"
306354
},
307355
{
308356
"project": "languages/csharp/projects/04-expert/expert-project.csproj"
357+
,
358+
"required_stdout_contains": [
359+
"Running 3 jobs through 2 steps...",
360+
"Step load processed 3 jobs",
361+
"Step transform processed 3 jobs"
362+
],
363+
"required_stdout_patterns": [
364+
"Elapsed \\(microseconds\\): \\d+"
365+
]
309366
},
310367
{
311368
"working_dir": "languages/csharp/projects/02-core",

0 commit comments

Comments
 (0)