Skip to content

Commit bb614d4

Browse files
committed
Fix test include_overrides_gitignore.
1 parent 2510c0c commit bb614d4

File tree

1 file changed

+19
-101
lines changed

1 file changed

+19
-101
lines changed

tests/testsuite/git.rs

Lines changed: 19 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,132 +2484,50 @@ fn two_at_rev_instead_of_tag() {
24842484
}
24852485

24862486
#[test]
2487-
#[ignore] // accesses crates.io
24882487
fn include_overrides_gitignore() {
2489-
let p = git::new("reduction", |repo| {
2488+
// Make sure that `package.include` takes precedence over .gitignore.
2489+
let p = git::new("foo", |repo| {
24902490
repo.file(
24912491
"Cargo.toml",
24922492
r#"
24932493
[package]
2494-
name = "reduction"
2494+
name = "foo"
24952495
version = "0.5.0"
2496-
authors = ["pnkfelix"]
2497-
build = "tango-build.rs"
2498-
include = ["src/lib.rs", "src/incl.rs", "src/mod.md", "tango-build.rs", "Cargo.toml"]
2499-
2500-
[build-dependencies]
2501-
filetime = "0.1"
2496+
include = ["src/lib.rs", "ignored.txt", "Cargo.toml"]
25022497
"#,
25032498
)
25042499
.file(
25052500
".gitignore",
25062501
r#"
2507-
target
2502+
/target
25082503
Cargo.lock
2509-
# Below files represent generated code, thus not managed by `git`
2510-
src/incl.rs
2511-
src/not_incl.rs
2512-
"#,
2513-
)
2514-
.file(
2515-
"tango-build.rs",
2516-
r#"
2517-
extern crate filetime;
2518-
use filetime::FileTime;
2519-
use std::fs::{self, File};
2520-
2521-
fn main() {
2522-
// generate files, or bring their timestamps into sync.
2523-
let source = "src/mod.md";
2524-
2525-
let metadata = fs::metadata(source).unwrap();
2526-
let mtime = FileTime::from_last_modification_time(&metadata);
2527-
let atime = FileTime::from_last_access_time(&metadata);
2528-
2529-
// sync time stamps for generated files with time stamp of source file.
2530-
2531-
let files = ["src/not_incl.rs", "src/incl.rs"];
2532-
for file in files.iter() {
2533-
File::create(file).unwrap();
2534-
filetime::set_file_times(file, atime, mtime).unwrap();
2535-
}
2536-
}
2537-
"#,
2538-
)
2539-
.file("src/lib.rs", "mod not_incl; mod incl;")
2540-
.file(
2541-
"src/mod.md",
2542-
r#"
2543-
(The content of this file does not matter since we are not doing real codegen.)
2504+
ignored.txt
25442505
"#,
25452506
)
2507+
.file("src/lib.rs", "")
2508+
.file("ignored.txt", "")
2509+
.file("build.rs", "fn main() {}")
25462510
})
25472511
.unwrap();
25482512

2549-
println!("build 1: all is new");
2550-
p.cargo("build -v")
2551-
.with_stderr(
2552-
"\
2553-
[UPDATING] `[..]` index
2554-
[DOWNLOADED] filetime [..]
2555-
[DOWNLOADED] libc [..]
2556-
[COMPILING] libc [..]
2557-
[RUNNING] `rustc --crate-name libc [..]`
2558-
[COMPILING] filetime [..]
2559-
[RUNNING] `rustc --crate-name filetime [..]`
2560-
[COMPILING] reduction [..]
2561-
[RUNNING] `rustc --crate-name build_script_tango_build tango-build.rs --crate-type bin [..]`
2562-
[RUNNING] `[..]/build-script-tango-build`
2563-
[RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]`
2564-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2565-
",
2566-
)
2567-
.run();
2568-
2569-
println!("build 2: nothing changed; file timestamps reset by build script");
2570-
p.cargo("build -v")
2571-
.with_stderr(
2572-
"\
2573-
[FRESH] libc [..]
2574-
[FRESH] filetime [..]
2575-
[FRESH] reduction [..]
2576-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2577-
",
2578-
)
2579-
.run();
2580-
2581-
println!("build 3: touch `src/not_incl.rs`; expect build script **not** re-run");
2582-
sleep_ms(1000);
2583-
File::create(p.root().join("src").join("not_incl.rs")).unwrap();
2584-
2513+
p.cargo("build").run();
2514+
p.change_file("ignored.txt", "Trigger rebuild.");
25852515
p.cargo("build -v")
25862516
.with_stderr(
25872517
"\
2588-
[FRESH] libc [..]
2589-
[FRESH] filetime [..]
2590-
[COMPILING] reduction [..]
2591-
[RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]`
2518+
[COMPILING] foo v0.5.0 ([..])
2519+
[RUNNING] `[..]build-script-build[..]`
2520+
[RUNNING] `rustc --crate-name foo src/lib.rs [..]`
25922521
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
25932522
",
25942523
)
25952524
.run();
2596-
2597-
// This final case models the bug from rust-lang/cargo#4135: an
2598-
// explicitly included file should cause a build-script re-run,
2599-
// even if that same file is matched by `.gitignore`.
2600-
println!("build 4: touch `src/incl.rs`; expect build script re-run");
2601-
sleep_ms(1000);
2602-
File::create(p.root().join("src").join("incl.rs")).unwrap();
2603-
2604-
p.cargo("build -v")
2605-
.with_stderr(
2525+
p.cargo("package --list --allow-dirty")
2526+
.with_stdout(
26062527
"\
2607-
[FRESH] libc [..]
2608-
[FRESH] filetime [..]
2609-
[COMPILING] reduction [..]
2610-
[RUNNING] `[..]/build-script-tango-build`
2611-
[RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]`
2612-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2528+
Cargo.toml
2529+
ignored.txt
2530+
src/lib.rs
26132531
",
26142532
)
26152533
.run();

0 commit comments

Comments
 (0)