Skip to content

Commit 460bec2

Browse files
authored
Use cargo-nextest instead of regular cargo test (#1279)
… if available. Makes tests execute faster.
2 parents 39d86bd + 8c7c6d0 commit 460bec2

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed

.github/workflows/bridge-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
# include relevant information in the cache name
4646
prefix-key: "bridge-${{ matrix.rust }}"
4747

48+
- uses: taiki-e/install-action@nextest
49+
4850
- name: rustfmt
4951
run: cargo fmt -- --check
5052
working-directory: bridge

.github/workflows/rust-lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ jobs:
6666
# include relevant information in the cache name
6767
prefix-key: "rust-client-${{ matrix.rust }}"
6868

69+
- uses: taiki-e/install-action@nextest
70+
6971
- name: Clippy
7072
run: cargo clippy --all-targets --all-features -- -D warnings
7173
working-directory: rust
7274

7375
- name: Run tests
74-
run: cargo test --all
76+
run: cargo nextest run
7577
working-directory: rust

.github/workflows/server-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
# include relevant information in the cache name
4646
prefix-key: "server-${{ matrix.rust }}"
4747

48+
- uses: taiki-e/install-action@nextest
49+
4850
- name: rustfmt
4951
run: cargo fmt -- --check
5052
working-directory: server

bridge/run-tests.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
#!/bin/sh -e
1+
#!/bin/bash
2+
3+
if [[ -z "$TEST_COMMAND" ]]; then
4+
if [[ -z "$CARGO_HOME" ]]; then
5+
CARGO_HOME="$HOME/.cargo"
6+
fi
7+
8+
if command -v cargo-nextest || [[ -e "$CARGO_HOME/bin/cargo-nextest" ]]; then
9+
TEST_COMMAND="cargo nextest run"
10+
else
11+
TEST_COMMAND="cargo test"
12+
fi
13+
fi
214

315
AWS_DEFAULT_REGION="elasticmq" \
416
AWS_ACCESS_KEY_ID="x" \
517
AWS_SECRET_ACCESS_KEY="x" \
618
PUBSUB_EMULATOR_HOST=localhost:8085 \
719
PUBSUB_PROJECT_ID=local-project \
8-
cargo test --all-features -- "$@"
20+
${TEST_COMMAND} --all-features -- "$@"

server/run-tests.sh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
#!/bin/sh -e
1+
#!/bin/bash
22

3-
# Run tests with various configurations:
3+
# Run tests with various configurations.
4+
5+
if [[ -z "$TEST_COMMAND" ]]; then
6+
if [[ -z "$CARGO_HOME" ]]; then
7+
CARGO_HOME="$HOME/.cargo"
8+
fi
9+
10+
if command -v cargo-nextest || [[ -e "$CARGO_HOME/bin/cargo-nextest" ]]; then
11+
TEST_COMMAND="cargo nextest run"
12+
else
13+
TEST_COMMAND="cargo test"
14+
fi
15+
fi
416

517
# Common variables:
618
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
@@ -15,40 +27,40 @@ echo "*********** RUN 1 ***********"
1527
export SVIX_QUEUE_TYPE="redis"
1628
export SVIX_CACHE_TYPE="redis"
1729
export SVIX_REDIS_DSN="redis://localhost:6379"
18-
cargo test
19-
cargo test -- --ignored redis
30+
${TEST_COMMAND}
31+
${TEST_COMMAND} -- --ignored redis
2032
)
2133

2234
echo "*********** RUN 2 ***********"
2335
(
2436
export SVIX_QUEUE_TYPE="redis"
2537
export SVIX_CACHE_TYPE="memory"
2638
export SVIX_REDIS_DSN="redis://localhost:6379"
27-
cargo test
39+
${TEST_COMMAND}
2840
)
2941

3042
echo "*********** RUN 3 ***********"
3143
(
3244
export SVIX_QUEUE_TYPE="redis"
3345
export SVIX_CACHE_TYPE="none"
3446
export SVIX_REDIS_DSN="redis://localhost:6379"
35-
cargo test
47+
${TEST_COMMAND}
3648
)
3749

3850
echo "*********** RUN 4 ***********"
3951
(
4052
export SVIX_QUEUE_TYPE="rediscluster"
4153
export SVIX_CACHE_TYPE="rediscluster"
4254
export SVIX_REDIS_DSN="redis://localhost:6380"
43-
cargo test
44-
cargo test -- --ignored redis
55+
${TEST_COMMAND}
56+
${TEST_COMMAND} -- --ignored redis
4557
)
4658

4759
echo "*********** RUN 5 ***********"
4860
(
4961
export SVIX_QUEUE_TYPE="memory"
5062
export SVIX_CACHE_TYPE="none"
51-
cargo test
63+
${TEST_COMMAND}
5264
)
5365

5466
echo "*********** RUN 6 ***********"
@@ -57,6 +69,6 @@ echo "*********** RUN 6 ***********"
5769
export SVIX_CACHE_TYPE="redis"
5870
export SVIX_REDIS_DSN="redis://localhost:6379"
5971
export SVIX_RABBIT_DSN="amqp://xivs:xivs@localhost:5672/%2f"
60-
cargo test
61-
cargo test -- --ignored rabbitmq
72+
${TEST_COMMAND}
73+
${TEST_COMMAND} -- --ignored rabbitmq
6274
)

0 commit comments

Comments
 (0)