Skip to content

Commit

Permalink
Force debug builds in CI, output all the tests output, run some tests…
Browse files Browse the repository at this point in the history
… in parallel
  • Loading branch information
apolukhin committed Jun 18, 2017
1 parent 5ec1108 commit 9345b15
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ environment:
matrix:
- TOOLSET_PATH: C:\Qt\5.8\mingw53_32\bin;C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin
BOOST_FLAGS: toolset=gcc --layout=system variant=release
BUILD_COMMAND: mingw32-make
BUILD_COMMAND: mingw32-make -j2

- TOOLSET_PATH: C:\Qt\5.8\msvc2015_64\bin
BOOST_FLAGS: toolset=msvc address-model=64
Expand Down Expand Up @@ -66,9 +66,9 @@ after_build:
before_test:
test_script:
# Building examples.
- qmake "BOOST_PATH=%BOOST%" BoostBook.pro
- qmake "BOOST_PATH=%BOOST%" "CONFIG+=debug" BoostBook.pro
- "%BUILD_COMMAND%"
- python ./test.py
- python ./test.py -v

after_test:
on_success:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ before_install:
- cd $PROJECT_DIR

script:
- qmake "QMAKE_CXX=$CXXTOOLSET" "QMAKE_LINK=$CXXTOOLSET" "QMAKE_CXXFLAGS+=$CXX_FLAGS" "QMAKE_LFLAGS+=$LINK_FLAGS" "LIBS+=$QLIBS" "BOOST_PATH=$BOOST" BoostBook.pro
- qmake "QMAKE_CXX=$CXXTOOLSET" "QMAKE_LINK=$CXXTOOLSET" "QMAKE_CXXFLAGS+=$CXX_FLAGS" "QMAKE_LFLAGS+=$LINK_FLAGS" "LIBS+=$QLIBS" "BOOST_PATH=$BOOST" "CONFIG+=debug" BoostBook.pro
- make -j4

# Executing examples
- python ./test.py
- python ./test.py -v

after_success:
- mkdir -p $TRAVIS_BUILD_DIR/coverals
Expand Down
2 changes: 1 addition & 1 deletion Chapter09/03_hash/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
template <class T>
std::size_t test_default() {
// Constants
const std::size_t ii_max = 200000000;
const std::size_t ii_max = 200000;
const std::string s(
"Long long long string that "
"will be used in tests to compare "
Expand Down
3 changes: 2 additions & 1 deletion Chapter09/04_unordered/04_unordered.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ if (!include(../../config.txt)) {
}

SOURCES += main.cpp
!msvc:LIBS += -lboost_timer -lboost_chrono -lboost_system
LIBS += -lboost_timer
!msvc:LIBS += -lboost_chrono -lboost_system
23 changes: 16 additions & 7 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class tester:
'Chapter08/01_vector_of_types': ('N5boost3mpl6v_itemIN4mpl_6size_tILm32EEENS1_INS3_ILm1EEENS1_INS3_ILm4096EEENS1_INS3_ILm8EEENS1_INS3_ILm4EEENS0_7vector0INS2_2naEEELi0EEELi0EEELi0EEELi0EEELi0EEE', '', 0),
'Chapter08/02_manipulating_vector_of_types': ('N4mpl_5long_ILl4EEE\n', '', 0),
'Chapter08/06_tuple_to_string': ('Meow! 0_0\nMeow! 0_0\nMeow! Meow! \nMeow! Meow! Meow! Meow! Meow! Meow! Meow! Meow! Meow! Meow! \n', '', 0),
'Chapter09/03_hash_h': ('HASH matched: 800000000\n', '', 0),
'Chapter09/03_hash_s': ('STD matched: 800000000\n', '', 0),
'Chapter09/03_hash_h': ('HASH matched: 800000\n', '', 0),
'Chapter09/03_hash_s': ('STD matched: 800000\n', '', 0),
'Chapter09/03_hash_x': ('', '', 2),
'Chapter09/05_bimap': ('Left:\nAnton Polukhin <=> 3\nAntony Polukhin <=> 3\nJohn Snow <=> 1\nVasya Pupkin <=> 2\n\nRight:\n1 <=> John Snow\n2 <=> Vasya Pupkin\n3 <=> Antony Polukhin\n3 <=> Anton Polukhin\n', '', 0),
'Chapter09/06_multiindex': ('0:\nAnton Polukhin, 3, 182, 70\nAntony Polukhin, 3, 183, 70\nJohn Snow, 1, 185, 80\nVasya Pupkin, 2, 165, 60\n\n1:\nJohn Snow, 1, 185, 80\nVasya Pupkin, 2, 165, 60\nAnton Polukhin, 3, 182, 70\nAntony Polukhin, 3, 183, 70\n\n2:\nVasya Pupkin, 2, 165, 60\nAnton Polukhin, 3, 182, 70\nAntony Polukhin, 3, 183, 70\nJohn Snow, 1, 185, 80\n\n3:\nVasya Pupkin, 2, 165, 60\nAntony Polukhin, 3, 183, 70\nAnton Polukhin, 3, 182, 70\nJohn Snow, 1, 185, 80\n\n', '', 0),
Expand Down Expand Up @@ -295,8 +295,14 @@ def _test_but_ignore_output_diff(test_name, path):
print 'No output in "{}" test\n'.format(test_name)
tester.was_error = True

tester.outputs[test_name] = ('', '', proc.returncode)
tester._test_validate(test_name)
tester.outputs[test_name] = (out1, out2, proc.returncode)
if tester.canonize_output:
return

if proc.returncode != 0:
print 'Return code in "{}" test is {}, {} expected. Info:'.format(test_name, tester.outputs[test_name][2], tester.expected[test_name][2])
tester._print_test_output(test_name)
tester.was_error = True


@staticmethod
Expand Down Expand Up @@ -365,7 +371,7 @@ def _is_exe(path):

''' ****************************************** Public functions *********************************************** '''
@staticmethod
def run_tests(root_directory='.'):
def run_tests(root_directory='.', verbose=False):
executables = []
for folder, _, files in os.walk(root_directory):
for f in files:
Expand All @@ -384,8 +390,10 @@ def run_tests(root_directory='.'):
tester._print_outputs_short()
sys.exit(-3)

if tester.was_error:
if verbose or tester.was_error:
tester._print_outputs()

if tester.was_error:
print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FAILURE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
sys.exit(-1)

Expand All @@ -397,6 +405,7 @@ def run_tests(root_directory='.'):
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--dir', default='.', help='Directory (chapter) to run tests for')
parser.add_argument('--build', '-b', action='store_true', help='Build the recipes for Linux platform')
parser.add_argument('--verbose', '-v', action='store_true', help='Output all the results')
args = parser.parse_args()

if args.build:
Expand All @@ -406,7 +415,7 @@ def run_tests(root_directory='.'):
subprocess.check_call(['make', '-j4'])
os.chdir(old_path)

tester.run_tests(args.dir)
tester.run_tests(args.dir, args.verbose)

if args.build:
old_path = os.getcwd()
Expand Down

0 comments on commit 9345b15

Please sign in to comment.