Skip to content

Commit

Permalink
Preparing the repo for use with "cargo nextest"
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed Oct 3, 2023
1 parent afaa023 commit 76ad310
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
19 changes: 19 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Do not cancel the test run on the first failure.
fail-fast = false
# Automatically mark a test as "slow" after 60 seconds, then kill it after 180s
slow-timeout = { period = "60s", terminate-after = 3 }

[[profile.default.overrides]]
# Create-exe tests tend to be pretty flaky
filter = "test(create_exe)"
retries = 3

[[profile.default.overrides]]
# Snapshot tests tend to be flaky because they implicitly rely on how the OS will
# schedule threads. Our pipe flushing is also pretty unreliable.
filter = "test(snapshot)"
retries = 3
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
# can override that behaviour
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.70"
NEXTEST_PROFILE: "ci"

jobs:

Expand Down Expand Up @@ -371,6 +372,8 @@ jobs:
with:
toolchain: "nightly-2023-05-25"
target: ${{ matrix.metadata.target }}
- name: Install Nextest
uses: taiki-e/install-action@nextest
- name: Install Windows-GNU linker
if: ${{ matrix.metadata.build == 'windows-gnu' }}
shell: bash
Expand Down Expand Up @@ -595,6 +598,8 @@ jobs:
with:
toolchain: ${{ env.MSRV }}
target: ${{ matrix.metadata.target }}
- name: Install Nextest
uses: taiki-e/install-action@nextest
- name: Install LLVM (macOS Apple Silicon)
if: matrix.metadata.os == 'macos-11.0' && !matrix.metadata.llvm_url
run: |
Expand Down Expand Up @@ -696,6 +701,8 @@ jobs:
with:
toolchain: ${{ env.MSRV }}
target: ${{ matrix.metadata.target }}
- name: Install Nextest
uses: taiki-e/install-action@nextest
- name: Cache
uses: whywaita/actions-cache-s3@v2
with:
Expand Down
24 changes: 11 additions & 13 deletions lib/virtual-net/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ async fn setup_pipe(

#[cfg(feature = "remote")]
async fn test_tcp(client: RemoteNetworkingClient, _server: RemoteNetworkingServer) {
static PORT: AtomicU16 = AtomicU16::new(8000);
let addr = SocketAddr::V4(SocketAddrV4::new(
Ipv4Addr::LOCALHOST,
PORT.fetch_add(1, Ordering::SeqCst),
));
tracing::info!("listening on {addr}");
let mut listener = client
.listen_tcp(addr.clone(), false, false, false)
.listen_tcp(
SocketAddr::from((Ipv4Addr::LOCALHOST, 0)),
false,
false,
false,
)
.await
.unwrap();
let addr = listener.addr_local().unwrap();
tracing::info!("listening on {addr}");

const TEST1: &'static str = "the cat ran up the wall!";
const TEST2: &'static str = "...and fell off the roof! raise the roof! oop oop";
const TEST1: &str = "the cat ran up the wall!";
const TEST2: &str = "...and fell off the roof! raise the roof! oop oop";

tracing::info!("spawning acceptor worker thread");
tokio::task::spawn(async move {
Expand All @@ -104,10 +105,7 @@ async fn test_tcp(client: RemoteNetworkingClient, _server: RemoteNetworkingServe

tracing::info!("connecting to listening socket");
let mut socket = client
.connect_tcp(
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)),
addr,
)
.connect_tcp(SocketAddr::from((Ipv4Addr::LOCALHOST, 0)), addr)
.await
.unwrap();

Expand Down

0 comments on commit 76ad310

Please sign in to comment.