swc-project/swc · error
failed to create directory ({}) for writing data of the fail
Error message
failed to create directory ({}) for writing data of the failed assertion: {} What it means
Raised in print_left_right (crates/testing/src/lib.rs:270). After a failed assert_eq_ignore_span, the harness builds ./target/swc-test-results/<test name components>/ via create_dir_all; if directory creation fails (permissions, disk full, invalid path, sandbox), the panic fires and masks the underlying assertion failure. The failing create_dir_all result for the per-test results directory is the fault.
Source
Thrown at crates/testing/src/lib.rs:270
s.into()
}
let (left, right) = (print(left), print(right));
let cur = thread::current();
let test_name = cur
.name()
.expect("rustc sets test name as the name of thread");
// ./target/debug/tests/${test_name}/
let target_dir = {
let mut buf = paths::test_results_dir().to_path_buf();
for m in test_name.split("::") {
buf.push(m)
}
create_dir_all(&buf).unwrap_or_else(|err| {
panic!(
"failed to create directory ({}) for writing data of the failed assertion: {}",
buf.display(),
err
)
});
buf
};
write_to_file(&target_dir.join("left"), &left);
write_to_file(&target_dir.join("right"), &right);
format!("----- {test_name}\n left:\n{left}\n right:\n{right}")
}
#[macro_export]
macro_rules! assert_eq_ignore_span {
($l:expr, $r:expr) => {{View on GitHub (pinned to 5176682b65)
Solutions
- Pre-create or verify writability of target/swc-test-results before running the test suite
- Run tests outside read-only/sandboxed filesystems, or point the results dir at a writable location
- Fall back to printing left/right to stdout if directory creation fails, preserving the assertion output
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/testing/src/lib.rs:270 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/0f9fc8430bd7828b.
Report an issue: GitHub.