Skip to content

Commit 878a4e1

Browse files
authoredJan 22, 2023
Use nextest as test runner to get junit test reports (awslabs#142)
1 parent 7945bbd commit 878a4e1

File tree

2 files changed

+136
-4
lines changed

2 files changed

+136
-4
lines changed
 

‎.config/nextest.toml

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# This is the default config used by nextest. It is embedded in the binary at
2+
# build time. It may be used as a template for .config/nextest.toml.
3+
4+
[store]
5+
# The directory under the workspace root at which nextest-related files are
6+
# written. Profile-specific storage is currently written to dir/<profile-name>.
7+
dir = "target/nextest"
8+
9+
# This section defines the default nextest profile. Custom profiles are layered
10+
# on top of the default profile.
11+
[profile.default]
12+
# "retries" defines the number of times a test should be retried. If set to a
13+
# non-zero value, tests that succeed on a subsequent attempt will be marked as
14+
# non-flaky. Can be overridden through the `--retries` option.
15+
# Examples
16+
# * retries = 3
17+
# * retries = { backoff = "fixed", count = 2, delay = "1s" }
18+
# * retries = { backoff = "exponential", count = 10, delay = "1s", jitter = true, max-delay = "10s" }
19+
retries = 3
20+
21+
# The number of threads to run tests with. Supported values are either an integer or
22+
# the string "num-cpus". Can be overridden through the `--test-threads` option.
23+
test-threads = "num-cpus"
24+
25+
# The number of threads required for each test. This is generally used in overrides to
26+
# mark certain tests as heavier than others. However, it can also be set as a global parameter.
27+
threads-required = 1
28+
29+
# Show these test statuses in the output.
30+
#
31+
# The possible values this can take are:
32+
# * none: no output
33+
# * fail: show failed (including exec-failed) tests
34+
# * retry: show flaky and retried tests
35+
# * slow: show slow tests
36+
# * pass: show passed tests
37+
# * skip: show skipped tests (most useful for CI)
38+
# * all: all of the above
39+
#
40+
# Each value includes all the values above it; for example, "slow" includes
41+
# failed and retried tests.
42+
#
43+
# Can be overridden through the `--status-level` flag.
44+
status-level = "pass"
45+
46+
# Similar to status-level, show these test statuses at the end of the run.
47+
final-status-level = "flaky"
48+
49+
# "failure-output" defines when standard output and standard error for failing tests are produced.
50+
# Accepted values are
51+
# * "immediate": output failures as soon as they happen
52+
# * "final": output failures at the end of the test run
53+
# * "immediate-final": output failures as soon as they happen and at the end of
54+
# the test run; combination of "immediate" and "final"
55+
# * "never": don't output failures at all
56+
#
57+
# For large test suites and CI it is generally useful to use "immediate-final".
58+
#
59+
# Can be overridden through the `--failure-output` option.
60+
failure-output = "immediate"
61+
62+
# "success-output" controls production of standard output and standard error on success. This should
63+
# generally be set to "never".
64+
success-output = "never"
65+
66+
# Cancel the test run on the first failure. For CI runs, consider setting this
67+
# to false.
68+
fail-fast = true
69+
70+
# Treat a test that takes longer than the configured 'period' as slow, and print a message.
71+
# See <https://nexte.st/book/slow-tests> for more information.
72+
#
73+
# Optional: specify the parameter 'terminate-after' with a non-zero integer,
74+
# which will cause slow tests to be terminated after the specified number of
75+
# periods have passed.
76+
# Example: slow-timeout = { period = "60s", terminate-after = 2 }
77+
slow-timeout = { period = "60s" }
78+
79+
# Treat a test as leaky if after the process is shut down, standard output and standard error
80+
# aren't closed within this duration.
81+
#
82+
# This usually happens in case of a test that creates a child process and lets it inherit those
83+
# handles, but doesn't clean the child process up (especially when it fails).
84+
#
85+
# See <https://nexte.st/book/leaky-tests> for more information.
86+
leak-timeout = "100ms"
87+
88+
[profile.default.junit]
89+
# Output a JUnit report into the given file inside 'store.dir/<profile-name>'.
90+
# If unspecified, JUnit is not written out.
91+
92+
# path = "junit.xml"
93+
94+
# The name of the top-level "report" element in JUnit report. If aggregating
95+
# reports across different test runs, it may be useful to provide separate names
96+
# for each report.
97+
report-name = "nextest-run"
98+
99+
# Whether standard output and standard error for passing tests should be stored in the JUnit report.
100+
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
101+
store-success-output = false
102+
103+
# Whether standard output and standard error for failing tests should be stored in the JUnit report.
104+
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
105+
#
106+
# Note that if a description can be extracted from the output, it is always stored in the
107+
# <description> element.
108+
store-failure-output = true
109+
110+
# This profile is activated if MIRI_SYSROOT is set.
111+
[profile.default-miri]
112+
# Miri tests take up a lot of memory, so only run 1 test at a time by default.
113+
test-threads = 1
114+
115+
[profile.ci]
116+
inherits = "test"
117+
# Print out output for failing tests as soon as they fail, and also at the end
118+
# of the run (for easy scrollability).
119+
failure-output = "immediate-final"
120+
# Do not cancel the test run on the first failure.
121+
fail-fast = false
122+
123+
[profile.ci.junit]
124+
path = "junit.xml"

‎.github/workflows/pipeline.yaml

+12-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- released
1414

1515
env:
16+
CARGO_TERM_COLOR: always
1617
PIPELINE_USER_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
1718
PIPELINE_USER_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1819
SAM_TEMPLATE_X86_64: template-x86_64.yaml
@@ -42,11 +43,13 @@ jobs:
4243
with:
4344
toolchain: stable
4445
components: clippy, rustfmt
46+
- uses: taiki-e/install-action@nextest
4547
- name: linting
4648
run: |
4749
cargo fmt -- --check
4850
cargo clippy -- -Dwarnings
49-
- run: cargo test
51+
- name: run unit and integration tests
52+
run: cargo nextest run --profile ci
5053

5154

5255
build:
@@ -416,7 +419,13 @@ jobs:
416419
- name: Collect Workflow Telemetry
417420
if: always()
418421
uses: runforesight/foresight-workflow-kit-action@v1
419-
422+
423+
- uses: dtolnay/rust-toolchain@master
424+
with:
425+
toolchain: stable
426+
components: clippy, rustfmt
427+
- uses: taiki-e/install-action@nextest
428+
420429
- uses: actions/checkout@v3
421430
- uses: actions/setup-python@v4
422431
with:
@@ -471,8 +480,7 @@ jobs:
471480
/lambda-web-adapter/e2e/zip/function-url = ZIP_FURL_ENDPOINT"
472481

473482
- name: run e2e tests
474-
run: |
475-
cargo test -- --ignored
483+
run: cargo nextest run --run-ignored ignored-only --profile ci
476484

477485
- name: remove the oci x86 integration test stacks
478486
working-directory: ./tests/e2e/fixtures/go-httpbin

0 commit comments

Comments
 (0)
Please sign in to comment.