Skip to content

Commit

Permalink
Merge pull request #1163 from reyoung/feature/fix_error_msg_in_test_c…
Browse files Browse the repository at this point in the history
…onfigHelpers

Fix bugs in config_helpers unittest.
  • Loading branch information
gangliao authored Jan 17, 2017
2 parents 92d75f1 + a5c1658 commit 010dd20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
21 changes: 7 additions & 14 deletions python/paddle/trainer_config_helpers/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,10 @@ add_test(NAME test_reset_hook
${PYTHON_EXECUTABLE} ${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/test_reset_hook.py
WORKING_DIRECTORY ${PROJ_ROOT}/python/paddle)

if (PROTOBUF_3)
add_paddle_exe(protobuf_equal
ProtobufEqualMain.cpp)
add_test(NAME test_layerHelpers
COMMAND
${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/protobuf_equal
)
else()
add_test(NAME test_layerHelpers
COMMAND
${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh ${PYTHON_EXECUTABLE}
)
endif()
add_paddle_exe(protobuf_equal
ProtobufEqualMain.cpp)
add_test(NAME test_layerHelpers
COMMAND
${PROJ_ROOT}/python/paddle/trainer_config_helpers/tests/configs/run_tests.sh ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/protobuf_equal
)
14 changes: 8 additions & 6 deletions python/paddle/trainer_config_helpers/tests/configs/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
cd `dirname $0`

set -e
PYTHON_EXEC=$1
COMPARE_PROTO_UTIL=$2

protostr=`dirname $0`/protostr

files=`ls $protostr | grep -v "unittest"`

./generate_protostr.sh $1
./generate_protostr.sh ${PYTHON_EXEC}

. ./file_list.sh

if [ -z $1 ]; then
if [ -z ${COMPARE_PROTO_UTIL} ]; then
for file in $files
do
base_protostr=$protostr/$file
Expand All @@ -22,20 +24,20 @@ if [ -z $1 ]; then
else
for file in ${configs[*]}
do
if ! $1 $protostr/$file.protostr $protostr/$file.protostr.unittest; then
if ! ${COMPARE_PROTO_UTIL} $protostr/$file.protostr $protostr/$file.protostr.unittest; then
diff $protostr/$file.protostr $protostr/$file.protostr.unittest -u
fi
if ! $1 $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest; then
if ! ${COMPARE_PROTO_UTIL} $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest; then
diff $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest -u
fi
done

for file in ${whole_configs[*]}
do
if ! $1 $protostr/$file.protostr $protostr/$file.protostr.unittest --whole; then
if ! ${COMPARE_PROTO_UTIL} $protostr/$file.protostr $protostr/$file.protostr.unittest --whole; then
diff $protostr/$file.protostr $protostr/$file.protostr.unittest -u
fi
if ! $1 $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest --whole; then
if ! ${COMPARE_PROTO_UTIL} $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest --whole; then
diff $protostr/$file.protostr $protostr/$file.protostr.non_file_config.unittest -u
fi
done
Expand Down

0 comments on commit 010dd20

Please sign in to comment.