Skip to content

Commit aa0082b

Browse files
committed
Add test verifying that changing comments recompiles dependents
1 parent f46ce66 commit aa0082b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// tests that changing the content of a comment will cause a change in the rmeta of a file
2+
use run_make_support::{rfs, rustc};
3+
use std::hash::{Hash, Hasher};
4+
use std::path::Path;
5+
6+
fn main() {
7+
let before = check_and_hash("before.rs");
8+
let after = check_and_hash("after.rs");
9+
dbg!(before, after);
10+
assert_neq!(before, after);
11+
}
12+
13+
fn check_and_hash<P>(filename: P) -> u64
14+
where
15+
P: AsRef<Path>,
16+
{
17+
rfs::rename(filename, "foo.rs");
18+
rustc().input("foo.rs").emit("metadata").run();
19+
// hash the output
20+
let bytes = rfs::read("libfoo.rmeta");
21+
let mut hasher = std::hash::DefaultHasher::new();
22+
bytes.hash(&mut hasher);
23+
hasher.finish()
24+
}

0 commit comments

Comments
 (0)