-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Prevent commands from executing during tests #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
// We don't want :: commands to be executed by the runner during tests | ||
// Replace any :: with : | ||
if (!str.match(/^::/)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want anything written out to stdout by the actual process? What if we just drop everything on the floor? Any value in capturing logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's helpful to have some output for debugging test errors or writing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I would either:
- Add some prefix to the line, to indicate clearly this is from the actual runner, so that I can easily grep for testing output or proram output; or
- Pipe everything to a different place, such as a file.
Personally, I don't like to see my testing result and the actual program's output mingled together. If we add some prefix, will it prevent ::error::
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what about stderr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've switched to dropping all of the actual program's output (aka any ::
command)
Dropping absolutely everything resulting in losing the --coverage
table, and the jest --silent
option doesn't handle silencing process.stdout.write
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we don't want to mess with stdout too much then.
* Create CODE_OF_CONDUCT.md * Update workflow (#1) * Run workflow on linux, mac, and windows * Add status badge * Use npm install instead * Bump typescript version * Use node 12.x * Add Ruby Gem example (#4) * Add Cocoapods example (#5) * Add Carthage example (#10) * Move examples to their own page (#13) * Minor typo in README (#15) from `steps.[ID].outupts.cache-hit` to `steps.[ID].outputs.cache-hit` * Update README.md * Prevent commands from executing during tests (#21) * Prevent commands from executing during tests * Add newline at end of file * Drop all commands from output * Link to NuGet lock files documentation (#20) * Add trailing dash to Maven fallback key (#19) * Fix README.md (#25) `restore-keys` had incorrect indentation. * Exclude documentation from CI tests (#28) * Ignore all .md files * Add note about time-based eviction to README (#30) * Fix typo in error message (#29) * Time based eviction interval is 1 week (#34) * Remove cache checksum debug - close #24 (#26) * Remove cache checksum debug - close #24 * Remove cache checksum debug on save * Fix formatting * Add Go modules example (#18) * Add Go modules example * Fix TOC * Fix repo name in contact email (#41) * Add Elixir Mix example (#42) * Add Elixir Mix example * Fix typo * Add cargo example for Rust project (#8) * Add cargo example * Add hash of Cargo.lock to keys of caches * Move Rust example to examples.md * Stop warning when cache is not found (#40) The cache not being found is a common situation so very visible warning is a little too much. * Bump package version * Release v0.0.2
When running tests that check for error cases, calls to
core.error
orcore.warning
are made, which internally execute commands on the runner before being output to stdout (seeIssueCommand
)The
::warning::
and::error::
commands create annotations, which pollute the run logs and are misleading since these are expected failures from testing.From: actions/toolkit#118, we can globally mock
process.stdout.write
to alter any::
commands so that they aren't mistakenly executed during testing.