test-lib: test_region looks for trace2 regions
authorDerrick Stolee <redacted>
Sat, 23 Jan 2021 21:07:08 +0000 (16:07 -0500)
committerJunio C Hamano <redacted>
Sun, 24 Jan 2021 01:14:18 +0000 (17:14 -0800)
commit3b14436364f0a68167723541bef1a625c5c6f163
tree88850d17bb2faf49420d851acf30bb1506d65743
parentdd23022acbf7433514e20a14a9f74e39fec9d340
test-lib: test_region looks for trace2 regions

From ff15d509b89edd4830d85d53cea3079a6b0c1c08 Mon Sep 17 00:00:00 2001
From: Derrick Stolee <redacted>
Date: Mon, 11 Jan 2021 08:53:09 -0500
Subject: [PATCH 8/9] test-lib: test_region looks for trace2 regions

Most test cases can verify Git's behavior using input/output
expectations or changes to the .git directory. However, sometimes we
want to check that Git did or did not run a certain section of code.
This is particularly important for performance-only features that we
want to ensure have been enabled in certain cases.

Add a new 'test_region' function that checks if a trace2 region was
entered and left in a given trace2 event log.

There is one existing test (t0500-progress-display.sh) that performs
this check already, so use the helper function instead. Note that this
changes the expectations slightly. The old test (incorrectly) used two
patterns for the 'grep' invocation, but this performs an OR of the
patterns, not an AND. This means that as long as one region_enter event
was logged, the test would succeed, even if it was not due to the
progress category.

More uses will be added in a later change.

t6423-merge-rename-directories.sh also greps for region_enter lines, but
it verifies the number of such lines, which is not the same as an
existence check.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
t/t0500-progress-display.sh
t/test-lib-functions.sh
git clone https://git.99rst.org/PROJECT