summaryrefslogtreecommitdiff
path: root/cli/tests/integration/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-27 16:52:49 -0400
committerGitHub <noreply@github.com>2023-02-27 16:52:49 -0400
commit7c090b1b14e6b5000dbbed434525387c414ca62c (patch)
tree1645fbd8a8b1aee55f79cfe74d2bb7ecadcf5215 /cli/tests/integration/mod.rs
parent6bbb4c3af60d568a34e1472a0721ddd8a3dab469 (diff)
chore: test builders for integration tests (#17965)
Start of adding test builders to simplify integration tests. I only updated a few test files. We can complete upgrading over time.
Diffstat (limited to 'cli/tests/integration/mod.rs')
-rw-r--r--cli/tests/integration/mod.rs61
1 files changed, 58 insertions, 3 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index d102b486d..6d1daf7d7 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -5,12 +5,20 @@ macro_rules! itest(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[test]
fn $name() {
- (test_util::CheckOutputIntegrationTest {
+ let test = test_util::CheckOutputIntegrationTest {
$(
$key: $value,
)*
.. Default::default()
- }).run()
+ };
+ let output = test.output();
+ test_util::assert_exit_code!(output, test.exit_code);
+ if !test.output.is_empty() {
+ assert!(test.output_str.is_none());
+ test_util::assert_output_file!(output, test.output);
+ } else {
+ test_util::assert_output_text!(output, test.output_str.unwrap_or(""));
+ }
}
}
);
@@ -20,7 +28,42 @@ macro_rules! itest_flaky(
($name:ident {$( $key:ident: $value:expr,)*}) => {
#[flaky_test::flaky_test]
fn $name() {
- (test_util::CheckOutputIntegrationTest {
+ let test = test_util::CheckOutputIntegrationTest {
+ $(
+ $key: $value,
+ )*
+ .. Default::default()
+ };
+ let output = test.output();
+ test_util::assert_exit_code!(output, test.exit_code);
+ if !test.output.is_empty() {
+ assert!(test.output_str.is_none());
+ test_util::assert_output_file!(output, test.output);
+ } else {
+ test_util::assert_output_text!(output, test.output_str.unwrap_or(""));
+ }
+ }
+}
+);
+
+#[macro_export]
+macro_rules! context(
+({$( $key:ident: $value:expr,)*}) => {
+ test_util::TestContext::create(test_util::TestContextOptions {
+ $(
+ $key: $value,
+ )*
+ .. Default::default()
+ })
+}
+);
+
+#[macro_export]
+macro_rules! itest_steps(
+($name:ident {$( $key:ident: $value:expr,)*}) => {
+ #[test]
+ fn $name() {
+ (test_util::CheckOutputIntegrationTestSteps {
$(
$key: $value,
)*
@@ -30,6 +73,18 @@ macro_rules! itest_flaky(
}
);
+#[macro_export]
+macro_rules! command_step(
+({$( $key:ident: $value:expr,)*}) => {
+ test_util::CheckOutputIntegrationTestCommandStep {
+ $(
+ $key: $value,
+ )*
+ .. Default::default()
+ }
+}
+);
+
// These files have `_tests.rs` suffix to make it easier to tell which file is
// the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`)
// when both are open, especially for two tabs in VS Code