mbox series

[v8,00/14] Introduce clar testing framework

Message ID cover.1725459142.git.ps@pks.im (mailing list archive)
Headers show
Series Introduce clar testing framework | expand

Message

Patrick Steinhardt Sept. 4, 2024, 2:16 p.m. UTC
Hi,

this is the 8th version of my patch series that introduces the clar
testing framework.

Changes compared to v7:

  - Properly wire up the "--immediate" flag.

  - Give a hint for the syntax to run only specific suites or tests for
    the "--run" and "--exclude" options.

Thanks!

Patrick

Johannes Schindelin (4):
  clar: avoid compile error with mingw-w64
  clar(win32): avoid compile error due to unused `fs_copy()`
  clar: stop including `shellapi.h` unnecessarily
  clar: add CMake support

Patrick Steinhardt (10):
  t: do not pass GIT_TEST_OPTS to unit tests with prove
  t: import the clar unit testing framework
  t/clar: fix compatibility with NonStop
  Makefile: fix sparse dependency on GENERATED_H
  Makefile: make hdr-check depend on generated headers
  Makefile: do not use sparse on third-party sources
  Makefile: wire up the clar unit testing framework
  t/unit-tests: implement test driver
  t/unit-tests: convert strvec tests to use clar
  t/unit-tests: convert ctype tests to use clar

 .gitignore                                 |   1 +
 Documentation/technical/unit-tests.txt     |   2 +
 Makefile                                   |  53 +-
 contrib/buildsystems/CMakeLists.txt        |  53 ++
 t/Makefile                                 |   4 +-
 t/run-test.sh                              |   2 +-
 t/unit-tests/.gitignore                    |   2 +
 t/unit-tests/clar-generate.awk             |  50 ++
 t/unit-tests/clar/.github/workflows/ci.yml |  23 +
 t/unit-tests/clar/COPYING                  |  15 +
 t/unit-tests/clar/README.md                | 329 ++++++++
 t/unit-tests/clar/clar.c                   | 842 +++++++++++++++++++++
 t/unit-tests/clar/clar.h                   | 173 +++++
 t/unit-tests/clar/clar/fixtures.h          |  50 ++
 t/unit-tests/clar/clar/fs.h                | 524 +++++++++++++
 t/unit-tests/clar/clar/print.h             | 211 ++++++
 t/unit-tests/clar/clar/sandbox.h           | 159 ++++
 t/unit-tests/clar/clar/summary.h           | 143 ++++
 t/unit-tests/clar/generate.py              | 266 +++++++
 t/unit-tests/clar/test/.gitignore          |   4 +
 t/unit-tests/clar/test/Makefile            |  39 +
 t/unit-tests/clar/test/clar_test.h         |  16 +
 t/unit-tests/clar/test/main.c              |  40 +
 t/unit-tests/clar/test/main.c.sample       |  27 +
 t/unit-tests/clar/test/resources/test/file |   1 +
 t/unit-tests/clar/test/sample.c            |  84 ++
 t/unit-tests/{t-ctype.c => ctype.c}        |  71 +-
 t/unit-tests/strvec.c                      | 241 ++++++
 t/unit-tests/t-strvec.c                    | 211 ------
 t/unit-tests/unit-test.c                   |  47 ++
 t/unit-tests/unit-test.h                   |  10 +
 31 files changed, 3459 insertions(+), 234 deletions(-)
 create mode 100644 t/unit-tests/clar-generate.awk
 create mode 100644 t/unit-tests/clar/.github/workflows/ci.yml
 create mode 100644 t/unit-tests/clar/COPYING
 create mode 100644 t/unit-tests/clar/README.md
 create mode 100644 t/unit-tests/clar/clar.c
 create mode 100644 t/unit-tests/clar/clar.h
 create mode 100644 t/unit-tests/clar/clar/fixtures.h
 create mode 100644 t/unit-tests/clar/clar/fs.h
 create mode 100644 t/unit-tests/clar/clar/print.h
 create mode 100644 t/unit-tests/clar/clar/sandbox.h
 create mode 100644 t/unit-tests/clar/clar/summary.h
 create mode 100755 t/unit-tests/clar/generate.py
 create mode 100644 t/unit-tests/clar/test/.gitignore
 create mode 100644 t/unit-tests/clar/test/Makefile
 create mode 100644 t/unit-tests/clar/test/clar_test.h
 create mode 100644 t/unit-tests/clar/test/main.c
 create mode 100644 t/unit-tests/clar/test/main.c.sample
 create mode 100644 t/unit-tests/clar/test/resources/test/file
 create mode 100644 t/unit-tests/clar/test/sample.c
 rename t/unit-tests/{t-ctype.c => ctype.c} (68%)
 create mode 100644 t/unit-tests/strvec.c
 delete mode 100644 t/unit-tests/t-strvec.c
 create mode 100644 t/unit-tests/unit-test.c
 create mode 100644 t/unit-tests/unit-test.h

