mirror of
				https://github.com/TheLocehiliosan/yadm
				synced 2025-06-13 13:03:58 +00:00 
			
		
		
		
	Gracefully handle changes in yadm.cygwin-copy
This commit is contained in:
		
							parent
							
								
									f8e0bd593d
								
							
						
					
					
						commit
						7538851fe3
					
				| @ -1,5 +1,6 @@ | |||||||
| load common | load common | ||||||
| load_fixtures | load_fixtures | ||||||
|  | status=;output=; #; populated by bats run() | ||||||
| 
 | 
 | ||||||
| IN_REPO=(alt*) | IN_REPO=(alt*) | ||||||
| export TEST_TREE_WITH_CYGWIN=1 | export TEST_TREE_WITH_CYGWIN=1 | ||||||
| @ -14,6 +15,7 @@ test_alt() { | |||||||
|   local cygwin_copy="$1" |   local cygwin_copy="$1" | ||||||
|   local is_cygwin="$2" |   local is_cygwin="$2" | ||||||
|   local expect_link="$3" |   local expect_link="$3" | ||||||
|  |   local preexisting_link="$4" | ||||||
| 
 | 
 | ||||||
|   case "$cygwin_copy" in |   case "$cygwin_copy" in | ||||||
|     true|false) |     true|false) | ||||||
| @ -30,8 +32,17 @@ test_alt() { | |||||||
|   local expected_content |   local expected_content | ||||||
|   expected_content="$T_DIR_WORK/alt-test##$(PATH="$T_TMP:$PATH" uname -s)" |   expected_content="$T_DIR_WORK/alt-test##$(PATH="$T_TMP:$PATH" uname -s)" | ||||||
| 
 | 
 | ||||||
|  |   if [ "$preexisting_link" = 'symlink' ]; then | ||||||
|  |     ln -s "$expected_content" "$T_DIR_WORK/alt-test" | ||||||
|  |   elif [ "$preexisting_link" = 'file' ]; then | ||||||
|  |     touch "$T_DIR_WORK/alt-test" | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|   PATH="$T_TMP:$PATH" run "${T_YADM_Y[@]}" alt |   PATH="$T_TMP:$PATH" run "${T_YADM_Y[@]}" alt | ||||||
| 
 | 
 | ||||||
|  |   echo "Alt output:$output" | ||||||
|  |   echo "Alt status:$status" | ||||||
|  | 
 | ||||||
|   if [ -L "$T_DIR_WORK/alt-test" ] && [ "$expect_link" != 'true' ] ; then |   if [ -L "$T_DIR_WORK/alt-test" ] && [ "$expect_link" != 'true' ] ; then | ||||||
|     echo "ERROR: Alt should be a simple file, but isn't" |     echo "ERROR: Alt should be a simple file, but isn't" | ||||||
|     return 1 |     return 1 | ||||||
| @ -100,3 +111,21 @@ test_alt() { | |||||||
|   " |   " | ||||||
|   test_alt 'false' 'true' 'true' |   test_alt 'false' 'true' 'true' | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | @test "Option 'yadm.cygwin-copy' (preexisting symlink) " { | ||||||
|  |   echo " | ||||||
|  |     When the option 'yadm.cygwin-copy' is true | ||||||
|  |     and the OS is CYGWIN | ||||||
|  |     Verify alternate is a copy | ||||||
|  |   " | ||||||
|  |   test_alt 'true' 'true' 'false' 'symlink' | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | @test "Option 'yadm.cygwin-copy' (preexisting file) " { | ||||||
|  |   echo " | ||||||
|  |     When the option 'yadm.cygwin-copy' is true | ||||||
|  |     and the OS is CYGWIN | ||||||
|  |     Verify alternate is a copy | ||||||
|  |   " | ||||||
|  |   test_alt 'true' 'true' 'false' 'file' | ||||||
|  | } | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								yadm
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								yadm
									
									
									
									
									
								
							| @ -199,6 +199,9 @@ function alt() { | |||||||
|               debug "Linking $alt_path to $new_link" |               debug "Linking $alt_path to $new_link" | ||||||
|               [ -n "$loud" ] && echo "Linking $alt_path to $new_link" |               [ -n "$loud" ] && echo "Linking $alt_path to $new_link" | ||||||
|               if [ "$do_copy" -eq 1 ]; then |               if [ "$do_copy" -eq 1 ]; then | ||||||
|  |                 if [ -L "$new_link" ]; then | ||||||
|  |                   rm -f "$new_link" | ||||||
|  |                 fi | ||||||
|                 cp -f "$alt_path" "$new_link" |                 cp -f "$alt_path" "$new_link" | ||||||
|               else |               else | ||||||
|                 ln -nfs "$alt_path" "$new_link" |                 ln -nfs "$alt_path" "$new_link" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user