coliru

A minimal, flexible, dotfile installer
git clone https://git.ashermorgan.net/coliru/
Log | Files | Refs | README

commit 8c1b2f12888886685a57b9e68ad5b7948370ac24
parent 8f976aeef62773d38d856da0081c3b76b3cd28a5
Author: Asher Morgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Wed, 26 Jun 2024 13:37:51 -0700

Update example manifest

Diffstat:
MREADME.md | 76++++++++++++++++++++++++++++++++++++++++------------------------------------
Dexamples/bar | 1-
Dexamples/baz | 3---
Dexamples/foo | 1-
Aexamples/gitconfig | 6++++++
Dexamples/invalid.yml | 14--------------
Aexamples/manifest-invalid.yml | 7+++++++
Mexamples/manifest.yml | 45++++++++++++++++++++++++++++++++-------------
Aexamples/script.bat | 3+++
Aexamples/script.sh | 4++++
Aexamples/vimrc | 5+++++
Msrc/manifest.rs | 51++++++++++++++++++++++++++++++++++-----------------
Mtests/basic.rs | 178+++++++++++++++++++++++++++++++++++++++----------------------------------------
13 files changed, 218 insertions(+), 176 deletions(-)

diff --git a/README.md b/README.md @@ -8,8 +8,8 @@ To uninstall `coliru`, run `cargo uninstall coliru` ## Usage Dotfiles are defined as a series of steps inside a manifest file that are - executed conditionally based on tag rules. -To install dotfiles, pass the manifest file and tag rules to `coliru`: +executed conditionally based on tag rules. To install dotfiles, pass the +manifest file and tag rules to `coliru`: ``` coliru path/to/manifest.yml --tag-rules tag1 tag2,tag3 ^tag4 @@ -22,47 +22,51 @@ Some helpful options include: - `--copy`, `-c`: Interpret link commands as copy commands ## Manifest File -Manifests are defined using YAML. -Each manifest contains a series of steps that are executed to install the - dotfiles. -Each step contains an array of tags and any number of copy, link, or run - commands. -Each command is run from the directory containing the manifest file. -The copy command copies a file from a source (`src`) to a (`dst`). -The link command links a file from a source (`src`) to a (`dst`) using symbolic - links on Unix platforms and hard links on Windows. +Manifests are defined using YAML. Each manifest contains a series of steps that +are executed to install the dotfiles. Each step contains an array of tags and +any number of copy, link, or run commands. Each command is run from the +directory containing the manifest file. The copy command copies a file from a +source (`src`) to a (`dst`). The link command links a file from a source (`src`) +to a (`dst`) using symbolic links on Unix platforms and hard links on Windows. Finally, the run command executes a script (`src`) from the command line, using - `sh` on Unix platforms and `powershell` on Windows, with an optional - `prefix` (e.g. `python3`) or `postfix` (e.g. `arg1 arg2 arg3`) string. -Inside `postfix`, `$COLIRU_RULES` will be expanded into a space-delimited list - of the current tag rules. +`sh` on Unix platforms and `powershell` on Windows, with an optional `prefix` +(e.g. `python3`) or `postfix` (e.g. `arg1 arg2 arg3`) string. Inside `postfix`, +`$COLIRU_RULES` will be expanded into a space-delimited list of the current tag +rules. -Example YAML manifest: +Example YAML manifest (see [`examples/manifest.yml`](examples/manifest.yml) for +more details): ```yml steps: - copy: - - src: git_dotfiles/.gitconfig - dst: ~/.gitconfig - link: - - src: vim_dotfiles/.vimrc - dst: ~/.vimrc + - src: gitconfig + dst: ~/.gitconfig.coliru + tags: [ windows, linux, macos ] + + - link: + - src: vimrc + dst: ~/.vimrc.coliru # Will create symbolic link on Linux & MacOS + run: + - src: script.sh + prefix: sh # unecessary on Unix if script.sh is executable + postfix: arg1 $COLIRU_RULES tags: [ linux, macos ] - - run: - - src: install_programs.sh - prefix: bash # Unecessary if install_programs.sh is executable - postfix: $COLIRU_RULES -y - tags: [ linux ] + + - link: + - src: vimrc + dst: ~/_vimrc.coliru # Will create hard link on Windows + run: + - src: script.bat + postfix: arg1 $COLIRU_RULES + tags: [ windows ] ``` ## Tag Rules -Tag rules are specified on the command line using the `--tag-rules` option. -In order for a manifest step to be executed, its tags must satisfy all of the - tag rules. -If no tags rules are provided, all manifest steps will be executed. -Each tag rule contains a comma separated list of tags that will satisfy the - rule. -A leading caret (`^`) will negate the entire rule. -In other words, commas correspond to OR, carets to NOT, and the spaces between - rules to AND. -So the tag rules `A B,C ^D,E` are equivalent to `A && (B || C) && !(D || E)`. +Tag rules are specified on the command line using the `--tag-rules` option. In +order for a manifest step to be executed, its tags must satisfy all of the tag +rules. If no tags rules are provided, all manifest steps will be executed. Each +tag rule contains a comma separated list of tags that will satisfy the rule. A +leading caret (`^`) will negate the entire rule. In other words, commas +correspond to OR, carets to NOT, and the spaces between rules to AND. So the tag +rules `A B,C ^D,E` are equivalent to `A && (B || C) && !(D || E)`. diff --git a/examples/bar b/examples/bar @@ -1 +0,0 @@ -bar! diff --git a/examples/baz b/examples/baz @@ -1,3 +0,0 @@ -#!/usr/bin/sh - -echo "baz! (called with: $@)" > ~/baz diff --git a/examples/foo b/examples/foo @@ -1 +0,0 @@ -foo! diff --git a/examples/gitconfig b/examples/gitconfig @@ -0,0 +1,6 @@ +[core] + editor = vim + +[user] +# name = Change me! +# email = Change me! diff --git a/examples/invalid.yml b/examples/invalid.yml @@ -1,14 +0,0 @@ -# Invalid manifest - -steps: - - not_copy: - - src: foo - dst: ~/foo - - src: bar - dst: ~/test/bar - tags: [ a, b ] - - - copy: - - not_src: baz - dst: /baz - tags: [ b, c ] diff --git a/examples/manifest-invalid.yml b/examples/manifest-invalid.yml @@ -0,0 +1,7 @@ +# Invalid manifest + +steps: + - copy: + - not_src: foo + dst: /foo + tags: [ b, c ] diff --git a/examples/manifest.yml b/examples/manifest.yml @@ -1,17 +1,36 @@ -# Valid manifest +# Dotfile repo structure: +# . +# ├── gitconfig +# ├── script.bat +# ├── script.sh +# ├── manifest.yml +# └── vimrc + +# For testing purposes, all files are given the .coliru suffix so they won't +# overwrite existing dotfiles. The .vimrc file is linked to its destination so +# that changes are synced with the dotfile repo. In contrast, the .gitconfig +# file is only copied so that the name & email fields can be modified without +# changing the version in the dotfile repo. steps: - copy: - - src: foo - dst: /foo - link: - - src: foo - dst: ~/foo - - src: bar - dst: ~/test/bar - tags: [ a, b ] + - src: gitconfig + dst: ~/.gitconfig.coliru + tags: [ windows, linux, macos ] + + - link: + - src: vimrc + dst: ~/.vimrc.coliru # Will create symbolic link on Linux & MacOS + run: + - src: script.sh + prefix: sh # unecessary on Unix if script.sh is executable + postfix: arg1 $COLIRU_RULES + tags: [ linux, macos ] - - run: - - src: baz - postfix: arg1 $COLIRU_RULES arg2 - tags: [ c ] + - link: + - src: vimrc + dst: ~/_vimrc.coliru # Will create hard link on Windows + run: + - src: script.bat + postfix: arg1 $COLIRU_RULES + tags: [ windows ] diff --git a/examples/script.bat b/examples/script.bat @@ -0,0 +1,3 @@ +@ECHO OFF +ECHO script.bat called with %* +ECHO script.bat called with %* > log.txt diff --git a/examples/script.sh b/examples/script.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +echo "script.sh called with $@" +echo "script.sh called with $@" > log.txt diff --git a/examples/vimrc b/examples/vimrc @@ -0,0 +1,5 @@ +" A basic vim config: +set hlsearch +set incsearch +set number +syntax enable diff --git a/src/manifest.rs b/src/manifest.rs @@ -66,8 +66,8 @@ pub fn parse_manifest_file(path: &Path) -> Result<Manifest, String> { mod tests { use super::*; - #[cfg(target_os = "linux")] #[test] + #[cfg(target_os = "linux")] fn parse_manifest_file_missing() { let expected = "No such file or directory (os error 2)"; let actual = parse_manifest_file(Path::new("examples/missing.yml")); @@ -76,8 +76,8 @@ mod tests { #[test] fn parse_manifest_file_invalid() { - let expected = "steps[1].copy[0]: missing field `src` at line 12 column 7"; - let actual = parse_manifest_file(Path::new("examples/invalid.yml")); + let expected = "steps[0].copy[0]: missing field `src` at line 5 column 7"; + let actual = parse_manifest_file(Path::new("examples/manifest-invalid.yml")); assert_eq!(actual, Err(String::from(expected))); } @@ -88,35 +88,52 @@ mod tests { Step { copy: vec![ CopyLinkOptions { - src: String::from("foo"), - dst: String::from("/foo"), + src: String::from("gitconfig"), + dst: String::from("~/.gitconfig.coliru"), }, ], + link: vec![], + run: vec![], + tags: vec![ + String::from("windows"), + String::from("linux"), + String::from("macos") + ], + }, + Step { + copy: vec![], link: vec![ CopyLinkOptions { - src: String::from("foo"), - dst: String::from("~/foo"), + src: String::from("vimrc"), + dst: String::from("~/.vimrc.coliru"), }, - CopyLinkOptions { - src: String::from("bar"), - dst: String::from("~/test/bar"), + ], + run: vec![ + RunOptions { + src: String::from("script.sh"), + prefix: String::from("sh"), + postfix: String::from("arg1 $COLIRU_RULES"), }, ], - run: vec![], - tags: vec![String::from("a"), String::from("b")], + tags: vec![String::from("linux"), String::from("macos")], }, Step { copy: vec![], - link: vec![], + link: vec![ + CopyLinkOptions { + src: String::from("vimrc"), + dst: String::from("~/_vimrc.coliru"), + }, + ], run: vec![ RunOptions { - src: String::from("baz"), + src: String::from("script.bat"), prefix: String::from(""), - postfix: String::from("arg1 $COLIRU_RULES arg2"), + postfix: String::from("arg1 $COLIRU_RULES"), }, ], - tags: vec![String::from("c")], - } + tags: vec![String::from("windows")], + }, ], base_dir: PathBuf::from("examples"), }; diff --git a/tests/basic.rs b/tests/basic.rs @@ -1,36 +1,26 @@ mod common; use common::*; -use std::fs::{create_dir_all, read_to_string, remove_file}; +use std::env::current_exe; +use std::fs::{copy, read_to_string, remove_file}; use std::path::Path; /// Create a basic manifest file and its associated dotfiles in a directory fn manifest_1(dir: &Path) { - let manifest = "\ -steps: - - copy: - - src: git_dotfiles/.gitconfig - dst: ~/.gitconfig - link: - - src: vim_dotfiles/.vimrc - dst: ~/.vimrc - tags: [ windows, linux, macos ] - - link: - - src: vim_dotfiles/.vimrc - dst: ~/_vimrc - tags: [ windows ] - - run: - - src: install_programs.sh - prefix: bash # Unecessary if install_programs.sh is executable - postfix: $COLIRU_RULES -y - tags: [ linux ] -"; - write_file(&dir.join("manifest.yml"), manifest); - create_dir_all(&dir.join("git_dotfiles")).unwrap(); - write_file(&dir.join("git_dotfiles").join(".gitconfig"), "git config"); - create_dir_all(&dir.join("vim_dotfiles")).unwrap(); - write_file(&dir.join("vim_dotfiles").join(".vimrc"), "vim config"); - write_file(&dir.join("install_programs.sh"), "echo $@ > log"); + // Copy files from examples + let examples = current_exe().unwrap().parent().unwrap().to_path_buf() + .join("../../../examples"); + let copy_file = |name: &str| { + copy(examples.join(name), &dir.join(name)).unwrap(); + }; + copy_file("script.bat"); + copy_file("script.sh"); + copy_file("manifest.yml"); + + // Create simplified config files + write_file(&dir.join("gitconfig"), "git #1"); + write_file(&dir.join("vimrc"), "vim #1"); + } #[test] @@ -64,24 +54,25 @@ fn test_standard() { manifest_1(&dir.dir); let expected = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig -[1/3] Link vim_dotfiles/.vimrc to ~/.vimrc -[3/3] Run bash install_programs.sh linux -y +[1/3] Copy gitconfig to ~/.gitconfig.coliru +[2/3] Link vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 linux +script.sh called with arg1 linux "; assert_eq!(&stdout_to_string(&mut cmd), expected); assert_eq!(&stderr_to_string(&mut cmd), ""); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("git_dotfiles").join(".gitconfig"), "git #2"); - write_file(&dir.dir.join("vim_dotfiles").join(".vimrc"), "vim #2"); - let git_contents = read_to_string(&dir.dir.join(".gitconfig")).unwrap(); - let vim1_contents = read_to_string(&dir.dir.join(".vimrc")).unwrap(); + write_file(&dir.dir.join("gitconfig"), "git #2"); + write_file(&dir.dir.join("vimrc"), "vim #2"); + let git_contents = read_to_string(&dir.dir.join(".gitconfig.coliru")).unwrap(); + let vim1_contents = read_to_string(&dir.dir.join(".vimrc.coliru")).unwrap(); let vim2_exists = dir.dir.join("_vimrc").exists(); - let log_contents = read_to_string(&dir.dir.join("log")).unwrap(); - assert_eq!(git_contents, "git config"); + let log_contents = read_to_string(&dir.dir.join("log.txt")).unwrap(); + assert_eq!(git_contents, "git #1"); assert_eq!(vim1_contents, "vim #2"); assert_eq!(vim2_exists, false); - assert_eq!(log_contents, "linux -y\n"); + assert_eq!(log_contents, "script.sh called with arg1 linux\n"); } #[test] @@ -91,49 +82,52 @@ fn test_run_alternate_tag_rules_1() { manifest_1(&dir.dir); let expected = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig -[1/3] Link vim_dotfiles/.vimrc to ~/.vimrc +[1/3] Copy gitconfig to ~/.gitconfig.coliru +[2/3] Link vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 macos +script.sh called with arg1 macos "; assert_eq!(&stdout_to_string(&mut cmd), expected); assert_eq!(&stderr_to_string(&mut cmd), ""); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("git_dotfiles").join(".gitconfig"), "git #2"); - write_file(&dir.dir.join("vim_dotfiles").join(".vimrc"), "vim #2"); - let git_contents = read_to_string(&dir.dir.join(".gitconfig")).unwrap(); - let vim1_contents = read_to_string(&dir.dir.join(".vimrc")).unwrap(); + write_file(&dir.dir.join("gitconfig"), "git #2"); + write_file(&dir.dir.join("vimrc"), "vim #2"); + let git_contents = read_to_string(&dir.dir.join(".gitconfig.coliru")).unwrap(); + let vim1_contents = read_to_string(&dir.dir.join(".vimrc.coliru")).unwrap(); let vim2_exists = dir.dir.join("_vimrc").exists(); - let log_exists = dir.dir.join("log").exists(); - assert_eq!(git_contents, "git config"); + let log_contents = read_to_string(&dir.dir.join("log.txt")).unwrap(); + assert_eq!(git_contents, "git #1"); assert_eq!(vim1_contents, "vim #2"); assert_eq!(vim2_exists, false); - assert_eq!(log_exists, false); + assert_eq!(log_contents, "script.sh called with arg1 macos\n"); } #[test] #[cfg(target_os = "linux")] fn test_run_alternate_tag_rules_2() { let (dir, mut cmd) = setup("test_run_alternate_tag_rules_2"); - cmd.args(["manifest.yml", "-t", "linux,windows", "^macos"]); + cmd.args(["manifest.yml", "-t", "linux,macos", "^windows"]); manifest_1(&dir.dir); let expected = "\ -[2/3] Link vim_dotfiles/.vimrc to ~/_vimrc -[3/3] Run bash install_programs.sh linux,windows ^macos -y +[2/3] Link vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 linux,macos ^windows +script.sh called with arg1 linux,macos ^windows "; assert_eq!(&stdout_to_string(&mut cmd), expected); assert_eq!(&stderr_to_string(&mut cmd), ""); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("vim_dotfiles").join(".vimrc"), "vim #2"); - let git_exists = dir.dir.join(".gitconfig").exists(); - let vim1_exists = dir.dir.join(".vimrc").exists(); - let vim2_contents = read_to_string(&dir.dir.join("_vimrc")).unwrap(); - let log_contents = read_to_string(&dir.dir.join("log")).unwrap(); + write_file(&dir.dir.join("vimrc"), "vim #2"); + let git_exists = dir.dir.join(".gitconfig.coliru").exists(); + let vim1_contents = read_to_string(&dir.dir.join(".vimrc.coliru")).unwrap(); + let vim2_exists = dir.dir.join("_vimrc").exists(); + let log_contents = read_to_string(&dir.dir.join("log.txt")).unwrap(); assert_eq!(git_exists, false); - assert_eq!(vim1_exists, false); - assert_eq!(vim2_contents, "vim #2"); - assert_eq!(log_contents, "linux,windows ^macos -y\n"); + assert_eq!(vim1_contents, "vim #2"); + assert_eq!(vim2_exists, false); + assert_eq!(log_contents, "script.sh called with arg1 linux,macos ^windows\n"); } #[test] @@ -143,18 +137,18 @@ fn test_dry_run() { manifest_1(&dir.dir); let expected = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig (DRY RUN) -[1/3] Link vim_dotfiles/.vimrc to ~/.vimrc (DRY RUN) -[3/3] Run bash install_programs.sh linux -y (DRY RUN) +[1/3] Copy gitconfig to ~/.gitconfig.coliru (DRY RUN) +[2/3] Link vimrc to ~/.vimrc.coliru (DRY RUN) +[2/3] Run sh script.sh arg1 linux (DRY RUN) "; assert_eq!(&stdout_to_string(&mut cmd), expected); assert_eq!(&stderr_to_string(&mut cmd), ""); // Assert files are correctly copied/linked/run - let git_exists = dir.dir.join(".gitconfig").exists(); - let vim1_exists = dir.dir.join(".vimrc").exists(); + let git_exists = dir.dir.join(".gitconfig.coliru").exists(); + let vim1_exists = dir.dir.join(".vimrc.coliru").exists(); let vim2_exists = dir.dir.join("_vimrc").exists(); - let log_exists = dir.dir.join("log").exists(); + let log_exists = dir.dir.join("log.txt").exists(); assert_eq!(git_exists, false); assert_eq!(vim1_exists, false); assert_eq!(vim2_exists, false); @@ -169,24 +163,25 @@ fn test_copy() { manifest_1(&dir.dir); let expected = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig -[1/3] Copy vim_dotfiles/.vimrc to ~/.vimrc -[3/3] Run bash install_programs.sh linux -y +[1/3] Copy gitconfig to ~/.gitconfig.coliru +[2/3] Copy vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 linux +script.sh called with arg1 linux "; assert_eq!(&stdout_to_string(&mut cmd), expected); assert_eq!(&stderr_to_string(&mut cmd), ""); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("git_dotfiles").join(".gitconfig"), "git #2"); - write_file(&dir.dir.join("vim_dotfiles").join(".vimrc"), "vim #2"); - let git_contents = read_to_string(&dir.dir.join(".gitconfig")).unwrap(); - let vim1_contents = read_to_string(&dir.dir.join(".vimrc")).unwrap(); + write_file(&dir.dir.join("gitconfig"), "git #2"); + write_file(&dir.dir.join("vimrc"), "vim #2"); + let git_contents = read_to_string(&dir.dir.join(".gitconfig.coliru")).unwrap(); + let vim1_contents = read_to_string(&dir.dir.join(".vimrc.coliru")).unwrap(); let vim2_exists = dir.dir.join("_vimrc").exists(); - let log_contents = read_to_string(&dir.dir.join("log")).unwrap(); - assert_eq!(git_contents, "git config"); - assert_eq!(vim1_contents, "vim config"); + let log_contents = read_to_string(&dir.dir.join("log.txt")).unwrap(); + assert_eq!(git_contents, "git #1"); + assert_eq!(vim1_contents, "vim #1"); assert_eq!(vim2_exists, false); - assert_eq!(log_contents, "linux -y\n"); + assert_eq!(log_contents, "script.sh called with arg1 linux\n"); } #[test] @@ -195,24 +190,24 @@ fn test_run_failure() { let (dir, mut cmd) = setup("test_run_failure"); cmd.args(["manifest.yml", "-t", "linux"]); manifest_1(&dir.dir); - write_file(&dir.dir.join("install_programs.sh"), "exit 1"); + write_file(&dir.dir.join("script.sh"), "exit 1"); let expected_stdout = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig -[1/3] Link vim_dotfiles/.vimrc to ~/.vimrc -[3/3] Run bash install_programs.sh linux -y +[1/3] Copy gitconfig to ~/.gitconfig.coliru +[2/3] Link vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 linux "; let expected_stderr = " Error: Process exited with exit status: 1\n"; assert_eq!(&stdout_to_string(&mut cmd), expected_stdout); assert_eq!(&stderr_to_string(&mut cmd), expected_stderr); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("git_dotfiles").join(".gitconfig"), "git #2"); - write_file(&dir.dir.join("vim_dotfiles").join(".vimrc"), "vim #2"); - let git_contents = read_to_string(&dir.dir.join(".gitconfig")).unwrap(); - let vim1_contents = read_to_string(&dir.dir.join(".vimrc")).unwrap(); + write_file(&dir.dir.join("gitconfig"), "git #2"); + write_file(&dir.dir.join("vimrc"), "vim #2"); + let git_contents = read_to_string(&dir.dir.join(".gitconfig.coliru")).unwrap(); + let vim1_contents = read_to_string(&dir.dir.join(".vimrc.coliru")).unwrap(); let vim2_exists = dir.dir.join("_vimrc").exists(); - assert_eq!(git_contents, "git config"); + assert_eq!(git_contents, "git #1"); assert_eq!(vim1_contents, "vim #2"); assert_eq!(vim2_exists, false); } @@ -223,23 +218,24 @@ fn test_missing_file() { let (dir, mut cmd) = setup("test_missing_file"); cmd.args(["manifest.yml", "-t", "linux"]); manifest_1(&dir.dir); - remove_file(&dir.dir.join("vim_dotfiles").join(".vimrc")).unwrap(); + remove_file(&dir.dir.join("vimrc")).unwrap(); let expected_stdout = "\ -[1/3] Copy git_dotfiles/.gitconfig to ~/.gitconfig -[1/3] Link vim_dotfiles/.vimrc to ~/.vimrc -[3/3] Run bash install_programs.sh linux -y +[1/3] Copy gitconfig to ~/.gitconfig.coliru +[2/3] Link vimrc to ~/.vimrc.coliru +[2/3] Run sh script.sh arg1 linux +script.sh called with arg1 linux "; let expected_stderr = " Error: No such file or directory (os error 2)\n"; assert_eq!(&stdout_to_string(&mut cmd), expected_stdout); assert_eq!(&stderr_to_string(&mut cmd), expected_stderr); // Assert files are correctly copied/linked/run - write_file(&dir.dir.join("git_dotfiles").join(".gitconfig"), "git #2"); - let git_contents = read_to_string(&dir.dir.join(".gitconfig")).unwrap(); - let log_contents = read_to_string(&dir.dir.join("log")).unwrap(); - assert_eq!(git_contents, "git config"); - assert_eq!(log_contents, "linux -y\n"); + write_file(&dir.dir.join("gitconfig"), "git #2"); + let git_contents = read_to_string(&dir.dir.join(".gitconfig.coliru")).unwrap(); + let log_contents = read_to_string(&dir.dir.join("log.txt")).unwrap(); + assert_eq!(git_contents, "git #1"); + assert_eq!(log_contents, "script.sh called with arg1 linux\n"); } #[test]