Range-diff against v7:
 1:  b67f10ec0b0 =  1:  b67f10ec0b0 t: do not pass GIT_TEST_OPTS to unit tests with prove
 2:  55a9b46e65f =  2:  55a9b46e65f t: import the clar unit testing framework
 3:  f24401f0a87 =  3:  f24401f0a87 t/clar: fix compatibility with NonStop
 4:  658a601c541 =  4:  658a601c541 clar: avoid compile error with mingw-w64
 5:  0b8a6ac5fed =  5:  0b8a6ac5fed clar(win32): avoid compile error due to unused `fs_copy()`
 6:  c50e7a0ea68 =  6:  c50e7a0ea68 clar: stop including `shellapi.h` unnecessarily
 7:  b8f3f16dd27 =  7:  b8f3f16dd27 Makefile: fix sparse dependency on GENERATED_H
 8:  3d3fe443b9a =  8:  3d3fe443b9a Makefile: make hdr-check depend on generated headers
 9:  7d0f494850a =  9:  7d0f494850a Makefile: do not use sparse on third-party sources
10:  9c74c5ae019 = 10:  9c74c5ae019 Makefile: wire up the clar unit testing framework
11:  8bd5b3e2b29 ! 11:  81d932bfa33 t/unit-tests: implement test driver
    @@ t/unit-tests/unit-test.c
     +	struct string_list exclude_args = STRING_LIST_INIT_NODUP;
     +	int immediate = 0;
     +	struct option options[] = {
    -+		OPT_BOOL('i', "--immediate", &immediate,
    ++		OPT_BOOL('i', "immediate", &immediate,
     +			 N_("immediately exit upon the first failed test")),
    -+		OPT_STRING_LIST('r', "run", &run_args, N_("name"),
    -+				N_("run only test suite or individual test <name>")),
    -+		OPT_STRING_LIST('x', "exclude", &exclude_args, N_("name"),
    -+				N_("exclude test suite <name>")),
    ++		OPT_STRING_LIST('r', "run", &run_args, N_("suite[::test]"),
    ++				N_("run only test suite or individual test <suite[::test]>")),
    ++		OPT_STRING_LIST('x', "exclude", &exclude_args, N_("suite"),
    ++				N_("exclude test suite <suite>")),
     +		OPT_END(),
     +	};
     +	struct strvec args = STRVEC_INIT;
    @@ t/unit-tests/unit-test.c
     +
     +	strvec_push(&args, argv[0]);
     +	strvec_push(&args, "-t");
    ++	if (immediate)
    ++		strvec_push(&args, "-Q");
     +	for (size_t i = 0; i < run_args.nr; i++)
     +		strvec_pushf(&args, "-s%s", run_args.items[i].string);
     +	for (size_t i = 0; i < exclude_args.nr; i++)
12:  3c3b9eacdfb = 12:  604303e31aa t/unit-tests: convert strvec tests to use clar
13:  c8360db2f86 = 13:  ba05b9f1eef t/unit-tests: convert ctype tests to use clar
14:  d51c146cd9d = 14:  8441d29daa8 clar: add CMake support

Comments

Phillip Wood Sept. 4, 2024, 2:32 p.m. UTC | #1
Hi Patrick

On 04/09/2024 15:16, Patrick Steinhardt wrote:
> 
> Changes compared to v7:
> 
>    - Properly wire up the "--immediate" flag.
> 
>    - Give a hint for the syntax to run only specific suites or tests for
>      the "--run" and "--exclude" options.

As far as I'm concerned this version looks ready to be merged to next

Thanks

Phillip

> Thanks!
> 
> Patrick
> 
> Johannes Schindelin (4):
>    clar: avoid compile error with mingw-w64
>    clar(win32): avoid compile error due to unused `fs_copy()`
>    clar: stop including `shellapi.h` unnecessarily
>    clar: add CMake support
> 
> Patrick Steinhardt (10):
>    t: do not pass GIT_TEST_OPTS to unit tests with prove
>    t: import the clar unit testing framework
>    t/clar: fix compatibility with NonStop
>    Makefile: fix sparse dependency on GENERATED_H
>    Makefile: make hdr-check depend on generated headers
>    Makefile: do not use sparse on third-party sources
>    Makefile: wire up the clar unit testing framework
>    t/unit-tests: implement test driver
>    t/unit-tests: convert strvec tests to use clar
>    t/unit-tests: convert ctype tests to use clar
> 
>   .gitignore                                 |   1 +
>   Documentation/technical/unit-tests.txt     |   2 +
>   Makefile                                   |  53 +-
>   contrib/buildsystems/CMakeLists.txt        |  53 ++
>   t/Makefile                                 |   4 +-
>   t/run-test.sh                              |   2 +-
>   t/unit-tests/.gitignore                    |   2 +
>   t/unit-tests/clar-generate.awk             |  50 ++
>   t/unit-tests/clar/.github/workflows/ci.yml |  23 +
>   t/unit-tests/clar/COPYING                  |  15 +
>   t/unit-tests/clar/README.md                | 329 ++++++++
>   t/unit-tests/clar/clar.c                   | 842 +++++++++++++++++++++
>   t/unit-tests/clar/clar.h                   | 173 +++++
>   t/unit-tests/clar/clar/fixtures.h          |  50 ++
>   t/unit-tests/clar/clar/fs.h                | 524 +++++++++++++
>   t/unit-tests/clar/clar/print.h             | 211 ++++++
>   t/unit-tests/clar/clar/sandbox.h           | 159 ++++
>   t/unit-tests/clar/clar/summary.h           | 143 ++++
>   t/unit-tests/clar/generate.py              | 266 +++++++
>   t/unit-tests/clar/test/.gitignore          |   4 +
>   t/unit-tests/clar/test/Makefile            |  39 +
>   t/unit-tests/clar/test/clar_test.h         |  16 +
>   t/unit-tests/clar/test/main.c              |  40 +
>   t/unit-tests/clar/test/main.c.sample       |  27 +
>   t/unit-tests/clar/test/resources/test/file |   1 +
>   t/unit-tests/clar/test/sample.c            |  84 ++
>   t/unit-tests/{t-ctype.c => ctype.c}        |  71 +-
>   t/unit-tests/strvec.c                      | 241 ++++++
>   t/unit-tests/t-strvec.c                    | 211 ------
>   t/unit-tests/unit-test.c                   |  47 ++
>   t/unit-tests/unit-test.h                   |  10 +
>   31 files changed, 3459 insertions(+), 234 deletions(-)
>   create mode 100644 t/unit-tests/clar-generate.awk
>   create mode 100644 t/unit-tests/clar/.github/workflows/ci.yml
>   create mode 100644 t/unit-tests/clar/COPYING
>   create mode 100644 t/unit-tests/clar/README.md
>   create mode 100644 t/unit-tests/clar/clar.c
>   create mode 100644 t/unit-tests/clar/clar.h
>   create mode 100644 t/unit-tests/clar/clar/fixtures.h
>   create mode 100644 t/unit-tests/clar/clar/fs.h
>   create mode 100644 t/unit-tests/clar/clar/print.h
>   create mode 100644 t/unit-tests/clar/clar/sandbox.h
>   create mode 100644 t/unit-tests/clar/clar/summary.h
>   create mode 100755 t/unit-tests/clar/generate.py
>   create mode 100644 t/unit-tests/clar/test/.gitignore
>   create mode 100644 t/unit-tests/clar/test/Makefile
>   create mode 100644 t/unit-tests/clar/test/clar_test.h
>   create mode 100644 t/unit-tests/clar/test/main.c
>   create mode 100644 t/unit-tests/clar/test/main.c.sample
>   create mode 100644 t/unit-tests/clar/test/resources/test/file
>   create mode 100644 t/unit-tests/clar/test/sample.c
>   rename t/unit-tests/{t-ctype.c => ctype.c} (68%)
>   create mode 100644 t/unit-tests/strvec.c
>   delete mode 100644 t/unit-tests/t-strvec.c
>   create mode 100644 t/unit-tests/unit-test.c
>   create mode 100644 t/unit-tests/unit-test.h
> 
> Range-diff against v7:
>   1:  b67f10ec0b0 =  1:  b67f10ec0b0 t: do not pass GIT_TEST_OPTS to unit tests with prove
>   2:  55a9b46e65f =  2:  55a9b46e65f t: import the clar unit testing framework
>   3:  f24401f0a87 =  3:  f24401f0a87 t/clar: fix compatibility with NonStop
>   4:  658a601c541 =  4:  658a601c541 clar: avoid compile error with mingw-w64
>   5:  0b8a6ac5fed =  5:  0b8a6ac5fed clar(win32): avoid compile error due to unused `fs_copy()`
>   6:  c50e7a0ea68 =  6:  c50e7a0ea68 clar: stop including `shellapi.h` unnecessarily
>   7:  b8f3f16dd27 =  7:  b8f3f16dd27 Makefile: fix sparse dependency on GENERATED_H
>   8:  3d3fe443b9a =  8:  3d3fe443b9a Makefile: make hdr-check depend on generated headers
>   9:  7d0f494850a =  9:  7d0f494850a Makefile: do not use sparse on third-party sources
> 10:  9c74c5ae019 = 10:  9c74c5ae019 Makefile: wire up the clar unit testing framework
> 11:  8bd5b3e2b29 ! 11:  81d932bfa33 t/unit-tests: implement test driver
>      @@ t/unit-tests/unit-test.c
>       +	struct string_list exclude_args = STRING_LIST_INIT_NODUP;
>       +	int immediate = 0;
>       +	struct option options[] = {
>      -+		OPT_BOOL('i', "--immediate", &immediate,
>      ++		OPT_BOOL('i', "immediate", &immediate,
>       +			 N_("immediately exit upon the first failed test")),
>      -+		OPT_STRING_LIST('r', "run", &run_args, N_("name"),
>      -+				N_("run only test suite or individual test <name>")),
>      -+		OPT_STRING_LIST('x', "exclude", &exclude_args, N_("name"),
>      -+				N_("exclude test suite <name>")),
>      ++		OPT_STRING_LIST('r', "run", &run_args, N_("suite[::test]"),
>      ++				N_("run only test suite or individual test <suite[::test]>")),
>      ++		OPT_STRING_LIST('x', "exclude", &exclude_args, N_("suite"),
>      ++				N_("exclude test suite <suite>")),
>       +		OPT_END(),
>       +	};
>       +	struct strvec args = STRVEC_INIT;
>      @@ t/unit-tests/unit-test.c
>       +
>       +	strvec_push(&args, argv[0]);
>       +	strvec_push(&args, "-t");
>      ++	if (immediate)
>      ++		strvec_push(&args, "-Q");
>       +	for (size_t i = 0; i < run_args.nr; i++)
>       +		strvec_pushf(&args, "-s%s", run_args.items[i].string);
>       +	for (size_t i = 0; i < exclude_args.nr; i++)
> 12:  3c3b9eacdfb = 12:  604303e31aa t/unit-tests: convert strvec tests to use clar
> 13:  c8360db2f86 = 13:  ba05b9f1eef t/unit-tests: convert ctype tests to use clar
> 14:  d51c146cd9d = 14:  8441d29daa8 clar: add CMake support