|
2 | 2 | extern crate cargotest;
|
3 | 3 | extern crate hamcrest;
|
4 | 4 |
|
| 5 | +use std::env; |
| 6 | +use std::fs::{self, File}; |
5 | 7 | use std::io::{Read, Write};
|
6 |
| -use std::fs::File; |
7 | 8 |
|
8 | 9 | use cargotest::sleep_ms;
|
9 | 10 | use cargotest::support::{project, execs, git};
|
@@ -1807,3 +1808,51 @@ fn cargo_home_at_root_works() {
|
1807 | 1808 | assert_that(p.cargo("build").arg("--frozen").env("CARGO_HOME", p.root()),
|
1808 | 1809 | execs().with_status(0));
|
1809 | 1810 | }
|
| 1811 | + |
| 1812 | +#[test] |
| 1813 | +fn relative_rustc() { |
| 1814 | + let p = project("the_exe") |
| 1815 | + .file("Cargo.toml", r#" |
| 1816 | + [package] |
| 1817 | + name = "foo" |
| 1818 | + version = "0.1.0" |
| 1819 | + "#) |
| 1820 | + .file("src/main.rs", r#" |
| 1821 | + use std::process::Command; |
| 1822 | + use std::env; |
| 1823 | +
|
| 1824 | + fn main() { |
| 1825 | + let mut cmd = Command::new("rustc"); |
| 1826 | + for arg in env::args_os().skip(1) { |
| 1827 | + cmd.arg(arg); |
| 1828 | + } |
| 1829 | + std::process::exit(cmd.status().unwrap().code().unwrap()); |
| 1830 | + } |
| 1831 | + "#) |
| 1832 | + .build(); |
| 1833 | + assert_that(p.cargo("build"), execs().with_status(0)); |
| 1834 | + |
| 1835 | + let src = p.root() |
| 1836 | + .join("target/debug/foo") |
| 1837 | + .with_extension(env::consts::EXE_EXTENSION); |
| 1838 | + |
| 1839 | + Package::new("a", "0.1.0").publish(); |
| 1840 | + |
| 1841 | + let p = project("lib") |
| 1842 | + .file("Cargo.toml", r#" |
| 1843 | + [package] |
| 1844 | + name = "lib" |
| 1845 | + version = "0.1.0" |
| 1846 | +
|
| 1847 | + [dependencies] |
| 1848 | + a = "0.1" |
| 1849 | + "#) |
| 1850 | + .file("src/lib.rs", "") |
| 1851 | + .build(); |
| 1852 | + |
| 1853 | + fs::copy(&src, p.root().join(src.file_name().unwrap())).unwrap(); |
| 1854 | + |
| 1855 | + let file = format!("./foo{}", env::consts::EXE_SUFFIX); |
| 1856 | + assert_that(p.cargo("build").env("RUSTC", &file), |
| 1857 | + execs().with_status(0)); |
| 1858 | +} |
0 commit comments