Skip to content

--output pointing at a nonexistent directory fails late with a misleading error #446

Description

@tylervick

Repro

Run the CLI with any valid bundle and an --output path whose directory does not exist:

xchtmlreport SomeValid.xcresult --output /some/missing/dir/report

The tool does all the parsing work, then fails at the very end when writing index.html:

An error has occured while creating the report
Error: The file "index.html" doesn't exist.

Exit code is 1. Neither line mentions the actual problem — that the output directory doesn't exist.

Details

  • Reproduces on Xcode 26.2 (local) and Xcode 26.6 (CI runners) — environment-independent.
  • The failure point is the html.write(toFile:) call in Sources/XCTestHTMLReport/XCTestHtmlReport.swift (run()): the thrown CocoaError surfaces as ArgumentParser's misleading "The file "index.html" doesn't exist." message, after all parsing/rendering work is already done.
  • This caused a false alarm in the first scheduled toolchain-drift run (Toolchain drift detected (Xcode 26.6 (17F113)) #444): the workflow passed an uncreated $RUNNER_TEMP subdirectory and the late, misleading error looked like toolchain drift.

Suggested fix (in the CLI)

Either create the output directory (FileManager.createDirectory(atPath:withIntermediateDirectories:)) before writing, or validate it up front in validate() and fail fast with a clear message ("output directory /some/missing/dir does not exist"). Failing late after minutes of parsing, with an error that points at the wrong file, is the bug regardless of which option is chosen.

The workflow-side workaround (mkdir before invoking) landed separately in #445; this issue tracks the product fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions