Fossil SCM

fossil-scm / test / symlinks.test
Source Blame History 111 lines
912a0d5… mistachkin 1 #
912a0d5… mistachkin 2 # Copyright (c) 2016 D. Richard Hipp
912a0d5… mistachkin 3 #
912a0d5… mistachkin 4 # This program is free software; you can redistribute it and/or
912a0d5… mistachkin 5 # modify it under the terms of the Simplified BSD License (also
912a0d5… mistachkin 6 # known as the "2-Clause License" or "FreeBSD License".)
912a0d5… mistachkin 7 #
912a0d5… mistachkin 8 # This program is distributed in the hope that it will be useful,
912a0d5… mistachkin 9 # but without any warranty; without even the implied warranty of
912a0d5… mistachkin 10 # merchantability or fitness for a particular purpose.
912a0d5… mistachkin 11 #
912a0d5… mistachkin 12 # Author contact information:
912a0d5… mistachkin 13 # [email protected]
912a0d5… mistachkin 14 # http://www.hwaci.com/drh/
912a0d5… mistachkin 15 #
912a0d5… mistachkin 16 ############################################################################
912a0d5… mistachkin 17 #
912a0d5… mistachkin 18 # Symbolic link tests.
912a0d5… mistachkin 19 #
912a0d5… mistachkin 20
64b812b… mistachkin 21 set path [file dirname [info script]]
64b812b… mistachkin 22
739dd48… mistachkin 23 if {$is_windows} {
64b812b… mistachkin 24 puts "Symlinks are not supported on Windows."
912a0d5… mistachkin 25 test_cleanup_then_return
912a0d5… mistachkin 26 }
912a0d5… mistachkin 27
912a0d5… mistachkin 28 require_no_open_checkout
912a0d5… mistachkin 29
912a0d5… mistachkin 30 ###############################################################################
912a0d5… mistachkin 31
912a0d5… mistachkin 32 test_setup; set rootDir [file normalize [pwd]]
271a978… preben 33
271a978… preben 34 # Using tempHomePath, allow-symlinks will always be off at this point.
271a978… preben 35 fossil set allow-symlinks on
912a0d5… mistachkin 36
912a0d5… mistachkin 37 fossil test-th-eval --open-config {repository}
912a0d5… mistachkin 38 set repository [normalize_result]
912a0d5… mistachkin 39
912a0d5… mistachkin 40 if {[string length $repository] == 0} {
912a0d5… mistachkin 41 puts "Detection of the open repository file failed."
912a0d5… mistachkin 42 test_cleanup_then_return
912a0d5… mistachkin 43 }
912a0d5… mistachkin 44
912a0d5… mistachkin 45 #######################################
912a0d5… mistachkin 46 # Use symbolic link to a directory... #
912a0d5… mistachkin 47 #######################################
912a0d5… mistachkin 48
912a0d5… mistachkin 49 file mkdir [file join $rootDir subdirA]
912a0d5… mistachkin 50 exec ln -s [file join $rootDir subdirA] symdirA
912a0d5… mistachkin 51
912a0d5… mistachkin 52 ###############################################################################
912a0d5… mistachkin 53
912a0d5… mistachkin 54 write_file [file join $rootDir subdirA f1.txt] "f1"
912a0d5… mistachkin 55 write_file [file join $rootDir subdirA f2.txt] "f2"
912a0d5… mistachkin 56
912a0d5… mistachkin 57 test symlinks-dir-1 {[file exists [file join $rootDir subdirA f1.txt]] eq 1}
912a0d5… mistachkin 58 test symlinks-dir-2 {[file exists [file join $rootDir symdirA f1.txt]] eq 1}
912a0d5… mistachkin 59 test symlinks-dir-3 {[file exists [file join $rootDir subdirA f2.txt]] eq 1}
912a0d5… mistachkin 60 test symlinks-dir-4 {[file exists [file join $rootDir symdirA f2.txt]] eq 1}
912a0d5… mistachkin 61
912a0d5… mistachkin 62 fossil add [file join $rootDir symdirA f1.txt]
271a978… preben 63 test symlinks-skip-dir-traversal {[normalize_result] eq \
271a978… preben 64 "SKIP symdirA/f1.txt"}
271a978… preben 65
e5bcfd1… preben 66 fossil commit -m "c1" -expectError
271a978… preben 67
271a978… preben 68 test symlinks-empty-commit {[normalize_result] eq \
271a978… preben 69 "nothing has changed; use --allow-empty to override"}
912a0d5… mistachkin 70
912a0d5… mistachkin 71 ###############################################################################
912a0d5… mistachkin 72
912a0d5… mistachkin 73 fossil ls
271a978… preben 74 test symlinks-dir-5 {[normalize_result] eq ""}
912a0d5… mistachkin 75
912a0d5… mistachkin 76 ###############################################################################
912a0d5… mistachkin 77
912a0d5… mistachkin 78 fossil extras
912a0d5… mistachkin 79 test symlinks-dir-6 {[normalize_result] eq \
271a978… preben 80 "subdirA/f1.txt\nsubdirA/f2.txt\nsymdirA"}
912a0d5… mistachkin 81
912a0d5… mistachkin 82 ###############################################################################
912a0d5… mistachkin 83
912a0d5… mistachkin 84 fossil close
912a0d5… mistachkin 85 file delete [file join $rootDir subdirA f1.txt]
912a0d5… mistachkin 86
912a0d5… mistachkin 87 test symlinks-dir-7 {[file exists [file join $rootDir subdirA f1.txt]] eq 0}
912a0d5… mistachkin 88 test symlinks-dir-8 {[file exists [file join $rootDir symdirA f1.txt]] eq 0}
912a0d5… mistachkin 89 test symlinks-dir-9 {[file exists [file join $rootDir subdirA f2.txt]] eq 1}
912a0d5… mistachkin 90 test symlinks-dir-10 {[file exists [file join $rootDir symdirA f2.txt]] eq 1}
912a0d5… mistachkin 91
912a0d5… mistachkin 92 ###############################################################################
912a0d5… mistachkin 93
271a978… preben 94 fossil open --force $repository
912a0d5… mistachkin 95 set code [catch {file readlink [file join $rootDir symdirA]} result]
912a0d5… mistachkin 96
912a0d5… mistachkin 97 test symlinks-dir-11 {$code == 0}
912a0d5… mistachkin 98 test symlinks-dir-12 {$result eq [file join $rootDir subdirA]}
271a978… preben 99 test symlinks-dir-13 {[file exists [file join $rootDir subdirA f1.txt]] eq 0}
271a978… preben 100 test symlinks-dir-14 {[file exists [file join $rootDir symdirA f1.txt]] eq 0}
912a0d5… mistachkin 101 test symlinks-dir-15 {[file exists [file join $rootDir subdirA f2.txt]] eq 1}
912a0d5… mistachkin 102 test symlinks-dir-16 {[file exists [file join $rootDir symdirA f2.txt]] eq 1}
912a0d5… mistachkin 103
912a0d5… mistachkin 104 ###############################################################################
912a0d5… mistachkin 105 #
912a0d5… mistachkin 106 # TODO: Add tests for symbolic links as files here, including tests with the
912a0d5… mistachkin 107 # "allow-symlinks" setting on and off.
912a0d5… mistachkin 108 #
912a0d5… mistachkin 109 ###############################################################################
912a0d5… mistachkin 110
912a0d5… mistachkin 111 test_cleanup

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button