File: test-what-changed.sh

package info (click to toggle)
tla 1.3.5%2Bdfsg1-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 22,292 kB
  • ctags: 11,952
  • sloc: ansic: 149,771; sh: 16,009; xml: 2,689; lisp: 1,927; makefile: 1,064; cpp: 363; tcl: 230; awk: 48; sed: 25
file content (135 lines) | stat: -rw-r--r-- 3,243 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
# -*- mode: sh; coding: utf-8 -*-
# Simple what-changed tests
# Copyright © 2003 Colin Walters <walters@verbum.org>
#
# See the file "COPYING" for further information about
# the copyright and warranty status of this work.

set -e

arg0="$0"
srcdir=`dirname "$arg0"`

. ${srcdir}/test-framework

setup_with_trivial_archives

test_class "what-changed"

setup () {
  tla get jane@example.com--2003/hello-world--mainline--1.0 hello-world
  copy_tree hello-world hello-world.good
  cd hello-world
}  

assert_output_changes () {
   tla what-changed -o ../,what-changed "$@" 1>../what-changed-output || test $? = 1
}  

verify_cleanup () {
  cd ..
  rm -rf ',what-changed'
  rm -f what-changed-output
  rm -rf hello-world
  mv hello-world.good hello-world
}
  
# begin_test "null change output"
# setup
# tla what-changed > ../what-changed-output
# file_is_empty ../what-changed-output
# verify_cleanup
# end_test 

begin_test "null changeset"
setup
tla what-changed -o ../,what-changed
changeset_is_null_changeset ../,what-changed
verify_cleanup
end_test 

begin_test "single file modification"
setup
sed -e 's/Hello world/Hello, world/' < hello-world.c > hello-world.c.new
mv hello-world.c.new hello-world.c
assert_output_changes
file_matches '^M[[:space:]]*hello-world.c' ../what-changed-output
verify_cleanup
end_test 

begin_test "single file modification changeset"
setup
sed -e 's/Hello world/Hello, world/' < hello-world.c > hello-world.c.new
mv hello-world.c.new hello-world.c
assert_output_changes
changeset_patches_file ../,what-changed hello-world.c
verify_cleanup
end_test 

begin_test "new file addition output"
setup
echo 'We follow the GNU coding standards' > HACKING
tla add-id HACKING
assert_output_changes
file_matches '^A[[:space:]]*HACKING' ../what-changed-output
file_matches '^A[[:space:]]*.arch-ids/HACKING.id' ../what-changed-output
verify_cleanup
end_test 

begin_test "new file addition changeset"
setup
echo 'We follow the GNU coding standards' > HACKING
tla add-id HACKING
assert_output_changes
changeset_adds_file ../,what-changed HACKING
changeset_adds_file ../,what-changed .arch-ids/HACKING.id
verify_cleanup
end_test 

begin_test "removing existing file output"
setup
rm README
tla delete-id README
assert_output_changes
file_matches '^D[[:space:]]*README' ../what-changed-output
verify_cleanup
end_test 

begin_test "removing existing file changeset"
setup
rm README
tla delete-id README
assert_output_changes
changeset_deletes_file ../,what-changed README
verify_cleanup
end_test 

begin_test "moving file output"
setup
mv hello-world.c hello_world.c
tla move-id hello-world.c hello_world.c
assert_output_changes
file_matches '^=>[[:space:]]*hello-world.c.*hello_world.c' ../what-changed-output
verify_cleanup
end_test 

begin_test "moving file changeset"
setup
mv hello-world.c hello_world.c
tla move-id hello-world.c hello_world.c
assert_output_changes
changeset_renames_file ../,what-changed hello-world.c hello_world.c
verify_cleanup
end_test 

begin_test "diffing against version without patchlevel"
setup
assert_output_changes jane@example.com--2003/hello-world--mainline--1.0
verify_cleanup
end_test

clean_workdir

# tag: Colin Walters Wed, 17 Sep 2003 14:08:00 -0400 (test-what-changed.sh)
#