Skip to content

Commit

Permalink
Add pthread to unit tests in UNIX (#396)
Browse files Browse the repository at this point in the history
* Add pthread to unit tests in UNIX

* use pip3 (fix travis)
  • Loading branch information
larroy authored and tqchen committed May 3, 2018
1 parent d26d9e7 commit b744643
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ addons:
- unzip
- gcc-4.8
- g++-4.8
- python-pip
- python3-pip

before_install:
- export TRAVIS=scripts/travis
- source ${TRAVIS}/travis_setup_env.sh
- ${TRAVIS}/travis_osx_install.sh

install:
- pip install --user cpplint pylint
- pip3 install --user cpplint pylint

script: ${TRAVIS}/travis_script.sh

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ $(ALIB):
$(AR) cr $@ $+

lint:
python scripts/lint.py dmlc ${LINT_LANG} include src scripts $(NOLINT_FILES)
scripts/lint.py dmlc ${LINT_LANG} include src scripts $(NOLINT_FILES)

pylint:
python scripts/lint.py dmlc ${LINT_LANG} tracker/dmlc_tracker
scripts/lint.py dmlc ${LINT_LANG} tracker/dmlc_tracker

doxygen:
doxygen doc/Doxyfile
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# pylint: disable=protected-access, unused-variable, locally-disabled, len-as-condition
"""Lint helper to generate lint summary of source.
Expand Down
2 changes: 2 additions & 0 deletions scripts/travis/travis_osx_install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -e
set -x

if [ ${TRAVIS_OS_NAME} != "osx" ]; then
exit 0
Expand Down
11 changes: 7 additions & 4 deletions scripts/travis/travis_script.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash

set -e
set -x

# main script of travis
if [ ${TASK} == "lint" ]; then
make lint || exit -1
make lint
make doxygen 2>log.txt
(cat log.txt| grep -v ENABLE_PREPROCESSING |grep -v "unsupported tag" |grep warning) && exit -1
(cat log.txt| grep -v ENABLE_PREPROCESSING |grep -v "unsupported tag" |grep warning) && exit 1
exit 0
fi

Expand All @@ -24,6 +27,6 @@ if [ ${TASK} == "unittest_gtest" ]; then
fi
echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk
echo "BUILD_TEST=1" >> config.mk
make all || exit -1
test/unittest/dmlc_unittest || exit -1
make all
test/unittest/dmlc_unittest
fi
3 changes: 3 additions & 0 deletions test/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ if(NOT GTEST_ROOT)
endif()

if(GTEST_FOUND)
if (UNIX)
SET(CMAKE_EXE_LINKER_FLAGS "-pthread")
endif(UNIX)
enable_testing()
find_package(Threads REQUIRED)
file(GLOB_RECURSE UNIT_TEST_SOURCE "*.cc")
Expand Down

0 comments on commit b744643

Please sign in to comment.