~akkartik/basic-test

ee74abba50c0f755a5e46318617b00eb0da0adc6 — Kartik Agaram 11 months ago 3f7f56e
decouple from basic-build repo

Using the `build` script continues to avoid the dependency on `make`, but
this repo can also stand alone with a focus on the test harness.
4 files changed, 34 insertions(+), 5 deletions(-)

M Readme.md
M build
M clean
A makefile
M Readme.md => Readme.md +14 -4
@@ 24,15 24,25 @@ any order in any .c file.)

Read test.h for more details.

Based on the minimal build system example repo at https://notabug.org/akkartik/basic-build

#### Try it out

First build the project, using either (preferred):

```
./build
```

or (more conventional):

```
make
```

Then try running tests.

```
$ ./build
$ ./a.out  # run some example tests
..  # emits one dot per passing test
$ ./a.out test_2  # run a single test
.  # single dot for single test
$ ./clean  # undo ./build
```

M build => build +1 -1
@@ 61,7 61,7 @@ grep -h "^[^ #].*) {" *.c  |sed 's/ {.*/;/'  |update function_list
grep -h "^\s*void test_" *.c  |sed 's/^\s*void \(.*\)(void) {.*/\1,/'  |update test_list
grep -h "^\s*void test_" *.c  |sed 's/^\s*void \(.*\)(void) {.*/"\1",/'  |update test_name_list

older_than a.out *.c *.h function_list test_list && {
older_than a.out *.c *.h function_list test_list test_name_list  &&  {
  $CC $CFLAGS *.c
}


M clean => clean +1 -0
@@ 1,3 1,4 @@
#!/bin/sh
# Undo build.

rm -rf a.out* test_list test_name_list function_list

A makefile => makefile +18 -0
@@ 0,0 1,18 @@
CFLAGS ?= -g -O3

a.out: *.c *.h function_list test_list test_name_list
	${CC} ${CFLAGS} *.c

function_list: *.c
	grep -h "^[^ #].*) {" *.c  |sed 's/ {.*/;/' > function_list

test_list: *.c
	grep -h "^\s*void test_" *.c  |sed 's/^\s*void \(.*\)(void) {.*/\1,/' > test_list

test_name_list: *.c
	grep -h "^\s*void test_" *.c  |sed 's/^\s*void \(.*\)(void) {.*/"\1",/' > test_name_list

.PHONY: clean

clean:
	-rm -rf a.out* function_list test_list test_name_list