Skip to content

Add --expect-* flags so CI steps can check the result to close #782 - #786

Merged
mathiasrw merged 44 commits into
mainfrom
fix/782
Oct 23, 2026
Merged

mathiasrw merged 44 commits into
mainfrom
fix/782

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #782

Stacked on #785.

Change

Flag Short Exit code 0 when
--expect-files -F at least 1 file is found
--expect-diff -z at least 1 file is changed
--expect-zero-diff -Z no file is changed
--expect-diff-all (long only) all files found are changed

When a check is not met, the exit code is 1. The run is as without the flags, so add --simulate to only check.

> rexreplace 'console\.log' '' 'src/**/*.js' --expect-zero-diff --simulate
src/app.js
 ❌ Expected no diff, but 1 file would change
  • A change is the same as for the names that are printed, so a match that gives the same text is not a change. A rename is a change.
  • The message says would with --simulate, --output and --output-match, and was or were without.
  • Piped data counts as one file.
  • With no files found, --expect-diff and --expect-diff-all are not met, and --expect-zero-diff is. --expect-files makes no files fail too.
  • A check that is not met is an error: it is told with ❌, also with --quiet, and it is in errors in the status report, so errors.length tells if anything was wrong. It is also in checks, so the CLI gives 1 when the failed checks are the only errors.
  • An error in a file still gives 2, also when a check is not met, as something went wrong.
  • --expect-zero-diff with --expect-diff or --expect-diff-all is an error in the CLI (exit code 3), and a panic in the engine.
  • The README has the flags, and code 1 in the table of exit codes.

Also in this PR

Tests

yarn test-ci passes: the demo on Node and Bun (now with --expect-*), and 969 Bun tests. There is one engine test file for each flag, and test/cli/expect.test.js.

@mathiasrw
mathiasrw added this pull request to stack #787 October 23, 2026 04:29
# Conflicts:
#	README.md
#	devguide.md
#	test/cli/debug.test.js
#	test/cli/delimiter.test.js
#	test/cli/glob-pipe.test.js
#	test/cli/run.sh
#	test/engine/encoding.test.js
#	test/engine/halt.test.js
#	test/fix/681.test.js
#	test/fix/683.test.js
#	test/fix/691.test.js
#	test/fix/700.test.js
#	test/fix/703.test.js
#	test/fix/708.test.js
#	test/fix/720.test.js
#	test/fix/728.test.js
#	test/fix/742.test.js
Base automatically changed from fix/780 to main October 23, 2026 09:45
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 09:45
# Conflicts:
#	README.md
#	src/cli.ts
#	src/engine.ts
#	test/cli/run.sh
#	test/engine/rename.test.js
#	test/helper.js
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 09:48
@mathiasrw
mathiasrw merged commit bf1be04 into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/782 branch October 23, 2026 09:53
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.

Add --expect-* flags so CI steps can check the result

1 participant