<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/unit-tests, branch v2.45.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-04-02T20:41:32Z</updated>
<entry>
<title>t-prio-queue: simplify using compound literals</title>
<updated>2024-04-02T20:41:32Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-02T18:30:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=543b2a1083f0fca2eaae86bf8d359aa565981b97'/>
<id>urn:sha1:543b2a1083f0fca2eaae86bf8d359aa565981b97</id>
<content type='text'>
Test names like "basic" are mentioned seven times in the code (ignoring
case): Twice when defining the input and result macros, thrice when
defining the test function, and twice again when calling it.  Reduce
that to a single time by using compound literals to pass the input and
result arrays via TEST_INPUT to test_prio_queue().

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-prio-queue: check result array bounds</title>
<updated>2024-03-18T16:25:54Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-16T21:09:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=30ff05094c145397d88ead89c3937d1a058ed98a'/>
<id>urn:sha1:30ff05094c145397d88ead89c3937d1a058ed98a</id>
<content type='text'>
Avoid reading past the end of the "result" array, which could otherwise
happen if the prio-queue were to yield more items than were put into it
due to an implementation bug, or if the array has not enough entries due
to a test bug.

Also check at the end whether all "result" entries were consumed, which
would not be the case if the prio-queue forgot some entries or the test
definition contained too many.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-prio-queue: shorten array index message</title>
<updated>2024-03-18T16:24:50Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-16T20:45:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e6f9cb76ea14b955fb7b4fcb8dea0786b5b108d3'/>
<id>urn:sha1:e6f9cb76ea14b955fb7b4fcb8dea0786b5b108d3</id>
<content type='text'>
If we get an unexpected result, the prio-queue unit test reports it like
this:

 # check "result[j++] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
 #    left: 5
 #   right: 1
 # failed at result[] index 0

That last line repeats "failed" and "result" from the first line.
Shorten it to resemble a similar one in t-ctype and also remove the
incrementation from the first line to avoid possible distractions from
the message of which comparison went wrong where:

 # check "result[j] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
 #    left: 5
 #   right: 1
 #       j: 0

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-ctype: avoid duplicating class names</title>
<updated>2024-03-03T17:47:33Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T10:13:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6cf06e9c6e9b4e99fc5abb334172cc201a42d66b'/>
<id>urn:sha1:6cf06e9c6e9b4e99fc5abb334172cc201a42d66b</id>
<content type='text'>
TEST_CTYPE_FUNC defines a function for testing a character classifier,
TEST_CHAR_CLASS calls it, causing the class name to be mentioned twice.

Avoid the need to define a class-specific function by letting
TEST_CHAR_CLASS do all the work.  This is done by using the internal
functions test__run_begin() and test__run_end(), but they do exist to be
used in test macros after all.

Alternatively we could unroll the loop to provide a very long expression
that tests all 256 characters and EOF and hand that to TEST, but that
seems awkward and hard to read.

No change of behavior or output intended.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-ctype: align output of i</title>
<updated>2024-03-03T17:47:33Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T10:13:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7a8d6c0a10e836d47e5531e321b5e1a944aa6123'/>
<id>urn:sha1:7a8d6c0a10e836d47e5531e321b5e1a944aa6123</id>
<content type='text'>
The unit test reports misclassified characters like this:

   # check "isdigit(i) == !!memchr("123456789", i, len)" failed at t/unit-tests/t-ctype.c:36
   #    left: 1
   #   right: 0
   #        i: 0x30

Reduce the indent of i to put its colon directly below the ones in the
preceding lines for consistency.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-ctype: simplify EOF check</title>
<updated>2024-03-03T17:47:33Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T10:13:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=752cb6ef816c8b2b37e38e418bd11698c00027e4'/>
<id>urn:sha1:752cb6ef816c8b2b37e38e418bd11698c00027e4</id>
<content type='text'>
EOF is not a member of any character class.  If a classifier function
returns a non-zero result for it, presumably by mistake, then the unit
test check reports:

   # check "!iseof(EOF)" failed at t/unit-tests/t-ctype.c:53
   #       i: 0xffffffff (EOF)

The numeric value of EOF is not particularly interesting in this
context.  Stop printing the second line.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t-ctype: allow NUL anywhere in the specification string</title>
<updated>2024-03-03T17:47:33Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-03-03T10:13:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=980013e90dd12ec1ff9eec23cebb0c845f198dab'/>
<id>urn:sha1:980013e90dd12ec1ff9eec23cebb0c845f198dab</id>
<content type='text'>
Replace the custom function is_in() for looking up a character in the
specification string with memchr(3) and sizeof.  This is shorter,
simpler and allows NUL anywhere in the string, which may come in handy
if we ever want to support more character classes that contain it.

Getting the string size using sizeof only works in a macro and with a
string constant.  Use ARRAY_SIZE and compile-time checks to make sure we
are not passed a string pointer.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/unit-tests-make-relative-fix'</title>
<updated>2024-02-13T22:31:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-13T22:31:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9115864cb59473aee9fcb9b0826342444559414d'/>
<id>urn:sha1:9115864cb59473aee9fcb9b0826342444559414d</id>
<content type='text'>
The mechanism to report the filename in the source code, used by
the unit-test machinery, assumed that the compiler expanded __FILE__
to the path to the source given to the $(CC), but some compilers
give full path, breaking the output.  This has been corrected.

* jc/unit-tests-make-relative-fix:
  unit-tests: do show relative file paths on non-Windows, too
</content>
</entry>
<entry>
<title>unit-tests: do show relative file paths on non-Windows, too</title>
<updated>2024-02-12T16:44:22Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-11T15:58:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f66286364f7875f9b3e3ac63733dd98e396fb7b8'/>
<id>urn:sha1:f66286364f7875f9b3e3ac63733dd98e396fb7b8</id>
<content type='text'>
There are compilers other than Visual C that want to show absolute
paths.  Generalize the helper introduced by a2c5e294 (unit-tests: do
show relative file paths, 2023-09-25) so that it can also work with
a path that uses slash as the directory separator, and becomes
almost no-op once one-time preparation finds out that we are using a
compiler that already gives relative paths.  Incidentally, this also
should do the right thing on Windows with a compiler that shows
relative paths but with backslash as the directory separator (if
such a thing exists and is used to build git).

Reported-by: Randall S. Becker &lt;rsbecker@nexbridge.com&gt;
Helped-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'cp/unit-test-prio-queue'</title>
<updated>2024-02-08T21:20:33Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-02-08T21:20:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=107023e1c9f981476c505e73eab319db6534a536'/>
<id>urn:sha1:107023e1c9f981476c505e73eab319db6534a536</id>
<content type='text'>
The priority queue test has been migrated to the unit testing
framework.

* cp/unit-test-prio-queue:
  tests: move t0009-prio-queue.sh to the new unit testing framework
</content>
</entry>
</feed>
