From 30b616e5ff1fd38aec2a982ebe1110cee1643cd7 Mon Sep 17 00:00:00 2001 From: yihau Date: Thu, 20 Apr 2023 13:17:41 +0800 Subject: [PATCH 1/9] ignore file not found error --- src/cache/cache.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cache/cache.rs b/src/cache/cache.rs index 5f2122a74..9ee0d1f84 100644 --- a/src/cache/cache.rs +++ b/src/cache/cache.rs @@ -259,7 +259,14 @@ impl CacheWrite { format!("failed to put object `{:?}` in cache entry", path) })?; } - (Err(e), false) => return Err(e), + (Err(e), false) => { + if let Some(io_err) = e.downcast_ref::() { + if io_err.kind() == io::ErrorKind::NotFound { + continue + } + } + return Err(e) + } (Err(_), true) => continue, } } From b9fb1616ada994a3b0155a9b51cd260aa88b7d7e Mon Sep 17 00:00:00 2001 From: yihau Date: Thu, 20 Apr 2023 17:56:30 +0800 Subject: [PATCH 2/9] Revert "ignore file not found error" This reverts commit 30b616e5ff1fd38aec2a982ebe1110cee1643cd7. --- src/cache/cache.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/cache/cache.rs b/src/cache/cache.rs index 9ee0d1f84..5f2122a74 100644 --- a/src/cache/cache.rs +++ b/src/cache/cache.rs @@ -259,14 +259,7 @@ impl CacheWrite { format!("failed to put object `{:?}` in cache entry", path) })?; } - (Err(e), false) => { - if let Some(io_err) = e.downcast_ref::() { - if io_err.kind() == io::ErrorKind::NotFound { - continue - } - } - return Err(e) - } + (Err(e), false) => return Err(e), (Err(_), true) => continue, } } From 42eac8c819635d273c804ab7a1f463bb8f355854 Mon Sep 17 00:00:00 2001 From: yihau Date: Thu, 20 Apr 2023 17:56:56 +0800 Subject: [PATCH 3/9] make gcno as optional files in rust compiler --- src/compiler/rust.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index 861929c00..face8535e 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -15,8 +15,8 @@ use crate::cache::FileObjectSource; use crate::compiler::args::*; use crate::compiler::{ - Cacheable, ColorMode, Compilation, CompileCommand, Compiler, CompilerArguments, CompilerHasher, - CompilerKind, CompilerProxy, HashResult, + c::ArtifactDescriptor, Cacheable, ColorMode, Compilation, CompileCommand, Compiler, + CompilerArguments, CompilerHasher, CompilerKind, CompilerProxy, HashResult, }; #[cfg(feature = "dist-client")] use crate::compiler::{DistPackagers, OutputsRewriter}; @@ -186,7 +186,7 @@ pub struct RustCompilation { /// The compiler inputs. inputs: Vec, /// The compiler outputs. - outputs: HashMap, + outputs: HashMap, /// The directories searched for rlibs crate_link_paths: Vec, /// The crate name being compiled. @@ -1513,19 +1513,37 @@ where .into_iter() .map(|o| { let p = output_dir.join(&o); - (o, p) + ( + o, + ArtifactDescriptor { + path: p, + optional: false, + }, + ) }) .collect::>(); let dep_info = if let Some(dep_info) = dep_info { let p = output_dir.join(&dep_info); - outputs.insert(dep_info.to_string_lossy().into_owned(), p.clone()); + outputs.insert( + dep_info.to_string_lossy().into_owned(), + ArtifactDescriptor { + path: p.clone(), + optional: false, + }, + ); Some(p) } else { None }; if let Some(gcno) = gcno { let p = output_dir.join(&gcno); - outputs.insert(gcno.to_string_lossy().into_owned(), p); + outputs.insert( + gcno.to_string_lossy().into_owned(), + ArtifactDescriptor { + path: p.clone(), + optional: true, + }, + ); } let mut arguments = arguments; // Request color output unless json was requested. The client will strip colors if needed. @@ -1761,8 +1779,8 @@ impl Compilation for RustCompilation { fn outputs<'a>(&'a self) -> Box + 'a> { Box::new(self.outputs.iter().map(|(k, v)| FileObjectSource { key: k.to_string(), - path: v.clone(), - optional: false, + path: v.path.clone(), + optional: v.optional, })) } } From 639976b4a39cf0ec2da3847bd48849576af0a6df Mon Sep 17 00:00:00 2001 From: yihau Date: Thu, 20 Apr 2023 18:08:32 +0800 Subject: [PATCH 4/9] fix redundant clone --- src/compiler/rust.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index face8535e..3c0503fc0 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -1540,7 +1540,7 @@ where outputs.insert( gcno.to_string_lossy().into_owned(), ArtifactDescriptor { - path: p.clone(), + path: p, optional: true, }, ); From d505f6558c816001556de859b171a53563ecedb7 Mon Sep 17 00:00:00 2001 From: yihau Date: Thu, 20 Apr 2023 19:16:11 +0800 Subject: [PATCH 5/9] add integration test, issues-1652 --- .github/workflows/integration-tests.yml | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0130095be..cf3e90921 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -609,3 +609,32 @@ jobs: ${SCCACHE_PATH} --show-stats ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" + + issues-1652: + runs-on: ubuntu-latest + needs: build + + strategy: + fail-fast: false + matrix: + version: [nightly-2023-02-08, nightly-2023-02-09] + steps: + - uses: actions/download-artifact@v3 + with: + name: integration-tests + path: /home/runner/.cargo/bin/ + - name: Chmod for binary + run: chmod +x ${SCCACHE_PATH} + + - name: Coverage test + run: | + rustup toolchain install ${{ matrix.version }} + cargo new hello + cd hello + echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml + cargo +${{ matrix.version }} test + env: + RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" + RUSTDOCFLAGS: "-Cpanic=abort" From adcec3a78330f0d7b709aa7af2c86d6cc388f500 Mon Sep 17 00:00:00 2001 From: yihau Date: Fri, 21 Apr 2023 17:07:05 +0800 Subject: [PATCH 6/9] make test more general --- .github/workflows/integration-tests.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cf3e90921..3ad4cbe90 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -610,14 +610,9 @@ jobs: ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" - issues-1652: + rust-test-coverage: runs-on: ubuntu-latest needs: build - - strategy: - fail-fast: false - matrix: - version: [nightly-2023-02-08, nightly-2023-02-09] steps: - uses: actions/download-artifact@v3 with: @@ -628,11 +623,11 @@ jobs: - name: Coverage test run: | - rustup toolchain install ${{ matrix.version }} + rustup toolchain install nightly cargo new hello cd hello echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml - cargo +${{ matrix.version }} test + cargo +nightly test env: RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache CARGO_INCREMENTAL: "0" From 3e0a3263cc30d228e3d9baf97a65a5fedf04288c Mon Sep 17 00:00:00 2001 From: yihau Date: Fri, 21 Apr 2023 17:57:03 +0800 Subject: [PATCH 7/9] move env to job level --- .github/workflows/integration-tests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 3ad4cbe90..09fb4dc88 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -613,6 +613,13 @@ jobs: rust-test-coverage: runs-on: ubuntu-latest needs: build + + env: + RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" + RUSTDOCFLAGS: "-Cpanic=abort" + steps: - uses: actions/download-artifact@v3 with: @@ -628,8 +635,3 @@ jobs: cd hello echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml cargo +nightly test - env: - RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" - RUSTDOCFLAGS: "-Cpanic=abort" From 9bbf8b42f2af151f432baaed19a87c683262043a Mon Sep 17 00:00:00 2001 From: yihau Date: Fri, 21 Apr 2023 18:03:24 +0800 Subject: [PATCH 8/9] test coverage twice and print status --- .github/workflows/integration-tests.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 09fb4dc88..927611351 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -628,10 +628,23 @@ jobs: - name: Chmod for binary run: chmod +x ${SCCACHE_PATH} - - name: Coverage test + - name: Prepare run: | rustup toolchain install nightly - cargo new hello - cd hello + cargo new coverage-test + cd coverage-test echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml - cargo +nightly test + + - name: "Coverage test #1" + run: cargo clean && cargo +nightly test + + - name: Output + run: ${SCCACHE_PATH} --show-stats + + - name: "Coverage test #2" + run: cargo clean && cargo +nightly test + + - name: Output + run: | + ${SCCACHE_PATH} --show-stats + ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" From 10b37a7c4ea304d40577c21c35814b936146f5e5 Mon Sep 17 00:00:00 2001 From: yihau Date: Fri, 21 Apr 2023 18:20:41 +0800 Subject: [PATCH 9/9] fix working directory --- .github/workflows/integration-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 927611351..73c1c4f21 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -636,12 +636,14 @@ jobs: echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml - name: "Coverage test #1" + working-directory: ./coverage-test run: cargo clean && cargo +nightly test - name: Output run: ${SCCACHE_PATH} --show-stats - name: "Coverage test #2" + working-directory: ./coverage-test run: cargo clean && cargo +nightly test - name: Output