Skip to content

Conversation

joshmgross
Copy link
Contributor

When running tests that check for error cases, calls to core.error or core.warning are made, which internally execute commands on the runner before being output to stdout (see IssueCommand)

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.

@joshmgross joshmgross requested a review from yacaovsnc October 31, 2019 18:23
// We don't want :: commands to be executed by the runner during tests
// Replace any :: with :
if (!str.match(/^::/)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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:

  1. 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
  2. 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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what about stderr?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@joshmgross joshmgross merged commit 526c940 into master Oct 31, 2019
@joshmgross joshmgross deleted the joshmgross/silence-test-commands branch October 31, 2019 19:06
joshmgross added a commit that referenced this pull request Nov 4, 2019
* 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
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