Skip to content

Commit 643a476

Browse files
committed
Add test verifying that changing comments recompiles dependents
1 parent c65dcca commit 643a476

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_name = "foo"]
2+
#![crate_type = "lib"]
3+
// bbb
4+
pub struct Foo;
5+
6+
impl Foo {
7+
pub fn bar(self: Foo) {}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_name = "foo"]
2+
#![crate_type = "lib"]
3+
// aaa
4+
pub struct Foo;
5+
6+
impl Foo {
7+
pub fn bar(self: Foo) {}
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// tests that we can reuse an existing rlib instead of rebuilding
2+
// when changin a non-doc comments in a file
3+
use run_make_support::{rfs, rustc};
4+
use std::path::Path;
5+
use std::hash::{Hash, Hasher};
6+
7+
fn main() {
8+
let before = check_and_hash("before.rs");
9+
let after = check_and_hash("after.rs");
10+
dbg!(before, after);
11+
assert_eq!(before, after);
12+
}
13+
14+
fn check_and_hash<P>(filename: P) -> u64
15+
where
16+
P: AsRef<Path>,
17+
{
18+
rfs::rename(filename, "foo.rs");
19+
rustc().input("foo.rs").emit("metadata").run();
20+
// hash the output
21+
let bytes = rfs::read("libfoo.rmeta");
22+
let mut hasher = std::hash::DefaultHasher::new();
23+
bytes.hash(&mut hasher);
24+
hasher.finish()
25+
}

0 commit comments

Comments
 (0)