diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0130095be..73c1c4f21 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -609,3 +609,44 @@ jobs: ${SCCACHE_PATH} --show-stats ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" + + 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: + name: integration-tests + path: /home/runner/.cargo/bin/ + - name: Chmod for binary + run: chmod +x ${SCCACHE_PATH} + + - name: Prepare + run: | + rustup toolchain install nightly + cargo new coverage-test + cd coverage-test + 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 + run: | + ${SCCACHE_PATH} --show-stats + ${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]" diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index 861929c00..3c0503fc0 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, + 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, })) } }