Skip to content

Commit

Permalink
tests: limit to unit tests or use --features test-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed Oct 9, 2024
1 parent 3c5b97f commit 654dcee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https://github.com/cristianoliveira/funzzy"
edition = "2021"
default-run = "funzzy" # the binary to run when `cargo run` is called

[features]
test-integration = []

[dependencies]
docopt = "1"
serde = "1.0" # if you're using `derive(Deserialize)`
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ build: tests ## Execute all the tests and build funzzy binary

.PHONY: integration ## Exectute integration tests
integration:
@cargo test --test '*'
@cargo test --features test-integration

.PHONY: ci-integration
ci-integration:
@cargo test --test '*'
@cargo test --features test-integration

.PHONY: lint
lint:
Expand Down
21 changes: 20 additions & 1 deletion tests/common/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,25 @@ static IS_RUNNING_MULTITHREAD: std::sync::Mutex<u8> = std::sync::Mutex::new(0);
#[allow(dead_code)]
pub const CLEAR_SCREEN: &str = "";

#[allow(dead_code)]
#[cfg(not(feature = "test-integration"))]
pub fn with_example<F>(_: Options, _: F) -> ()
where
F: FnOnce(&mut Command, File) -> (),
{
println!("WARNING: Skipping integration tests");
()
}

#[cfg(not(feature = "test-integration"))]
pub fn with_output<F>(output_file_path: &str, handler: F) -> ()
where
F: FnOnce(&mut Command, File) -> (),
{
println!("WARNING: Skipping integration tests");
()
}

#[cfg(feature = "test-integration")]
pub fn with_example<F>(opts: Options, handler: F) -> ()
where
F: FnOnce(&mut Command, File) -> (),
Expand Down Expand Up @@ -90,6 +108,7 @@ where
.expect("failed to remove file after running test");
}

#[cfg(feature = "test-integration")]
#[allow(dead_code)]
pub fn with_output<F>(output_file_path: &str, handler: F) -> ()
where
Expand Down

0 comments on commit 654dcee

Please sign in to comment.