Skip to content

Commit 03a6b6e

Browse files
committed
move the test
1 parent d2c71ca commit 03a6b6e

File tree

2 files changed

+110
-110
lines changed

2 files changed

+110
-110
lines changed

tests/testsuite/build.rs

+1-109
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::env;
2-
use std::fs::{self, File, OpenOptions};
2+
use std::fs::{self, File};
33
use std::io::prelude::*;
4-
use std::net::TcpListener;
5-
use std::thread;
64

75
use crate::support::paths::{root, CargoPathExt};
86
use crate::support::registry::Package;
@@ -2396,112 +2394,6 @@ fn rebuild_preserves_out_dir() {
23962394
.run();
23972395
}
23982396

2399-
#[test]
2400-
fn rebuild_on_mid_build_file_modification() {
2401-
let server = TcpListener::bind("127.0.0.1:0").unwrap();
2402-
let addr = server.local_addr().unwrap();
2403-
2404-
let p = project()
2405-
.file(
2406-
"Cargo.toml",
2407-
r#"
2408-
[workspace]
2409-
members = ["root", "proc_macro_dep"]
2410-
"#,
2411-
)
2412-
.file(
2413-
"root/Cargo.toml",
2414-
r#"
2415-
[project]
2416-
name = "root"
2417-
version = "0.1.0"
2418-
authors = []
2419-
2420-
[dependencies]
2421-
proc_macro_dep = { path = "../proc_macro_dep" }
2422-
"#,
2423-
)
2424-
.file(
2425-
"root/src/lib.rs",
2426-
r#"
2427-
#[macro_use]
2428-
extern crate proc_macro_dep;
2429-
2430-
#[derive(Noop)]
2431-
pub struct X;
2432-
"#,
2433-
)
2434-
.file(
2435-
"proc_macro_dep/Cargo.toml",
2436-
r#"
2437-
[project]
2438-
name = "proc_macro_dep"
2439-
version = "0.1.0"
2440-
authors = []
2441-
2442-
[lib]
2443-
proc-macro = true
2444-
"#,
2445-
)
2446-
.file(
2447-
"proc_macro_dep/src/lib.rs",
2448-
&format!(
2449-
r#"
2450-
extern crate proc_macro;
2451-
2452-
use std::io::Read;
2453-
use std::net::TcpStream;
2454-
use proc_macro::TokenStream;
2455-
2456-
#[proc_macro_derive(Noop)]
2457-
pub fn noop(_input: TokenStream) -> TokenStream {{
2458-
let mut stream = TcpStream::connect("{}").unwrap();
2459-
let mut v = Vec::new();
2460-
stream.read_to_end(&mut v).unwrap();
2461-
"".parse().unwrap()
2462-
}}
2463-
"#,
2464-
addr
2465-
),
2466-
)
2467-
.build();
2468-
let root = p.root();
2469-
2470-
let t = thread::spawn(move || {
2471-
let socket = server.accept().unwrap().0;
2472-
let mut file = OpenOptions::new()
2473-
.write(true)
2474-
.append(true)
2475-
.open(root.join("root/src/lib.rs"))
2476-
.unwrap();
2477-
writeln!(file, "// modified").expect("Failed to append to root sources");
2478-
drop(file);
2479-
drop(socket);
2480-
drop(server.accept().unwrap());
2481-
});
2482-
2483-
p.cargo("build")
2484-
.with_stderr(
2485-
"\
2486-
[COMPILING] proc_macro_dep v0.1.0 ([..]/proc_macro_dep)
2487-
[COMPILING] root v0.1.0 ([..]/root)
2488-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2489-
",
2490-
)
2491-
.run();
2492-
2493-
p.cargo("build")
2494-
.with_stderr(
2495-
"\
2496-
[COMPILING] root v0.1.0 ([..]/root)
2497-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2498-
",
2499-
)
2500-
.run();
2501-
2502-
t.join().ok().unwrap();
2503-
}
2504-
25052397
#[test]
25062398
fn dep_no_libs() {
25072399
let foo = project()

tests/testsuite/freshness.rs

+109-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use std::fs::{self, File};
1+
use std::fs::{self, File, OpenOptions};
22
use std::io::prelude::*;
3+
use std::net::TcpListener;
4+
use std::thread;
35

46
use crate::support::paths::CargoPathExt;
57
use crate::support::registry::Package;
@@ -1309,3 +1311,109 @@ fn bust_patched_dep() {
13091311
)
13101312
.run();
13111313
}
1314+
1315+
#[test]
1316+
fn rebuild_on_mid_build_file_modification() {
1317+
let server = TcpListener::bind("127.0.0.1:0").unwrap();
1318+
let addr = server.local_addr().unwrap();
1319+
1320+
let p = project()
1321+
.file(
1322+
"Cargo.toml",
1323+
r#"
1324+
[workspace]
1325+
members = ["root", "proc_macro_dep"]
1326+
"#,
1327+
)
1328+
.file(
1329+
"root/Cargo.toml",
1330+
r#"
1331+
[project]
1332+
name = "root"
1333+
version = "0.1.0"
1334+
authors = []
1335+
1336+
[dependencies]
1337+
proc_macro_dep = { path = "../proc_macro_dep" }
1338+
"#,
1339+
)
1340+
.file(
1341+
"root/src/lib.rs",
1342+
r#"
1343+
#[macro_use]
1344+
extern crate proc_macro_dep;
1345+
1346+
#[derive(Noop)]
1347+
pub struct X;
1348+
"#,
1349+
)
1350+
.file(
1351+
"proc_macro_dep/Cargo.toml",
1352+
r#"
1353+
[project]
1354+
name = "proc_macro_dep"
1355+
version = "0.1.0"
1356+
authors = []
1357+
1358+
[lib]
1359+
proc-macro = true
1360+
"#,
1361+
)
1362+
.file(
1363+
"proc_macro_dep/src/lib.rs",
1364+
&format!(
1365+
r#"
1366+
extern crate proc_macro;
1367+
1368+
use std::io::Read;
1369+
use std::net::TcpStream;
1370+
use proc_macro::TokenStream;
1371+
1372+
#[proc_macro_derive(Noop)]
1373+
pub fn noop(_input: TokenStream) -> TokenStream {{
1374+
let mut stream = TcpStream::connect("{}").unwrap();
1375+
let mut v = Vec::new();
1376+
stream.read_to_end(&mut v).unwrap();
1377+
"".parse().unwrap()
1378+
}}
1379+
"#,
1380+
addr
1381+
),
1382+
)
1383+
.build();
1384+
let root = p.root();
1385+
1386+
let t = thread::spawn(move || {
1387+
let socket = server.accept().unwrap().0;
1388+
let mut file = OpenOptions::new()
1389+
.write(true)
1390+
.append(true)
1391+
.open(root.join("root/src/lib.rs"))
1392+
.unwrap();
1393+
writeln!(file, "// modified").expect("Failed to append to root sources");
1394+
drop(file);
1395+
drop(socket);
1396+
drop(server.accept().unwrap());
1397+
});
1398+
1399+
p.cargo("build")
1400+
.with_stderr(
1401+
"\
1402+
[COMPILING] proc_macro_dep v0.1.0 ([..]/proc_macro_dep)
1403+
[COMPILING] root v0.1.0 ([..]/root)
1404+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1405+
",
1406+
)
1407+
.run();
1408+
1409+
p.cargo("build")
1410+
.with_stderr(
1411+
"\
1412+
[COMPILING] root v0.1.0 ([..]/root)
1413+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1414+
",
1415+
)
1416+
.run();
1417+
1418+
t.join().ok().unwrap();
1419+
}

0 commit comments

Comments
 (0)