tekknolagi/carp — pull request #17 by sardok (2014-08-09 21:24:31+00:00)
Title: Unit test support

Hi tekknolagi;

This PR meets this cute VM with a new build system and unit testing support.

I used CMake as new build system since, i think, it has several important advantages over gnu make;
* Easier to understand and add new changes.
* Supports multiplatform by default.
* Has good variety of extensions so you don't have to do much coding.

"Check" is used as unit testing framework which should be enough for what is needed at the moment.

Building:
```shell
sinan@ThinkPad-X1-Carbon:~/dev/carp$ mkdir build
sinan@ThinkPad-X1-Carbon:~/dev/carp$ cd build/
sinan@ThinkPad-X1-Carbon:~/dev/carp/build$ cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for one of the modules 'check'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sinan/dev/carp/build
sinan@ThinkPad-X1-Carbon:~/dev/carp/build$ make
Scanning dependencies of target carp
[ 12%] Building C object src/CMakeFiles/carp.dir/carp_instructions.c.o
[ 25%] Building C object src/CMakeFiles/carp.dir/carp_tokenizer.c.o
[ 37%] Building C object src/CMakeFiles/carp.dir/carp_machine.c.o
[ 50%] Building C object src/CMakeFiles/carp.dir/carp_lexer.c.o
[ 62%] Building C object src/CMakeFiles/carp.dir/lib/carp_ht.c.o
[ 75%] Building C object src/CMakeFiles/carp.dir/lib/carp_stack.c.o
Linking C static library libcarp.a
[ 75%] Built target carp
Scanning dependencies of target carp_cmd
[ 87%] Building C object src/CMakeFiles/carp_cmd.dir/carp.c.o
Linking C executable carp_cmd
[ 87%] Built target carp_cmd
Scanning dependencies of target test_instr
[100%] Building C object tests/CMakeFiles/test_instr.dir/test_instr.c.o
Linking C executable test_instr
[100%] Built target test_instr
```

And unit testing:
```shell
sinan@ThinkPad-X1-Carbon:~/dev/carp/build$ make test
Running tests...
Test project /home/sinan/dev/carp/build
Start 1: test_instr
1/1 Test #1: test_instr ....................... Passed 0.00 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) = 0.00 sec
```

Happy coding, thanks.