Skip to content

Commit 3e065ed

Browse files
authored
Fix running all tests with cargo nextest (#420)
1 parent 1b07d17 commit 3e065ed

File tree

4 files changed

+64
-28
lines changed

4 files changed

+64
-28
lines changed

.config/nextest.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[profile.default]
2+
# Default filter runs all tests on non-Windows platforms
3+
default-filter = 'all()'
4+
5+
# Retry flaky test on macOS
6+
[[profile.default.overrides]]
7+
platform = 'cfg(target_os = "macos")'
8+
filter = 'test(cleanup_on_drop)'
9+
retries = 3
10+
11+
# Test priority configuration - run tests in order of importance
12+
[[profile.default.overrides]]
13+
filter = 'package(butane_test_helper)'
14+
priority = 100
15+
16+
[[profile.default.overrides]]
17+
filter = 'package(butane_core)'
18+
priority = 80
19+
20+
[[profile.default.overrides]]
21+
filter = 'package(butane_cli)'
22+
priority = 60
23+
24+
[[profile.default.overrides]]
25+
filter = 'package(butane_tests)'
26+
priority = 40
27+
28+
[[profile.default.overrides]]
29+
filter = 'package(trybuild_tests)'
30+
priority = 20

.github/workflows/ci.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,13 @@ jobs:
7171
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH
7272
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_ENV
7373
echo BUTANE_PG_CONNSTR="host=localhost user=postgres password=root sslmode=disable port=5432" >> $GITHUB_ENV
74-
- name: Install sqlite (Windows)
74+
- name: Install sqlite on Windows using vcpkg
7575
if: runner.os == 'Windows'
76-
shell: cmd
7776
run: |
78-
choco install sqlite
79-
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
80-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
81-
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
82-
echo "C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_PATH
83-
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_ENV
77+
vcpkg install sqlite3:x64-windows
78+
echo "VCPKG_ROOT=C:/vcpkg" >> $GITHUB_ENV
79+
echo "SQLITE3_LIB_DIR=C:/vcpkg/installed/x64-windows/lib" >> $GITHUB_ENV
80+
echo "SQLITE3_INCLUDE_DIR=C:/vcpkg/installed/x64-windows/include" >> $GITHUB_ENV
8481
8582
- name: Add Rust nightly toolchain
8683
uses: actions-rust-lang/setup-rust-toolchain@v1
@@ -96,7 +93,7 @@ jobs:
9693
- name: Install tool binaries
9794
uses: taiki-e/install-action@v2
9895
with:
99-
tool: cargo-deny,editorconfig-checker,mise,typos
96+
tool: cargo-deny,cargo-nextest,editorconfig-checker,mise,typos
10097
- name: Install ephemeral-postgres via mise
10198
env:
10299
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -115,24 +112,18 @@ jobs:
115112
run: make lint-ci
116113
- name: Run cargo-deny
117114
run: cargo deny check all
118-
- name: Test Butane test helper with ephemeral-postgres
115+
- name: Test with mise tools
119116
if: runner.os != 'Windows'
120-
run: cd butane_test_helper && mise exec ephemeral-postgres -- cargo +stable test --all-features
121-
- name: Test Butane test helper without ephemeral-postgres
117+
run: mise exec ephemeral-postgres -- cargo +stable nextest run --all-features --no-fail-fast
118+
- name: Test without mise
122119
if: runner.os == 'Windows'
123-
run: cd butane_test_helper && cargo +stable test --all-features
124-
- name: Test Core
125-
run: cd butane_core && cargo +stable test --all-features
126-
- name: Test CLI
127-
run: cd butane_cli && cargo +stable test --all-features
128-
- name: Test
129-
run: cargo +stable test -p butane_tests --all-features
130-
- name: Test using trybuild
131-
run: cargo +stable test -p trybuild_tests
120+
run: cargo +stable nextest run --all-features --no-fail-fast
121+
132122
- name: Test doctests
133123
run: |
134-
cargo +stable test -p butane_codegen --all-features
135-
cargo +stable test -p butane --all-features
124+
cargo +stable test -p butane_codegen --doc
125+
cargo +stable test -p butane --doc --features async
126+
136127
- name: Check example migrations have been updated
137128
run: |
138129
set -ex
@@ -144,8 +135,8 @@ jobs:
144135
- name: Run tests in examples
145136
run: |
146137
set -ex
147-
cargo +stable test -p example --all-features
138+
cargo +stable nextest run -p example --all-features
148139
cd examples
149140
for dir in *; do
150-
cargo +stable test -p $dir --all-features
141+
cargo +stable nextest run -p $dir --all-features
151142
done

.mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tools]
22
"cargo:cargo-expand" = "latest"
3+
"cargo:cargo-nextest" = "latest"
34
"cargo:pep257" = "latest"
45
"cargo:timeout-cli" = "latest"
56
editorconfig-checker = "latest"

CONTRIBUTING.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,26 @@ Run all tests:
9191
cargo test
9292
```
9393

94+
It is also recommended to use cargo-nextest which provides many benefits, especially when running all tests:
95+
96+
```bash
97+
cargo nextest run
98+
```
99+
100+
Note cargo-nextest does not support doctests, [yet](https://github.com/nextest-rs/nextest/issues/16).
101+
102+
To check those:
103+
104+
```bash
105+
cargo test -p butane --doc --features async
106+
cargo test -p butane_codegen --doc # all doctest are ignored
107+
```
108+
94109
Run tests for a specific package:
95110

96111
```bash
97-
cargo test -p butane_core
98-
cargo test -p butane # doctests only
99-
cargo test -p butane_tests
112+
cargo test -p butane_core --all-features
113+
cargo test -p butane_tests --all-features
100114
cargo test -p trybuild_tests
101115
```
102116

0 commit comments

Comments
 (0)