add unit test for a simple CXX project

This commit is contained in:
Radovan Bast 2015-05-23 11:14:18 +02:00
parent 4e2da28705
commit f5e62c16fb
5 changed files with 54 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*.pyc
__pycache__/
# generated by unit tests
test/*/CMakeLists.txt
test/*/build/
test/*/cmake/bootstrap.py*
test/*/cmake/lib/
test/*/cmake/modules/
test/*/setup.py

View File

@ -0,0 +1,10 @@
[project]
name: example
[cxx]
source: https://github.com/scisoft/autocmake/raw/master/modules/UseCXX.cmake
docopt: --cxx=<CXX> C++ compiler [default: g++].
export: 'CXX=%s' % arguments['--cxx']
[custom]
source: custom/custom.cmake

View File

@ -0,0 +1 @@
add_executable(example example.cpp)

7
test/cxx/example.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}

26
test/test.py Normal file
View File

@ -0,0 +1,26 @@
import os
import subprocess
HERE = os.path.abspath(os.path.dirname(__file__))
#-------------------------------------------------------------------------------
def exe(command):
stdout, stderr = subprocess.Popen(command.split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
return stdout, stderr
#-------------------------------------------------------------------------------
def test_cxx():
os.chdir(os.path.join(HERE, 'cxx', 'cmake'))
stdout, stderr = exe('wget https://github.com/scisoft/autocmake/raw/master/bootstrap.py')
stdout, stderr = exe('python bootstrap.py --init')
stdout, stderr = exe('python bootstrap.py ..')
os.chdir(os.path.join(HERE, 'cxx'))
stdout, stderr = exe('python setup.py --cxx=g++')
os.chdir(os.path.join(HERE, 'cxx', 'build'))
stdout, stderr = exe('make')
stdout, stderr = exe('./example')
assert 'Hello World!' in stdout