Skip to content

Introduce a test framework

Kenta Arai requested to merge Kenta111/unix-tree:introduce-test-framework into master

Background

Additional bugs might be added when new features or patches are merged. In my opinion, the most fatal cause is no easy methods to compare the behavior of old and new tree. Some OSS projects contain the methods (e.g. coreutils).

Overview

The test framework which I have committed allow all developers to test the tree. It is useful to check fixed tree before you write your merge request.

Needless to say, the tree is not released with the framework. It only helps developers.

How to test tree

Run make test. The result are shown with either "SUCCESS" or "FAILURE".

$ make test
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o list.o list.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o hash.o hash.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o color.o color.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o file.o file.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o filter.o filter.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o info.o info.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o unix.o unix.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o xml.o xml.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o json.o json.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o html.o html.c
gcc -ggdb -std=c11 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o strverscmp.o strverscmp.c
gcc  -o tree tree.o list.o hash.o color.o file.o filter.o info.o unix.o xml.o json.o html.o strverscmp.o
make -C tests
make[1]: Entering directory '/path/to/unix-tree/tests'
***** tests are launched ******
SUCCESS: no-arg
SUCCESS: L-option
***** tests were finished ******
make[1]: Leaving directory '/path/to/unix-tree/tests'

How to add a test

First of all, add test entry in tests/Makefile.

entries = no-arg L-option new-test

Second, You must create a new test directory. It is helpful to reuse the existing directory.

$ cp -r tests/{no-arg,new-test} # reuse the no-arg test

Finally, overwrite tests/new-test/test.sh in order to test tree behavior.

Then, run make test and check results!

Note

The commit does not have enough entries to test all tree functions. Although I will add some entries, I am not familiar with some options. Significant efforts from other contributors are required.

Edited by Kenta Arai

Merge request reports