Skip to content

test: three helpers write a file map that os.CopyFS already writes #2420

Backlog

Description

@OmarAlJarrah

Problem

Three test helpers write a map of relative paths to contents under a root, each its own copy of the same body:

$ git grep -n -E '^func (writeTree|layout)\(' -- '*_test.go'
compilers/openapi/e2e/helpers_test.go:138:func layout(t *testing.T, root string, files map[string]string) {
compilers/openapi/internal/canary/checks_test.go:186:func writeTree(t *testing.T, root string, files map[string]string) {
internal/keydoc/cite_test.go:20:func writeTree(t *testing.T, root string, files map[string]string) {

(morphic @4a7a384c9). The standard library already does this job: os.CopyFS(root, fstest.MapFS{...}) writes a map of files, creating the directories, since Go 1.23. A fix to one copy (permissions, an error path) reaches none of the others, and layout's name does not say it writes files, which hid it from a search for an existing helper.

Direction

A draft: replace each helper's body with os.CopyFS over an fstest.MapFS, or call os.CopyFS at the call sites directly, keeping each test's assertions unchanged.

Out of scope

internal/archtest's one-file writeDocFile and the writers in other packages that write a single file.

Related: #2379

Priority: P4, rule 1 (housekeeping: a test refactor that changes no lowering, validation, IR or emit-contract behaviour). The command above → three copies (morphic @4a7a384c9).

Activity

  1. added
    type:test
    priority:P4
    on Dec 2, 2026
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

    priority:P4type:test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions