Skip to content

Tests - Stop writing a file called null into the current directory - #10532

Merged
potatoqualitee merged 1 commit into
developmentfrom
fix-external-process-test-output-file
Aug 8, 2026
Merged

Tests - Stop writing a file called null into the current directory#10532
potatoqualitee merged 1 commit into
developmentfrom
fix-external-process-test-output-file

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Get-DbaExternalProcess.Tests.ps1 and Stop-DbaExternalProcess.Tests.ps1 both start sqlcmd like this:

Start-Process -FilePath sqlcmd -ArgumentList "-S $($TestConfig.InstanceRestart) -i $sqlFile" -NoNewWindow -RedirectStandardOutput null

-RedirectStandardOutput takes a file name, not a stream, so null does not discard anything. It writes the sqlcmd output to a file literally called null in whatever the current directory happens to be - the repository checkout on a CI runner, or the directory a local test run was started from.

Found after a full local run, which left this behind:

output
------------------------------------------------------------------------------
NULL

(1 row affected)

That is the sqlcmd output of the xp_cmdshell 'powershell -command "sleep 5"' the test runs, and its timestamp lines up with Get-DbaExternalProcess in the run.

The output now goes to a file next to the sql file the test already writes to $TestConfig.Temp, and the AfterAll of each file removes both. NUL would also work but only on Windows, and putting the file where the test already keeps its temporary file matches what the rest of the file does.

Testing

Both files pass, 2 tests each, with no warnings. Verified that no null file appears in the working directory afterwards and that $TestConfig.Temp is left with neither sleep.sql nor sleep.out.

馃 Generated with Claude Code

Both external process tests started sqlcmd with -RedirectStandardOutput null. That
parameter takes a file name, so this did not discard the output, it wrote it to a file
called null in whatever the current directory happened to be - the checkout on a CI
runner, or the directory the test run was started from.

The output now goes to a file next to the sql file the test already writes, and the
AfterAll removes both.

(do Get-DbaExternalProcess, Stop-DbaExternalProcess)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@potatoqualitee

Copy link
Copy Markdown
Member

ahhh nice fix! thank you 馃檹馃徏 that is such a pesky filename. claude outputs it a lot for me.

@potatoqualitee
potatoqualitee merged commit 98912e5 into development Aug 8, 2026
23 of 24 checks passed
@potatoqualitee
potatoqualitee deleted the fix-external-process-test-output-file branch August 8, 2026 08:06
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.

2 participants