From e32efaa5a1fdcb8ff24142b66ecd6d29aa5e4f71 Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Mon, 15 Feb 2016 18:08:37 -0500 Subject: [PATCH] allow feature-gated integration tests for unimplemented functionality --- Cargo.toml | 1 + Makefile | 9 ++++++++- README.md | 5 +++++ build.rs | 2 +- tests/printf.rs | 12 ++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0fa2cac40..f35b2cab2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,7 @@ generic = [ "yes", ] default = ["generic", "unix"] +test_unimplemented = [] [dependencies] uucore = { path="src/uucore" } diff --git a/Makefile b/Makefile index 9a580c379..f418606b6 100644 --- a/Makefile +++ b/Makefile @@ -177,6 +177,13 @@ TEST_PROGS := \ TESTS := \ $(sort $(filter $(UTILS),$(filter-out $(SKIP_UTILS),$(TEST_PROGS)))) +TEST_NO_FAIL_FAST := +TEST_SPEC_FEATURE := +ifneq ($(SPEC),) +TEST_NO_FAIL_FAST :=--no-fail-fast +TEST_SPEC_FEATURE := test_unimplemented +endif + define BUILD_EXE build_exe_$(1): ${CARGO} build ${CARGOFLAGS} ${PROFILE_CMD} -p $(1) @@ -184,7 +191,7 @@ endef define TEST_INTEGRATION test_integration_$(1): build_exe_$(1) - ${CARGO} test ${CARGOFLAGS} --test $(1) --features $(1) --no-default-features + ${CARGO} test ${CARGOFLAGS} --test $(1) --features "$(1) $(TEST_SPEC_FEATURE)" --no-default-features $(TEST_NO_FAIL_FAST) endef define TEST_BUSYBOX diff --git a/README.md b/README.md index 94e1249cc..819ee4f78 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,11 @@ To test only a few of the available utilities: make UTILS='UTILITY_1 UTILITY_2' test ``` +To include tests for unimplemented behavior: +``` +make UTILS='UTILITY_1 UTILITY_2' SPEC=y test +``` + Run busybox tests ----------------- diff --git a/build.rs b/build.rs index 7f1cd301e..29c9a1f21 100644 --- a/build.rs +++ b/build.rs @@ -12,7 +12,7 @@ pub fn main() { if val == "1" && key.starts_with(feature_prefix) { let krate = key[feature_prefix.len()..].to_lowercase(); match krate.as_ref() { - "default" | "unix" | "generic" => continue, + "default" | "unix" | "generic" | "test_unimplemented" => continue, _ => {}, } crates.push(krate.to_string()); diff --git a/tests/printf.rs b/tests/printf.rs index 52370b751..be3fae7fb 100644 --- a/tests/printf.rs +++ b/tests/printf.rs @@ -188,6 +188,18 @@ fn sub_num_dec_trunc() { expect_stdout(vec!["pi is ~ %g", "3.1415926535"], "pi is ~ 3.141593"); } +#[cfg_attr(not(feature="test_unimplemented"),ignore)] +#[test] +fn sub_num_hex_float_lower() { + expect_stdout(vec!["%a", ".875"], "0xep-4"); +} + +#[cfg_attr(not(feature="test_unimplemented"),ignore)] +#[test] +fn sub_num_hex_float_upper() { + expect_stdout(vec!["%A", ".875"], "0XEP-4"); +} + #[test] fn sub_minwidth() { expect_stdout(vec!["hello %7s", "world"], "hello world");