Commit b5f43284 by Tianqi Chen

Add travis test scripts (#35)

parent c5a34225
......@@ -46,7 +46,7 @@ class Graph {
* \tparam T the type of the attribute.
*/
template<typename T>
inline const T& GetAttr(const std::string& attr_name);
inline const T& GetAttr(const std::string& attr_name) const;
/*!
* \brief Get a move copy of the attribute, implement copy on write semantics.
* The content is moved if the reference counter of shared_ptr is 1.
......@@ -209,7 +209,7 @@ inline void DFSVisit(const std::vector<NodeEntry>& heads, FVisit fvisit);
// inline function implementations
template<typename T>
inline const T& Graph::GetAttr(const std::string& attr_name) {
inline const T& Graph::GetAttr(const std::string& attr_name) const {
auto it = attrs.find(attr_name);
CHECK(it != attrs.end())
<< "Cannot find attribute " << attr_name << " in the graph";
......
......@@ -19,3 +19,9 @@ TEST(Op, GetAttr) {
CHECK_EQ(nick[add], "plus");
}
int main(int argc, char ** argv) {
testing::InitGoogleTest(&argc, argv);
testing::FLAGS_gtest_death_test_style = "threadsafe";
return RUN_ALL_TESTS();
}
......@@ -22,3 +22,9 @@ TEST(Tuple, Basic) {
s = std::move(ss);
CHECK((s == TShape{1, 2, 3}));
}
int main(int argc, char ** argv) {
testing::InitGoogleTest(&argc, argv);
testing::FLAGS_gtest_death_test_style = "threadsafe";
return RUN_ALL_TESTS();
}
......@@ -4,9 +4,9 @@ GTEST_INC=$(GTEST_PATH)/include/
TEST_SRC = $(wildcard tests/cpp/*_test.cc)
TEST = $(patsubst tests/cpp/%_test.cc, tests/cpp/%_test, $(TEST_SRC))
tests/cpp/%_test: tests/cpp/%_test.cc lib/libnngraph.a
tests/cpp/%_test: tests/cpp/%_test.cc lib/libnnvm.a
$(CXX) -std=c++11 $(CFLAGS) -MM -MT tests/cpp/$* $< >tests/cpp/$*.d
$(CXX) -std=c++11 $(CFLAGS) -I$(GTEST_INC) -o $@ $(filter %.cc %.a, $^) \
-L$(GTEST_LIB) $(LDFLAGS) -lgtest -lgtest_main
-L$(GTEST_LIB) $(LDFLAGS) -lgtest
-include tests/cpp/*.d
......@@ -18,7 +18,7 @@ def test_graph_gradient():
print("Original graph")
print(y.debug_str())
print("Gradient graph")
print grad_graph.symbol.debug_str()
print(grad_graph.symbol.debug_str())
if __name__ == "__main__":
test_graph_gradient()
#!/bin/bash
if [ ${TASK} == "lint" ]; then
make lint || exit -1
echo "Check documentations of c++ code..."
make doc 2>log.txt
(cat log.txt| grep -v ENABLE_PREPROCESSING |grep -v "unsupported tag") > logclean.txt
echo "---------Error Log----------"
cat logclean.txt
echo "----------------------------"
(cat logclean.txt|grep warning) && exit -1
(cat logclean.txt|grep error) && exit -1
exit 0
fi
if [ ! ${TRAVIS_OS_NAME} == "osx" ]; then
# use g++-4.8 for linux
if [ ${CXX} == "g++" ]; then
export CXX=g++-4.8
fi
fi
if [ ${TASK} == "cpp_test" ]; then
make -f dmlc-core/scripts/packages.mk gtest
echo "GTEST_PATH="${CACHE_PREFIX} >> config.mk
make test || exit -1
for test in tests/cpp/*_test; do
./$test || exit -1
done
exit 0
fi
# run two test one for cython, one for ctypes
if [ ${TASK} == "python_test" ]; then
make clean
make -j all || exit -1
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
python -m nose tests/python/ || exit -1
python3 -m nose tests/python/ || exit -1
else
nosetests tests/python/ || exit -1
nosetests3 tests/python/ || exit -1
fi
python -m nose tests/python/ || exit -1
python3 -m nose tests/python/ || exit -1
make cython || exit -1
make cython3 || exit -1
python -m nose tests/python/ || exit -1
python3 -m nose tests/python/ || exit -1
exit 0
fi
#!/bin/bash
if [ ${TRAVIS_OS_NAME} == "osx" ]; then
brew update
brew install python3
if [ ${TASK} == "python_test" ]; then
python -m pip install nose numpy cython --user `whoami`
python3 -m pip install nose numpy cython --user `whoami`
fi
fi
if [ ${TASK} == "lint" ]; then
pip install cpplint 'pylint==1.4.4' 'astroid==1.3.6' --user `whoami`
fi
if [ ! -d dmlc-core ]; then
git clone https://github.com/dmlc/dmlc-core
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment