Skip to content

Commit 09dc8a0

Browse files
tests: limit to unit tests or use --features test-integration
1 parent 3c5b97f commit 09dc8a0

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ repository = "https://github.com/cristianoliveira/funzzy"
88
edition = "2021"
99
default-run = "funzzy" # the binary to run when `cargo run` is called
1010

11+
[features]
12+
test-integration = []
13+
1114
[dependencies]
1215
docopt = "1"
1316
serde = "1.0" # if you're using `derive(Deserialize)`

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ build: tests ## Execute all the tests and build funzzy binary
1212

1313
.PHONY: integration ## Exectute integration tests
1414
integration:
15-
@cargo test --test '*'
15+
@cargo test --features test-integration
1616

1717
.PHONY: ci-integration
1818
ci-integration:
19-
@cargo test --test '*'
19+
@cargo test --features test-integration
2020

2121
.PHONY: lint
2222
lint:

nix/package-from-source.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ lib , rustPlatform , fetchFromGitHub , stdenv , darwin }:
22

3-
rustPlatform.buildRustPackage rec {
3+
rustPlatform.buildRustPackage {
44
pname = "funzzy";
55
version = "nightly-20240825";
66

@@ -40,7 +40,7 @@ rustPlatform.buildRustPackage rec {
4040
touch /tmp/fzz/accepts_full_or_relativepaths2.txt
4141
touch /tmp/fzz/accepts_full_or_relativepaths3.txt
4242
43-
RUST_BACKTRACE=1 cargo test --test '*' -- --nocapture
43+
RUST_BACKTRACE=1 cargo test -- --nocapture
4444
4545
rm -rf /tmp/fzz
4646
'';
@@ -59,7 +59,7 @@ rustPlatform.buildRustPackage rec {
5959
meta = with lib; {
6060
description = "A lightweight watcher";
6161
homepage = "https://github.com/cristianoliveira/funzzy";
62-
changelog = "https://github.com/cristianoliveira/funzzy/releases/tag/${src.rev}";
62+
changelog = "https://github.com/cristianoliveira/funzzy/releases";
6363
license = licenses.mit;
6464
maintainers = with maintainers; [ cristianoliveira ];
6565
};

tests/common/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,25 @@ static IS_RUNNING_MULTITHREAD: std::sync::Mutex<u8> = std::sync::Mutex::new(0);
2323
#[allow(dead_code)]
2424
pub const CLEAR_SCREEN: &str = "";
2525

26-
#[allow(dead_code)]
26+
#[cfg(not(feature = "test-integration"))]
27+
pub fn with_example<F>(_: Options, _: F) -> ()
28+
where
29+
F: FnOnce(&mut Command, File) -> (),
30+
{
31+
println!("WARNING: Skipping integration tests");
32+
()
33+
}
34+
35+
#[cfg(not(feature = "test-integration"))]
36+
pub fn with_output<F>(output_file_path: &str, handler: F) -> ()
37+
where
38+
F: FnOnce(&mut Command, File) -> (),
39+
{
40+
println!("WARNING: Skipping integration tests");
41+
()
42+
}
43+
44+
#[cfg(feature = "test-integration")]
2745
pub fn with_example<F>(opts: Options, handler: F) -> ()
2846
where
2947
F: FnOnce(&mut Command, File) -> (),
@@ -90,6 +108,7 @@ where
90108
.expect("failed to remove file after running test");
91109
}
92110

111+
#[cfg(feature = "test-integration")]
93112
#[allow(dead_code)]
94113
pub fn with_output<F>(output_file_path: &str, handler: F) -> ()
95114
where

0 commit comments

Comments
 (0)