|
1 |
| -use std::fs::{self, File}; |
2 |
| -use std::io::prelude::*; |
3 |
| - |
4 | 1 | use cargo;
|
5 |
| - |
6 | 2 | use cargo_test_support::paths::CargoPathExt;
|
7 | 3 | use cargo_test_support::registry::Package;
|
8 | 4 | use cargo_test_support::{
|
9 | 5 | basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, project,
|
10 | 6 | };
|
11 | 7 | use cargo_test_support::{cross_compile, is_nightly, paths};
|
12 | 8 | use cargo_test_support::{rustc_host, sleep_ms};
|
| 9 | +use std::fs; |
13 | 10 |
|
14 | 11 | #[cargo_test]
|
15 | 12 | fn cargo_test_simple() {
|
@@ -2421,10 +2418,7 @@ fn bin_does_not_rebuild_tests() {
|
2421 | 2418 | p.cargo("test -v").run();
|
2422 | 2419 |
|
2423 | 2420 | sleep_ms(1000);
|
2424 |
| - File::create(&p.root().join("src/main.rs")) |
2425 |
| - .unwrap() |
2426 |
| - .write_all(b"fn main() { 3; }") |
2427 |
| - .unwrap(); |
| 2421 | + fs::write(p.root().join("src/main.rs"), "fn main() { 3; }").unwrap(); |
2428 | 2422 |
|
2429 | 2423 | p.cargo("test -v --no-run")
|
2430 | 2424 | .with_stderr(
|
@@ -3787,19 +3781,19 @@ fn cargo_test_doctest_xcompile_runner() {
|
3787 | 3781 | let config = paths::root().join(".cargo/config");
|
3788 | 3782 |
|
3789 | 3783 | fs::create_dir_all(config.parent().unwrap()).unwrap();
|
3790 |
| - File::create(config) |
3791 |
| - .unwrap() |
3792 |
| - .write_all( |
3793 |
| - format!( |
3794 |
| - r#" |
| 3784 | + // Escape Windows backslashes for TOML config. |
| 3785 | + let runner_str = runner_path.to_str().unwrap().replace('\\', "\\\\"); |
| 3786 | + fs::write( |
| 3787 | + config, |
| 3788 | + format!( |
| 3789 | + r#" |
3795 | 3790 | [target.'cfg(target_arch = "x86")']
|
3796 | 3791 | runner = "{}"
|
3797 | 3792 | "#,
|
3798 |
| - runner_path.to_str().unwrap() |
3799 |
| - ) |
3800 |
| - .as_bytes(), |
3801 |
| - ) |
3802 |
| - .unwrap(); |
| 3793 | + runner_str |
| 3794 | + ), |
| 3795 | + ) |
| 3796 | + .unwrap(); |
3803 | 3797 |
|
3804 | 3798 | let p = project()
|
3805 | 3799 | .file("Cargo.toml", &basic_lib_manifest("foo"))
|
|
0 commit comments