From 88738ca299179588e9abae6b8265c8287270edb6 Mon Sep 17 00:00:00 2001 From: Michael Suo Date: Sat, 16 Apr 2022 18:13:11 -0700 Subject: [PATCH] test: add integration test for dryrun error on init config --- tests/integration_test.rs | 22 +++++++++++++++++++ ...egration_test__excluding_dryrun_fails.snap | 11 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/snapshots/integration_test__excluding_dryrun_fails.snap diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 718ea1a..d44df4a 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -540,3 +540,25 @@ fn changed_init_causes_warning() -> Result<()> { assert_output_snapshot("changed_init_causes_warning_2", &mut cmd)?; Ok(()) } + +// If you forgot to include a `@{{DRYRUN}}` argument in the init command, there +// should be an error. +#[test] +fn excluding_dryrun_fails() -> Result<()> { + let config = temp_config( + "\ + [[linter]] + code = 'TESTLINTER' + include_patterns = [] + command = ['echo', 'foo'] + init_command = ['echo', 'bar'] + ", + )?; + let mut cmd = Command::cargo_bin("lintrunner")?; + cmd.arg(format!("--config={}", config.path().to_str().unwrap())); + + cmd.assert().failure(); + assert_output_snapshot("excluding_dryrun_fails", &mut cmd)?; + + Ok(()) +} diff --git a/tests/snapshots/integration_test__excluding_dryrun_fails.snap b/tests/snapshots/integration_test__excluding_dryrun_fails.snap new file mode 100644 index 0000000..a18a43a --- /dev/null +++ b/tests/snapshots/integration_test__excluding_dryrun_fails.snap @@ -0,0 +1,11 @@ +--- +source: tests/integration_test.rs +expression: output_lines + +--- +- "STDOUT:" +- "" +- "" +- "STDERR:" +- "error: Config for linter TESTLINTER defines init args but does not take a {{DRYRUN}} argument." +