diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 00000000000..9f25c6ddb8a --- /dev/null +++ b/.config/nextest.toml @@ -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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c24e126239f..833bc65fdfe 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,6 +25,7 @@ env: # can override that behaviour CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git MSRV: "1.70" + NEXTEST_PROFILE: "ci" jobs: @@ -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 @@ -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: | @@ -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: diff --git a/lib/virtual-net/src/tests.rs b/lib/virtual-net/src/tests.rs index 960a4d2cf8b..6fa4ebd7b0c 100644 --- a/lib/virtual-net/src/tests.rs +++ b/lib/virtual-net/src/tests.rs @@ -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 { @@ -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();