Skip to content

HTMLTemplates.swift claims to be generated, but the generator was deleted in #295 #434

Description

@tylervick

The report's markup exists in two places, only one of which is real, and the repo is configured on the assumption that the other one is the source.

What's actually true

Sources/XCTestHTMLReportCore/Classes/HTMLTemplates.swift opens with:

/// DO NOT EDIT! This file is autogenerated by createTemplates.sh

createTemplates.sh was deleted in #295 ("remove ruby & thor tasks"). Nothing has generated that file since. It is the real, hand-maintained source — it is what compiles.

Sources/XCTestHTMLReportCore/HTML/*.html is the supposed input. Package.swift excludes the directory from the target ("ignore HTML directory resources. They are already imported as static strings"), so it is not built, not tested, and not shipped. It is dead weight that looks authoritative.

The drift

HTMLTemplates.index    875 non-blank lines
HTML/index.html        764 non-blank lines     28 diff hunks

Features that landed only in the Swift string literal include the video icon rules, the .test-summary.skipped/.failed .test-result-icon selectors, and the whole .video block. Conversely HTML/index.html still carries absolute-positioning rules the compiled template dropped.

The mechanism is visible in the history: #350 last touched HTML/ on 2024-01-22, and #349 hand-edited the "generated" file on 2024-01-23.

Why it's not harmless

Both linters skip the file because it is believed to be generated:

  • .swiftformat: # HTMLTemplates.swift is generated (it carries a DO NOT EDIT header)--exclude
  • .swiftlint.yml: same file in excluded:

So the only hand-maintained markup in the project is also the only file exempt from both linters, on a premise that stopped being true two years ago. And the 4.0 report redesign is going to rewrite exactly this file — anyone starting from HTML/ would be editing a stale copy that has no effect on the build.

Options

  1. Delete HTML/. Smallest change, makes HTMLTemplates.swift honestly the source, drops the false header and the lint exemptions. Cost: editing CSS inside an escaped Swift string literal stays miserable, which is plausibly why the drift happened.
  2. Make HTML/ real as SPM resources, load templates at runtime, delete HTMLTemplates.swift. Best editing experience and the linters stop mattering for markup. Cost: templates become runtime resources rather than compile-time constants — a behaviour change for the library product.
  3. Restore a generator. Regenerate HTMLTemplates.swift from HTML/, wire it into CI so drift fails the build. Keeps compile-time constants and gets a real source. Cost: a build step to own.

Option 2 or 3 is worth the trouble if the 4.0 redesign is going to touch this heavily; option 1 is fine if it isn't. Either way the header and the lint exemptions need to stop lying.

Scope note

Non-breaking cleanup, hence 3.1 — but it gates the 4.0 redesign workstream, so it wants to land before that starts rather than alongside it.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions