@@ -4,12 +4,6 @@ test_description='test trace2 facility (normal target)'
4
4
5
5
. ./test-lib.sh
6
6
7
- if ! test_have_prereq PERL_TEST_HELPERS
8
- then
9
- skip_all=' skipping trace2 tests; Perl not available'
10
- test_done
11
- fi
12
-
13
7
# Turn off any inherited trace2 settings for this test.
14
8
sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT
15
9
sane_unset GIT_TRACE2_BRIEF
@@ -59,10 +53,41 @@ GIT_TRACE2_BRIEF=1 && export GIT_TRACE2_BRIEF
59
53
#
60
54
# Implicit return from cmd_<verb> function propagates <code>.
61
55
56
+ scrub_normal () {
57
+ # Scrub the variable fields from the normal trace2 output to make
58
+ # testing easier:
59
+ #
60
+ # 1. Various messages include an elapsed time in the middle of the
61
+ # message. Replace the time with a placeholder to simplify our
62
+ # HEREDOC in the test script.
63
+ #
64
+ # 2. We expect:
65
+ #
66
+ # start <argv0> [<argv1> [<argv2> [...]]]
67
+ #
68
+ # where argv0 might be a relative or absolute path, with or
69
+ # without quotes, and platform dependent. Replace argv0 with a
70
+ # token for HEREDOC matching in the test script.
71
+ #
72
+ # 3. Likewise, the 'cmd_path' message breaks out argv[0].
73
+ #
74
+ # This line is only emitted when RUNTIME_PREFIX is defined,
75
+ # so just omit it for testing purposes.
76
+ #
77
+ # 4. 'cmd_ancestry' is not implemented everywhere, so for portability's
78
+ # sake, skip it when parsing normal.
79
+ sed \
80
+ -e ' s/elapsed:[0-9]*\.[0-9][0-9]*\([eE][-+]\{0,1\}[0-9][0-9]*\)\{0,1\}/elapsed:_TIME_/g' \
81
+ -e " s/^start '[^']*' \(.*\)/start _EXE_ \1/" \
82
+ -e ' s/^start [^ ][^ ]* \(.*\)/start _EXE_ \1/' \
83
+ -e ' /^cmd_path/d' \
84
+ -e ' /^cmd_ancestry/d'
85
+ }
86
+
62
87
test_expect_success ' normal stream, return code 0' '
63
88
test_when_finished "rm trace.normal actual expect" &&
64
89
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 0 &&
65
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
90
+ scrub_normal <trace.normal >actual &&
66
91
cat >expect <<-EOF &&
67
92
version $V
68
93
start _EXE_ trace2 001return 0
@@ -76,7 +101,7 @@ test_expect_success 'normal stream, return code 0' '
76
101
test_expect_success ' normal stream, return code 1' '
77
102
test_when_finished "rm trace.normal actual expect" &&
78
103
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 1 &&
79
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
104
+ scrub_normal <trace.normal >actual &&
80
105
cat >expect <<-EOF &&
81
106
version $V
82
107
start _EXE_ trace2 001return 1
@@ -91,7 +116,7 @@ test_expect_success 'automatic filename' '
91
116
test_when_finished "rm -r traces actual expect" &&
92
117
mkdir traces &&
93
118
GIT_TRACE2="$(pwd)/traces" test-tool trace2 001return 0 &&
94
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <"$(ls traces/*)" >actual &&
119
+ scrub_normal <"$(ls traces/*)" >actual &&
95
120
cat >expect <<-EOF &&
96
121
version $V
97
122
start _EXE_ trace2 001return 0
@@ -109,7 +134,7 @@ test_expect_success 'automatic filename' '
109
134
test_expect_success ' normal stream, exit code 0' '
110
135
test_when_finished "rm trace.normal actual expect" &&
111
136
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 0 &&
112
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
137
+ scrub_normal <trace.normal >actual &&
113
138
cat >expect <<-EOF &&
114
139
version $V
115
140
start _EXE_ trace2 002exit 0
@@ -123,7 +148,7 @@ test_expect_success 'normal stream, exit code 0' '
123
148
test_expect_success ' normal stream, exit code 1' '
124
149
test_when_finished "rm trace.normal actual expect" &&
125
150
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 1 &&
126
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
151
+ scrub_normal <trace.normal >actual &&
127
152
cat >expect <<-EOF &&
128
153
version $V
129
154
start _EXE_ trace2 002exit 1
@@ -141,7 +166,7 @@ test_expect_success 'normal stream, exit code 1' '
141
166
test_expect_success ' normal stream, error event' '
142
167
test_when_finished "rm trace.normal actual expect" &&
143
168
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 003error "hello world" "this is a test" &&
144
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
169
+ scrub_normal <trace.normal >actual &&
145
170
cat >expect <<-EOF &&
146
171
version $V
147
172
start _EXE_ trace2 003error ' \' ' hello world' \' ' ' \' ' this is a test' \' '
@@ -161,7 +186,7 @@ test_expect_success 'normal stream, error event' '
161
186
test_expect_success ' BUG messages are written to trace2' '
162
187
test_when_finished "rm trace.normal actual expect" &&
163
188
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 007bug &&
164
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
189
+ scrub_normal <trace.normal >actual &&
165
190
cat >expect <<-EOF &&
166
191
version $V
167
192
start _EXE_ trace2 007bug
@@ -185,7 +210,7 @@ test_expect_success 'bug messages with BUG_if_bug() are written to trace2' '
185
210
sed "s/^.*: //" <err >actual &&
186
211
test_cmp expect actual &&
187
212
188
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
213
+ scrub_normal <trace.normal >actual &&
189
214
cat >expect <<-EOF &&
190
215
version $V
191
216
start _EXE_ trace2 008bug
@@ -211,7 +236,7 @@ test_expect_success 'bug messages without explicit BUG_if_bug() are written to t
211
236
sed "s/^.*: //" <err >actual &&
212
237
test_cmp expect actual &&
213
238
214
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
239
+ scrub_normal <trace.normal >actual &&
215
240
cat >expect <<-EOF &&
216
241
version $V
217
242
start _EXE_ trace2 009bug_BUG
@@ -236,7 +261,7 @@ test_expect_success 'bug messages followed by BUG() are written to trace2' '
236
261
sed "s/^.*: //" <err >actual &&
237
262
test_cmp expect actual &&
238
263
239
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
264
+ scrub_normal <trace.normal >actual &&
240
265
cat >expect <<-EOF &&
241
266
version $V
242
267
start _EXE_ trace2 010bug_BUG
@@ -268,7 +293,7 @@ test_expect_success 'using global config, normal stream, return code 0' '
268
293
test_config_global trace2.normalBrief 1 &&
269
294
test_config_global trace2.normalTarget "$(pwd)/trace.normal" &&
270
295
test-tool trace2 001return 0 &&
271
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
296
+ scrub_normal <trace.normal >actual &&
272
297
cat >expect <<-EOF &&
273
298
version $V
274
299
start _EXE_ trace2 001return 0
@@ -286,7 +311,7 @@ test_expect_success 'using global config with include' '
286
311
mv "$(pwd)/.gitconfig" "$(pwd)/real.gitconfig" &&
287
312
test_config_global include.path "$(pwd)/real.gitconfig" &&
288
313
test-tool trace2 001return 0 &&
289
- perl "$TEST_DIRECTORY/t0210/ scrub_normal.perl" <trace.normal >actual &&
314
+ scrub_normal <trace.normal >actual &&
290
315
cat >expect <<-EOF &&
291
316
version $V
292
317
start _EXE_ trace2 001return 0
0 commit comments