Skip to content

Commit

Permalink
Merge pull request #1 from cubicdaiya/gtest-update
Browse files Browse the repository at this point in the history
test: changed the way to embed googletest.
  • Loading branch information
cubicdaiya authored Aug 28, 2016
2 parents c207fa2 + b13acd4 commit 424ab0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ compiler:
- gcc
- clang
before_script:
- wget http://googletest.googlecode.com/files/gtest-1.7.0.zip
- unzip -q gtest-1.7.0.zip
- cd gtest-1.7.0
- ./configure
- sudo apt-get install -y cmake
- wget https://github.com/google/googletest/archive/release-1.8.0.zip
- unzip -q release-1.8.0.zip
- cd googletest-release-1.8.0
- cmake .
- make
- sudo make install
- cd ..
script:
- cd examples
- scons
- cd ../test
- GTEST_ROOT=$PWD/../gtest-1.7.0 scons check
- scons check
40 changes: 14 additions & 26 deletions test/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,34 @@ def path_chomp(path):
return path[:-1]
return path

if not 'GTEST_ROOT' in os.environ:
print "set environment variable 'GTEST_ROOT'"
Exit(1)

gtest_root = path_chomp(os.environ['GTEST_ROOT'])
if gtest_root[-1] == '/':
gtest_root = gtest_root[:-1]

gtest_includes = gtest_root + '/include'
gtest_libs = gtest_root + '/lib/.libs'

flags = ['-Wall', '-O2']
libs = ['stdc++', 'pthread']
includes = ['..', gtest_includes]
target = 'dtl_test'

env = Environment(CPPFLAGS=flags,
CPPPATH=includes,
LIBPATH=[gtest_libs],
)
env = Environment(
CPPFLAGS=['-Wall', '-O2'],
CPPPATH=['..'],
)

conf = Configure(env);

if not conf.CheckCXX():
print "c++ compiler is not installed!"
Exit(1)

libs = ['stdc++', 'pthread', 'gtest']
for lib in libs:
if not conf.CheckLib(lib):
print "library " + lib + " not installed!"
Exit(1)

conf.Finish()

test = env.Program(target,
[Glob('*.cpp'), gtest_libs + '/libgtest.a']
)
test = env.Program(
'dtl_test',
[Glob('*.cpp')],
)

test_alias = env.Alias('check',
test,
test[0].abspath)
test_alias = env.Alias(
'check',
test,
test[0].abspath
)

env.AlwaysBuild(test_alias)

0 comments on commit 424ab0d

Please sign in to comment.