Tests - Stop writing a file called null into the current directory - #10532
Merged
Conversation
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>
Member
|
ahhh nice fix! thank you 馃檹馃徏 that is such a pesky filename. claude outputs it a lot for me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Get-DbaExternalProcess.Tests.ps1andStop-DbaExternalProcess.Tests.ps1both startsqlcmdlike this:-RedirectStandardOutputtakes a file name, not a stream, sonulldoes not discard anything. It writes the sqlcmd output to a file literally callednullin 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:
That is the
sqlcmdoutput of thexp_cmdshell 'powershell -command "sleep 5"'the test runs, and its timestamp lines up withGet-DbaExternalProcessin the run.The output now goes to a file next to the sql file the test already writes to
$TestConfig.Temp, and theAfterAllof each file removes both.NULwould 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
nullfile appears in the working directory afterwards and that$TestConfig.Tempis left with neithersleep.sqlnorsleep.out.馃 Generated with Claude Code