Skip to content

Commit 3bea0c0

Browse files
ttaylorrgitster
authored andcommitted
t/test-lib-functions.sh: implement test_trace2_data helper
Introduce a helper function which looks for a specific (category, key, value) tuple in the output of a trace2 event stream. We will use this function in a future patch to ensure that the expected number of objects are reused from an expected number of packs. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54393e4 commit 3bea0c0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/test-lib-functions.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,20 @@ test_region () {
18741874
return 0
18751875
}
18761876

1877+
# Check that the given data fragment was included as part of the
1878+
# trace2-format trace on stdin.
1879+
#
1880+
# test_trace2_data <category> <key> <value>
1881+
#
1882+
# For example, to look for trace2_data_intmax("pack-objects", repo,
1883+
# "reused", N) in an invocation of "git pack-objects", run:
1884+
#
1885+
# GIT_TRACE2_EVENT="$(pwd)/trace.txt" git pack-objects ... &&
1886+
# test_trace2_data pack-objects reused N <trace2.txt
1887+
test_trace2_data () {
1888+
grep -e '"category":"'"$1"'","key":"'"$2"'","value":"'"$3"'"'
1889+
}
1890+
18771891
# Given a GIT_TRACE2_EVENT log over stdin, writes to stdout a list of URLs
18781892
# sent to git-remote-https child processes.
18791893
test_remote_https_urls() {

0 commit comments

Comments
 (0)