Skip to content

testscript: remove the work directory root with all its contents - #312

Merged
mvdan merged 2 commits into
rogpeppe:masterfrom
mvdan:testscript-remove-root
Oct 5, 2026
Merged

mvdan merged 2 commits into
rogpeppe:masterfrom
mvdan:testscript-remove-root

Conversation

@mvdan

@mvdan mvdan commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

(see commit messages - please do not squash)

This resolves a case where testscripts in the CUE repo were leaking temporary directories.

mvdan added 2 commits October 4, 2026 12:40
testscript removes each script's work directory with all its contents,
but the directory holding them only with os.Remove, which fails if it
is not empty. A Setup function which creates files next to the work
directories, such as a shared configuration file, therefore leaves a
go-test-script directory behind in the system temporary directory.
Use removeAll rather than os.Remove, so that files created by Setup
functions next to the work directories do not keep it around. The
directory is created by testscript itself and is only removed when
work directories are not kept, so its contents are never wanted
afterwards.
@mvdan
mvdan merged commit 38c169d into rogpeppe:master Oct 5, 2026
6 checks passed
@mvdan
mvdan deleted the testscript-remove-root branch October 5, 2026 07:30
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.

3 participants