Skip to content

Create the output directory tree, not just its last component - #214

Open
greeng3 wants to merge 2 commits into
worawit:mainfrom
greeng3:upstream-1-output-directory
Open

greeng3 wants to merge 2 commits into
worawit:mainfrom
greeng3:upstream-1-output-directory

Conversation

@greeng3

@greeng3 greeng3 commented Aug 11, 2026

Copy link
Copy Markdown

std::filesystem::create_directory fails when the parent does not exist, so an
output path like -o out/some/new/path aborts with

Failed to create output directory: No such file or directory

and exits 1 — after the Dart VM build has already run, which is what makes a
one-line bug worth reporting.

create_directories has mkdir -p semantics. Both overloads return false for
an existing directory without setting the error code, so the surrounding guard
is unchanged, and a genuine failure — an unwritable parent, or a file in the
way — is still reported and still exits 1.

Adds tests/test_output_directory.py: standard library only, no test framework
introduced, and no sample application needed. The directory is created before
the snapshot is loaded, so the tests pass a deliberately invalid input file and
assert only that the run does not fail at directory creation. Seven cases,
under a second: missing parent, deeply nested, existing directory, single
component, output path is a file, parent component is a file, unwritable
parent.

greeng3 and others added 2 commits August 11, 2026 07:16
Reproduces issue #3: an output path whose parent does not exist aborts with
"Failed to create output directory: No such file or directory", after the
expensive Dart VM build has already run.

The directory is created before the snapshot is loaded, so the tests pass a
deliberately invalid input file — the run is expected to fail later, and what
is asserted is that it does not fail at directory creation. No snapshot
parsing, no analysis, so the suite finishes in under a second.

Seven cases: the two failing shapes (missing parent, deeply nested), two that
already worked and must not regress (existing directory, single component under
an existing parent), and three that must still be reported as failures rather
than swallowed (output path is a file, a parent component is a file, unwritable
parent). The unwritable-parent case skips under root, which is why the
file-in-the-way cases exist — they exercise the error path either way.

Standard library only, no test framework added.

Refs: #3

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
std::filesystem::create_directory fails when the parent does not exist, so
`-o out/some/new/path` aborted the run after the Dart VM build had already
happened. create_directories has mkdir -p semantics.

Both overloads return false for an already-existing directory without setting
the error code, so the surrounding guard is unchanged and a genuine failure —
an unwritable parent, or a file in the way — is still reported and still exits
1.

Fixes #3

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant