From 9b2f0de0c5c8be462e84742fc41991b54d9d9981 Mon Sep 17 00:00:00 2001 From: Chip Senkbeil Date: Sun, 11 Dec 2022 00:05:18 -0600 Subject: [PATCH] Reenable cli tests on windows (#156) Also fixes a failing Windows test that has different behavior than Linux/Unix --- .github/workflows/ci.yml | 9 ++++++--- tests/cli/repl/proc_spawn.rs | 35 +++++++++++++---------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f85af94..ff8218a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: target: ${{ matrix.target }} - uses: taiki-e/install-action@v1 with: - tool: cargo-nextest + tool: cargo-nextest@0.9.45 - uses: Swatinem/rust-cache@v2 - name: Check Cargo availability run: cargo --version @@ -153,6 +153,10 @@ jobs: } ELSE { New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force } + - name: Extend Windows retry count to be more resilient + if: matrix.os == 'windows-latest' + run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV + shell: bash - name: Run net tests (default features) run: cargo nextest run --profile ci --release -p distant-net - name: Build core (default features) @@ -172,7 +176,6 @@ jobs: run: cargo build --release - name: Run CLI tests (all features) run: cargo nextest run --profile ci --release --all-features - if: matrix.os != 'windows-latest' ssh-launch-tests: name: "Test ssh launch using Rust ${{ matrix.rust }} on ${{ matrix.os }}" runs-on: ${{ matrix.os }} @@ -191,7 +194,7 @@ jobs: toolchain: ${{ matrix.rust }} - uses: taiki-e/install-action@v1 with: - tool: cargo-nextest + tool: cargo-nextest@0.9.45 - uses: Swatinem/rust-cache@v2 - name: Check Cargo availability run: cargo --version diff --git a/tests/cli/repl/proc_spawn.rs b/tests/cli/repl/proc_spawn.rs index 0834eae..4ad0f0b 100644 --- a/tests/cli/repl/proc_spawn.rs +++ b/tests/cli/repl/proc_spawn.rs @@ -220,40 +220,31 @@ async fn should_support_json_to_forward_stdin_to_remote_process(mut json_repl: C // Now kill the process and wait for it to complete let id = rand::random::().to_string(); - let res_1 = json_repl + let res = json_repl .write_and_read_json(json!({ "id": id, "payload": { "type": "proc_kill", "id": proc_id, }, - })) .await .unwrap() .unwrap(); - let res_2 = json_repl.read_json_from_stdout().await.unwrap().unwrap(); - - // The order of responses may be different (kill could come before ok), so we need - // to check that we get one of each type - let got_ok = res_1["payload"]["type"] == "ok" || res_2["payload"]["type"] == "ok"; - let got_done = - res_1["payload"]["type"] == "proc_done" || res_2["payload"]["type"] == "proc_done"; - - if res_1["payload"]["type"] == "ok" { - assert_eq!(res_1["origin_id"], id, "JSON: {res_1}"); - } else if res_1["payload"]["type"] == "proc_done" { - assert_eq!(res_1["origin_id"], origin_id, "JSON: {res_1}"); - } - if res_2["payload"]["type"] == "ok" { - assert_eq!(res_2["origin_id"], id, "JSON: {res_2}"); - } else if res_2["payload"]["type"] == "proc_done" { - assert_eq!(res_2["origin_id"], origin_id, "JSON: {res_2}"); + // If the first response we get is proc_done, then we don't care bout the kill result + // as it can be an error if the process ended before the kill happened + // + // NOTE: The above is a situation in Windows, but I've not seen it happen with Mac/Linux. + if res["payload"]["type"] == "ok" { + let res = json_repl.read_json_from_stdout().await.unwrap().unwrap(); + assert_eq!( + res["payload"]["type"], "proc_done", + "Did not receive proc_done from killed process: {res}" + ); + } else { + assert_eq!(res["payload"]["type"], "proc_done", "JSON: {res}"); } - - assert!(got_ok, "Did not receive ok from proc_kill"); - assert!(got_done, "Did not receive proc_done from killed process"); } #[rstest]