{"record":{"id":"0f9fc8430bd7828b","repo":"swc-project/swc","slug":"failed-to-create-directory-for-writing-data-o","errorCode":null,"errorMessage":"failed to create directory ({}) for writing data of the failed assertion: {}","messagePattern":"failed to create directory \\((.+?)\\) for writing data of the failed assertion: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/testing/src/lib.rs","lineNumber":270,"sourceCode":"        s.into()\n    }\n\n    let (left, right) = (print(left), print(right));\n\n    let cur = thread::current();\n    let test_name = cur\n        .name()\n        .expect(\"rustc sets test name as the name of thread\");\n\n    // ./target/debug/tests/${test_name}/\n    let target_dir = {\n        let mut buf = paths::test_results_dir().to_path_buf();\n        for m in test_name.split(\"::\") {\n            buf.push(m)\n        }\n\n        create_dir_all(&buf).unwrap_or_else(|err| {\n            panic!(\n                \"failed to create directory ({}) for writing data of the failed assertion: {}\",\n                buf.display(),\n                err\n            )\n        });\n\n        buf\n    };\n\n    write_to_file(&target_dir.join(\"left\"), &left);\n    write_to_file(&target_dir.join(\"right\"), &right);\n\n    format!(\"----- {test_name}\\n    left:\\n{left}\\n    right:\\n{right}\")\n}\n\n#[macro_export]\nmacro_rules! assert_eq_ignore_span {\n    ($l:expr, $r:expr) => {{","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/testing/src/lib.rs#L252-L288","documentation":"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.","triggerScenarios":"Thrown at crates/testing/src/lib.rs:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}