mkhomedir
mksourcedir golden

# test adding a file in a directory
chezmoi add $HOME${/}.dir/file
cmp $CHEZMOISOURCEDIR/dot_dir/file golden/dot_dir/file

# test adding a subdirectory
chezmoi add $HOME${/}.dir/subdir
cmp $CHEZMOISOURCEDIR/dot_dir/subdir/file golden/dot_dir/subdir/file

# test adding an empty file without --empty
chezmoi add $HOME${/}.empty
! exists $CHEZMOISOURCEDIR/dot_empty

# test adding an empty file with --empty
chezmoi add --empty $HOME${/}.empty
cmp $CHEZMOISOURCEDIR/empty_dot_empty golden/empty_dot_empty

# test adding an executable file
chezmoi add $HOME${/}.executable
[!windows] cmp $CHEZMOISOURCEDIR/executable_dot_executable golden/executable_dot_executable
[windows] cmp $CHEZMOISOURCEDIR/dot_executable golden/executable_dot_executable

# test adding that a file should exist
chezmoi add --exists $HOME${/}.exists
cmp $CHEZMOISOURCEDIR/exists_dot_exists golden/exists_dot_exists

# test adding a private file
chezmoi add $HOME${/}.private
[!windows] cmp $CHEZMOISOURCEDIR/private_dot_private $HOME/.private
[windows] cmp $CHEZMOISOURCEDIR/dot_private $HOME/.private

# test adding a symlink
chezmoi add $HOME${/}.symlink
cmp $CHEZMOISOURCEDIR/symlink_dot_symlink golden/symlink_dot_symlink

# test adding a symlink with a separator
symlink $HOME${/}.symlink2 -> .dir${/}subdir${/}file
chezmoi add $HOME${/}.symlink2
cmp $CHEZMOISOURCEDIR/symlink_dot_symlink2 golden/symlink_dot_symlink

# test adding a symlink with --follow
symlink $HOME${/}.symlink3 -> .file
chezmoi add --follow $HOME${/}.symlink3
cmp $CHEZMOISOURCEDIR/dot_symlink3 golden/dot_file
