Skip to content

Commit 3b70d6b

Browse files
authored
fix: rust coverage test meets compile error for missing debuginfo (#1740)
1 parent 2c84fb6 commit 3b70d6b

File tree

2 files changed

+67
-8
lines changed

2 files changed

+67
-8
lines changed

.github/workflows/integration-tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,44 @@ jobs:
612612
${SCCACHE_PATH} --show-stats
613613
614614
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
615+
616+
rust-test-coverage:
617+
runs-on: ubuntu-latest
618+
needs: build
619+
620+
env:
621+
RUSTC_WRAPPER: /home/runner/.cargo/bin/sccache
622+
CARGO_INCREMENTAL: "0"
623+
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
624+
RUSTDOCFLAGS: "-Cpanic=abort"
625+
626+
steps:
627+
- uses: actions/download-artifact@v3
628+
with:
629+
name: integration-tests
630+
path: /home/runner/.cargo/bin/
631+
- name: Chmod for binary
632+
run: chmod +x ${SCCACHE_PATH}
633+
634+
- name: Prepare
635+
run: |
636+
rustup toolchain install nightly
637+
cargo new coverage-test
638+
cd coverage-test
639+
echo "serde = { version = \"1.0\", features = [\"derive\"] }" >> Cargo.toml
640+
641+
- name: "Coverage test #1"
642+
working-directory: ./coverage-test
643+
run: cargo clean && cargo +nightly test
644+
645+
- name: Output
646+
run: ${SCCACHE_PATH} --show-stats
647+
648+
- name: "Coverage test #2"
649+
working-directory: ./coverage-test
650+
run: cargo clean && cargo +nightly test
651+
652+
- name: Output
653+
run: |
654+
${SCCACHE_PATH} --show-stats
655+
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"

src/compiler/rust.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use crate::cache::FileObjectSource;
1616
use crate::compiler::args::*;
1717
use crate::compiler::{
18-
Cacheable, ColorMode, Compilation, CompileCommand, Compiler, CompilerArguments, CompilerHasher,
19-
CompilerKind, CompilerProxy, HashResult,
18+
c::ArtifactDescriptor, Cacheable, ColorMode, Compilation, CompileCommand, Compiler,
19+
CompilerArguments, CompilerHasher, CompilerKind, CompilerProxy, HashResult,
2020
};
2121
#[cfg(feature = "dist-client")]
2222
use crate::compiler::{DistPackagers, OutputsRewriter};
@@ -186,7 +186,7 @@ pub struct RustCompilation {
186186
/// The compiler inputs.
187187
inputs: Vec<PathBuf>,
188188
/// The compiler outputs.
189-
outputs: HashMap<String, PathBuf>,
189+
outputs: HashMap<String, ArtifactDescriptor>,
190190
/// The directories searched for rlibs
191191
crate_link_paths: Vec<PathBuf>,
192192
/// The crate name being compiled.
@@ -1513,19 +1513,37 @@ where
15131513
.into_iter()
15141514
.map(|o| {
15151515
let p = output_dir.join(&o);
1516-
(o, p)
1516+
(
1517+
o,
1518+
ArtifactDescriptor {
1519+
path: p,
1520+
optional: false,
1521+
},
1522+
)
15171523
})
15181524
.collect::<HashMap<_, _>>();
15191525
let dep_info = if let Some(dep_info) = dep_info {
15201526
let p = output_dir.join(&dep_info);
1521-
outputs.insert(dep_info.to_string_lossy().into_owned(), p.clone());
1527+
outputs.insert(
1528+
dep_info.to_string_lossy().into_owned(),
1529+
ArtifactDescriptor {
1530+
path: p.clone(),
1531+
optional: false,
1532+
},
1533+
);
15221534
Some(p)
15231535
} else {
15241536
None
15251537
};
15261538
if let Some(gcno) = gcno {
15271539
let p = output_dir.join(&gcno);
1528-
outputs.insert(gcno.to_string_lossy().into_owned(), p);
1540+
outputs.insert(
1541+
gcno.to_string_lossy().into_owned(),
1542+
ArtifactDescriptor {
1543+
path: p,
1544+
optional: true,
1545+
},
1546+
);
15291547
}
15301548
let mut arguments = arguments;
15311549
// Request color output unless json was requested. The client will strip colors if needed.
@@ -1761,8 +1779,8 @@ impl Compilation for RustCompilation {
17611779
fn outputs<'a>(&'a self) -> Box<dyn Iterator<Item = FileObjectSource> + 'a> {
17621780
Box::new(self.outputs.iter().map(|(k, v)| FileObjectSource {
17631781
key: k.to_string(),
1764-
path: v.clone(),
1765-
optional: false,
1782+
path: v.path.clone(),
1783+
optional: v.optional,
17661784
}))
17671785
}
17681786
}

0 commit comments

Comments
 (0)