Fossil SCM

fossil-scm / test / merge_exe.test
Blame History Raw 94 lines
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
# Testing changes to a file's execute bit caused by a merge
19
#
20
21
if {$tcl_platform(platform) eq "unix"} {
22
proc setx {fn isexe} {
23
file attributes $fn -permissions [expr {$isexe ? "+" : "-"}]x
24
}
25
26
proc test_exe {fn expected} {
27
test merge_exe-$fn {[file executable $fn]==$expected}
28
}
29
} else {
30
# WARNING: This is a hack for setting and testing a file's execute bit
31
# on Windows. Never operate directly on Fossil database files like this
32
# unless you really need to and really know what you're doing.
33
34
proc query {sql} {
35
return [exec $::fossilexe sqlite3 --no-repository _FOSSIL_ $sql]
36
}
37
38
proc setx {fn isexe} {
39
set isexe [expr {bool($isexe)}]
40
query "UPDATE vfile SET isexe=$isexe WHERE pathname='$fn'"
41
}
42
43
proc test_exe {fn expected} {
44
set result [query "SELECT isexe FROM vfile WHERE pathname='$fn'"]
45
test merge_exe-$fn {$result==$expected}
46
}
47
}
48
49
test_setup
50
51
write_file f1 "line"
52
write_file f2 "line"
53
write_file f3 "line"
54
write_file f4 "line"
55
fossil addremove
56
setx f3 1
57
setx f4 1
58
fossil commit -m "add files"
59
60
write_file f0 "f0"
61
fossil add f0
62
setx f0 1
63
fossil mv --hard f1 f1n
64
setx f1n 1
65
write_file f2 "line\nline2"
66
setx f2 1
67
write_file f3 "line\nline2"
68
setx f3 0
69
setx f4 0
70
fossil commit -b b -m "changes"
71
72
fossil update trunk
73
write_file f3 "line3\nline"
74
fossil commit -m "edit f3"
75
76
fossil merge b
77
test_status_list merge_exe-mrg $RESULT {
78
EXECUTABLE f1
79
EXECUTABLE f2
80
UNEXEC f3
81
UNEXEC f4
82
UPDATE f2
83
MERGE f3
84
RENAME f1 -> f1n
85
ADDED f0
86
}
87
foreach {fn isexe} {f0 1 f1n 1 f2 1 f3 0 f4 0} {
88
test_exe $fn $isexe
89
}
90
91
###############################################################################
92
93
test_cleanup
94

Keyboard Shortcuts

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