libgit2/libgit2 — pull request #1160 by vmg (2012-12-19 01:05:01+00:00)
Title: Clar 2.0 for great victory

Alright, so this is the rewrite, as promised:

- No C files are generated at runtime anymore. Fuck that. The test suite is self-contained in the submodule and never changes. `clar.py` is gone, and replaced by the generation script `clar/generate.py`, which creates a `clar.suite` in the root of the test folder, and that file contains all the information needed to run the tests. The file gets included from `clar.c`.

- The whole bullshit with including the C data in `clar.py` is gone. The C files in clar are now standalone and distributed as-is: one main file, `clar.c` and several headers that get included from the main file.

- Incremental regeneration: Clar now keeps a `.clarcache` file with the information of the last run. Any files that didn't change at all since the last run don't get re-scanned. If nothing has changed at all, the test metadata file `clar.suite` file doesn't get rewritten. Even if the file gets rewritten, this file is only included in `clar.c`, so this only triggers the recompilation of a single file to get a new suite.

- `clar_on_` callbacks are completely gone. Less complexity, less parsing. Now clar exports a `clar_test(int argc, char *argv[])` method, so you can write your own `main()` with whatever initialization/cleanup you need. See `tests-clar/main.c`.

- Categories are gone! Clar already has namespacing, so why dupe this functionality? All the tests that use network resources have been moved to the `online/` namespace, so just run `./libgit2_clar -x=online` to exclude these tests from the run.

- Running suites by number has been removed. It added complexity and very little value. Use `-s=name` to run them by name instead.

# TODO

- The tests under `online/` do not run because their callbacks haven't been renamed.
- Need to add `-x` flag to `generate.py` to mark whole suites as disabled by default.
- Need to fix `-x` on Clar itself to allow skipping whole namespaces, not only individual suites.
- Need to fix CMake so it always runs `generate.py` on every run.

/cc @arrbee @scottjg