11 Commits

Author SHA1 Message Date
Nate Fischer
dbac0a724d refactor: use promises for utils.runScript
No change to logic. This swaps out utils.runScript() to return a Promise
instead of taking a callback. This also moves some of `test.cb()` cases
over to async functions instead.
2025-04-07 22:44:41 -07:00
Nate Fischer
39ebb71846 test: add coverage for exit function
This adds test coverage for the shell.exit() function. This also
refactors how we mock stdout/stderr and adds support for mocking
process.exit() (which was needed for this change).

While I was writing these tests, I realized there was an edge case I
missed in PR #1122. This change fixes that edge case.

Issue #1013
2023-11-11 18:27:54 -08:00
Nate Fischer
37b42fef25
test: misc test changes (#970)
No change to production logic.

This renames test cases with duplicate names, deletes a redundant test,
and uses the public `t.title` API in favor of `t._test.title`.

This is a prerequisite for updating ava.

Issue #969
2019-10-08 22:41:16 -07:00
Nate Fischer
1dd437eb6b
fix(mocks): fix conflict between mocks and skip (#863)
This fixes a conflict between mocks.init() and
utils.skipOnWin/skipOnUnix. mocks.init() mocks out process.stderr.write,
which utils.js implicitly depends on.

Instead, preserve stderr.write in a local variable to avoid polluting
mocked stdio and to correctly output warning messages.

Fixes #862
Test: locally apply mocks.init() inside test/which.js
2018-06-28 14:15:54 -07:00
Nate Fischer
38b57c8942 chore: add skipOnWin and skipOnUnix test helpers (#746)
This adds `skipOnWin` and `skipOnUnix` to help us manage our platform-dependent
tests. These methods give a nice warning message when we skip tests. We may also
consider adding warnings when running platform-dependent tests.

Part of the motivation for this is if we ever update to AVA v0.19. This version
requires at least one assertion per test case. While this could be disabled with
an AVA setting, we instead benefit from warnings for any case when we
unintentionally skip assertions.

This adds chalk as a dev dependency to enable colored messages.
2017-06-18 11:51:01 -07:00
Brandon Freitag
e8ec60bc2f Echo test mocks (#708)
* Add stdout/stderr test mocks

* Mock stdout/stderr during echo tests

* Fix lint issues

* Use 'use strict'

* Re-implement mocks as a prototype

* Implement mocks as a single-instance

* Remove redundant test

* Create mocked stdout/stderr.write methods once
2017-06-06 21:10:27 -07:00
Brandon Freitag
7949759463 Add support for removing fifos (#687)
* Add support for removing fifos in rm

* Add test for removing fifo

* Add mkfifo util for testing

* Use ES5 syntax in utils
2017-03-08 07:33:41 -08:00
Nate Fischer
4c48631d74 refactor: create common.execPath (#636)
Switch to using common.execPath instead of process.execPath directly and warn
electron users if we were unable to find the correct path to NodeJS.
2017-01-08 13:52:39 -08:00
Brandon Freitag
7fa4b995bf Finalize moving to ava (#630)
* Move ava-test/ directory to test/

* Remove unnecessary run-tests.js script

* Run only ava during npm test script
2016-12-20 11:27:02 -08:00
Nate Fischer
2395214fee chore: switch to eslint (#504)
* chore: switch to eslint

* fix: works on older versions of NodeJS now

* chore: fix curly braces

* chore: fix indents and remove jshint references
2016-08-07 12:16:29 -07:00
Nate Fischer
74f1ff8748 Commands that have multiple errors now produce cleaner log output. Errors are
echoed to stderr. exec() supports a new stderr field.
2016-01-12 17:02:19 -08:00