Skip to content

Commit 733a049

Browse files
committed
add tests for no-default-features
1 parent a1baa69 commit 733a049

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ jobs:
7777
run: cargo build
7878
- name: Run tests
7979
run: cargo nextest run
80+
- name: Run tests (without default features)
81+
run: cargo nextest run --no-default-features

tests/fixture_tests.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) The nextest Contributors
22
// SPDX-License-Identifier: MIT OR Apache-2.0
33

4+
#[cfg(feature = "timestamps")]
45
use chrono::DateTime;
56
use goldenfile::Mint;
67
use owo_colors::OwoColorize;
@@ -13,9 +14,14 @@ use std::time::Duration;
1314
fn fixtures() {
1415
let mut mint = Mint::new("tests/fixtures");
1516

17+
#[cfg(all(feature = "timestamps", feature = "uuids", feature = "strip-ansi"))]
1618
let f = mint
1719
.new_goldenfile("basic_report.xml")
1820
.expect("creating new goldenfile succeeds");
21+
#[cfg(not(any(feature = "timestamps", feature = "uuids", feature = "strip-ansi")))]
22+
let f = mint
23+
.new_goldenfile("basic_report_no_default_features.xml")
24+
.expect("creating new goldenfile succeeds");
1925

2026
let basic_report = basic_report();
2127
basic_report
@@ -25,13 +31,15 @@ fn fixtures() {
2531

2632
fn basic_report() -> Report {
2733
let mut report = Report::new("my-test-run");
34+
#[cfg(feature = "timestamps")]
2835
report.set_timestamp(
2936
DateTime::parse_from_rfc2822("Thu, 1 Apr 2021 10:52:37 -0800")
3037
.expect("valid RFC2822 datetime"),
3138
);
3239
report.set_time(Duration::new(42, 234_567_890));
3340

3441
let mut test_suite = TestSuite::new("testsuite0");
42+
#[cfg(feature = "timestamps")]
3543
test_suite.set_timestamp(
3644
DateTime::parse_from_rfc2822("Thu, 1 Apr 2021 10:52:39 -0800")
3745
.expect("valid RFC2822 datetime"),
@@ -74,11 +82,13 @@ fn basic_report() -> Report {
7482
.set_message("skipped message");
7583
// no description to test that.
7684
let mut test_case = TestCase::new("testcase3", test_case_status);
85+
#[cfg(feature = "timestamps")]
7786
test_case
7887
.set_timestamp(
7988
DateTime::parse_from_rfc2822("Thu, 1 Apr 2021 11:52:41 -0700")
8089
.expect("valid RFC2822 datetime"),
81-
)
90+
);
91+
test_case
8292
.set_assertions(20)
8393
.set_system_out("testcase3 output")
8494
.set_system_err("testcase3 error");
@@ -138,6 +148,8 @@ fn basic_report() -> Report {
138148
test_suite.add_property(Property::new("env", "FOOBAR"));
139149

140150
report.add_test_suite(test_suite);
151+
#[cfg(feature = "uuids")]
152+
report.set_uuid(uuid::Uuid::parse_str("0500990f-0df3-4722-bbeb-90a75b8aa6bd").expect("uuid parsing succeeds"));
141153

142154
report
143155
}

tests/fixtures/basic_report.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites name="my-test-run" tests="7" failures="2" errors="1" timestamp="2021-04-01T10:52:37.000-08:00" time="42.235">
2+
<testsuites name="my-test-run" tests="7" failures="2" errors="1" uuid="0500990f-0df3-4722-bbeb-90a75b8aa6bd" timestamp="2021-04-01T10:52:37.000-08:00" time="42.235">
33
<testsuite name="testsuite0" tests="7" disabled="1" errors="1" failures="2" timestamp="2021-04-01T10:52:39.000-08:00">
44
<properties>
55
<property name="env" value="FOOBAR"/>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="my-test-run" tests="7" failures="2" errors="1" time="42.235">
3+
<testsuite name="testsuite0" tests="7" disabled="1" errors="1" failures="2">
4+
<properties>
5+
<property name="env" value="FOOBAR"/>
6+
</properties>
7+
<testcase name="testcase0">
8+
<system-out>testcase0-output</system-out>
9+
</testcase>
10+
<testcase name="testcase1" time="4.242">
11+
<failure message="testcase1-message">this is the failure description</failure>
12+
<system-err>some sort of failure output</system-err>
13+
</testcase>
14+
<testcase name="testcase2" time="0.000">
15+
<error type="error type">testcase2 error description</error>
16+
</testcase>
17+
<testcase name="testcase3" assertions="20">
18+
<skipped message="skipped message" type="skipped type"/>
19+
<system-out>testcase3 output</system-out>
20+
<system-err>testcase3 error</system-err>
21+
</testcase>
22+
<testcase name="testcase4" time="661.661">
23+
<flakyFailure type="flaky failure type">this is a flaky failure description</flakyFailure>
24+
<flakyError type="flaky error type">flaky error description
25+
<stackTrace>flaky stack trace</stackTrace>
26+
<system-out>flaky system output</system-out>
27+
<system-err>flaky system error with [34mANSI escape codes[39m</system-err>
28+
</flakyError>
29+
</testcase>
30+
<testcase name="testcase5" time="0.156">
31+
<failure>main test failure description</failure>
32+
<rerunFailure type="retry failure type">
33+
</rerunFailure>
34+
<rerunError type="retry error type">
35+
<stackTrace>retry error stack trace</stackTrace>
36+
<system-out>retry error system output</system-out>
37+
</rerunError>
38+
</testcase>
39+
<testcase name="testcase6">
40+
<properties>
41+
<property name="step" value="foobar"/>
42+
</properties>
43+
</testcase>
44+
</testsuite>
45+
</testsuites>

0 commit comments

Comments
 (0)