You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/templates/input_output.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,84 @@ Executes a program with a series of stdin inputs and compares the program's stdo
56
56
57
57
---
58
58
59
+
### `expect_file_artifact`
60
+
61
+
Executes a program and then extracts a generated file from the sandbox container, comparing its content against an expected value. Useful for assignments where students must produce output files (e.g., reports, sorted data, metrics).
62
+
63
+
| Parameter | Type | Required | Description |
64
+
|-----------|------|----------|-------------|
65
+
|`artifact_path`| string | ✓ | Relative path under `/app` of the file the program must generate (e.g., `output.txt`) |
66
+
|`expected_content`| string | ✓ | Expected file content or pattern to match against |
67
+
|`program_command`| string | ✗ | Command to execute (same format as `expect_output`) |
68
+
|`match_mode`| string | ✗ |`exact` (default), `contains`, or `regex`|
69
+
|`inputs`| list[string]| ✗ | List of strings sent to stdin before extraction |
70
+
|`normalization`| boolean | ✗ | Normalize line endings and trim trailing whitespace (default: `true`) |
71
+
72
+
**Scoring:** 100 if file content matches, 0 otherwise.
73
+
74
+
**Error handling:** Inherits all execution error detection from `expect_output` (timeouts, compilation errors, runtime errors), plus:
75
+
- Missing artifact file
76
+
- Artifact extraction failure
77
+
- Invalid regex pattern
78
+
- Invalid artifact path (absolute or traversal paths are rejected)
79
+
80
+
**Artifact path conventions:**
81
+
- Paths are relative to `/app` (the sandbox working directory)
82
+
- Absolute paths (`/etc/passwd`) and traversal paths (`../secret`) are rejected
83
+
- The file must be a regular file (not a directory or symlink)
Executes a program with a specific input and verifies it completes **without crashing**. The program's stdout is ignored — this test only validates that execution succeeds. Useful for testing error handling (e.g., sending invalid input).
0 commit comments