add unit test for a simple CXX project
This commit is contained in:
parent
4e2da28705
commit
f5e62c16fb
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal 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
|
10
test/cxx/cmake/autocmake.cfg
Normal file
10
test/cxx/cmake/autocmake.cfg
Normal 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
|
1
test/cxx/cmake/custom/custom.cmake
Normal file
1
test/cxx/cmake/custom/custom.cmake
Normal file
@ -0,0 +1 @@
|
|||||||
|
add_executable(example example.cpp)
|
7
test/cxx/example.cpp
Normal file
7
test/cxx/example.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Hello World!";
|
||||||
|
return 0;
|
||||||
|
}
|
26
test/test.py
Normal file
26
test/test.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user