| 43 | |
| 44 | impl Fixture { |
| 45 | fn new(repository: bool) -> Self { |
| 46 | let dir = TempDir::new().unwrap(); |
| 47 | let source = dir.path().join("source"); |
| 48 | let target = dir.path().join("target"); |
| 49 | fs::create_dir_all(source.join("src")).unwrap(); |
| 50 | fs::write( |
| 51 | source.join("Cargo.toml"), |
| 52 | "[package]\nname = \"version-fixture\"\nversion = \"0.19.1\"\nedition = \"2021\"\n", |
| 53 | ) |
| 54 | .unwrap(); |
| 55 | fs::write(source.join("build.rs"), include_str!("../../build.rs")).unwrap(); |
| 56 | fs::write( |
| 57 | source.join("src/main.rs"), |
| 58 | "fn main() { println!(\"{}\", env!(\"ATOMIC_CLI_VERSION\")); }\n", |
| 59 | ) |
| 60 | .unwrap(); |
| 61 | fs::write(source.join("tracked.txt"), "original\n").unwrap(); |
| 62 | if repository { |
| 63 | git(&source, &["init", "--initial-branch=dev"]); |
| 64 | git(&source, &["add", "."]); |
| 65 | git(&source, &["commit", "-m", "Initial source"]); |
| 66 | } |
| 67 | Self { |
| 68 | dir, |
| 69 | source, |
| 70 | target, |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | fn build(&self, source: &Path, channel: Option<&str>, commit: Option<&str>) -> String { |
| 75 | let mut command = Command::new(env!("CARGO")); |