1#!/usr/bin/perl 2# 3# This file is part of GNU Stow. 4# 5# GNU Stow is free software: you can redistribute it and/or modify it 6# under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# GNU Stow is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see https://www.gnu.org/licenses/. 17 18# 19# Test case for dotfiles special processing 20# 21 22use strict; 23use warnings; 24 25use testutil; 26 27use Test::More tests => 6; 28use English qw(-no_match_vars); 29 30use testutil; 31 32init_test_dirs(); 33cd("$TEST_DIR/target"); 34 35my $stow; 36 37# 38# process a dotfile marked with 'dot' prefix 39# 40 41$stow = new_Stow(dir => '../stow', dotfiles => 1); 42 43make_path('../stow/dotfiles'); 44make_file('../stow/dotfiles/dot-foo'); 45 46$stow->plan_stow('dotfiles'); 47$stow->process_tasks(); 48is( 49 readlink('.foo'), 50 '../stow/dotfiles/dot-foo', 51 => 'processed dotfile' 52); 53 54# 55# ensure that turning off dotfile processing links files as usual 56# 57 58$stow = new_Stow(dir => '../stow', dotfiles => 0); 59 60make_path('../stow/dotfiles'); 61make_file('../stow/dotfiles/dot-foo'); 62 63$stow->plan_stow('dotfiles'); 64$stow->process_tasks(); 65is( 66 readlink('dot-foo'), 67 '../stow/dotfiles/dot-foo', 68 => 'unprocessed dotfile' 69); 70 71 72# 73# process folder marked with 'dot' prefix 74# 75 76$stow = new_Stow(dir => '../stow', dotfiles => 1); 77 78make_path('../stow/dotfiles/dot-emacs'); 79make_file('../stow/dotfiles/dot-emacs/init.el'); 80 81$stow->plan_stow('dotfiles'); 82$stow->process_tasks(); 83is( 84 readlink('.emacs'), 85 '../stow/dotfiles/dot-emacs', 86 => 'processed dotfile folder' 87); 88 89# 90# corner case: paths that have a part in them that's just "$DOT_PREFIX" or 91# "$DOT_PREFIX." should not have that part expanded. 92# 93 94$stow = new_Stow(dir => '../stow', dotfiles => 1); 95 96make_path('../stow/dotfiles'); 97make_file('../stow/dotfiles/dot-'); 98 99make_path('../stow/dotfiles/dot-.'); 100make_file('../stow/dotfiles/dot-./foo'); 101 102$stow->plan_stow('dotfiles'); 103$stow->process_tasks(); 104is( 105 readlink('dot-'), 106 '../stow/dotfiles/dot-', 107 => 'processed dotfile' 108); 109is( 110 readlink('dot-.'), 111 '../stow/dotfiles/dot-.', 112 => 'unprocessed dotfile' 113); 114 115# 116# simple unstow scenario 117# 118 119$stow = new_Stow(dir => '../stow', dotfiles => 1); 120 121make_path('../stow/dotfiles'); 122make_file('../stow/dotfiles/dot-bar'); 123make_link('.bar', '../stow/dotfiles/dot-bar'); 124 125$stow->plan_unstow('dotfiles'); 126$stow->process_tasks(); 127ok( 128 $stow->get_conflict_count == 0 && 129 -f '../stow/dotfiles/dot-bar' && ! -e '.bar' 130 => 'unstow a simple dotfile' 131); 132