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