Add clean.sh and compile_and_test_all.sh, ignore built libraries/tests/data,

and make the unit tests exit with non-zero status when tests fail.


git-svn-id: https://cld2.googlecode.com/svn/trunk@162 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
andrewhayden@google.com
2014-07-25 09:52:27 +00:00
parent d076f5eda2
commit b661afafc7
5 changed files with 113 additions and 3 deletions

View File

@@ -359,7 +359,7 @@ int RunTests (int flags, bool get_vector) {
}
FinishHtmlOut(flags);
return 0;
return any_fail ? 1 : 0;
}
} // End namespace CLD2

View File

@@ -392,7 +392,7 @@ int RunTests (int flags, bool get_vector) {
}
FinishHtmlOut(flags);
return 0;
return any_fail ? 1 : 0;
}
} // End namespace CLD2

29
internal/clean.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
#
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
rm -f compact_lang_det_test_chrome
rm -f cld2_unittest
rm -f cld2_unittest_avoid
rm -f libcld2.so
rm -f libcld2_full.so
rm -f compact_lang_det_test_full
rm -f cld2_unittest_full
rm -f cld2_unittest_full_avoid
rm -f cld2_dynamic_data_tool
rm -f cld2_data.bin
rm -f compact_lang_det_dynamic_test_chrome
rm -f cld2_dynamic_unittest
rm -f libcld2_dynamic.so

View File

@@ -92,6 +92,7 @@ extern const short kAvgDeltaOctaScore[];
static uint32_t mmapLength = 0;
bool isDataLoaded() { return dynamicDataLoaded; }
bool isDataDynamic() { return true; } // Because CLD2_DYNAMIC_MODE is defined
void loadDataFromFile(const char* fileName) {
if (isDataLoaded()) {
@@ -124,7 +125,7 @@ extern const short kAvgDeltaOctaScore[];
dataSourceIsFile = false; // vacuous
kScoringtables = NULL_TABLES; // Housekeeping: null all pointers
}
#else
#else // !CLD2_DYNAMIC_MODE
// This initializes kScoringtables.quadgram_obj etc.
static const ScoringTables kScoringtables = {
&cld_generated_CjkUni_obj,
@@ -139,6 +140,27 @@ extern const short kAvgDeltaOctaScore[];
kAvgDeltaOctaScore,
};
// Method implementations below are provided so that callers aren't *forced*
// to depend upon the CLD2_DYNAMIC_MODE flag, but can use runtime checks
// instead. For more information, refer to CLD2 issue 16:
// https://code.google.com/p/cld2/issues/detail?id=16
bool isDataLoaded() { return true; } // Data is statically linked
bool isDataDynamic() { return false; } // Because CLD2_DYNAMIC_MODE is not defined
void loadDataFromFile(const char* fileName) {
// This is a bug in the calling code.
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromFile has no effect!");
}
void loadDataFromRawAddress(const void* rawAddress, const uint32_t length) {
// This is a bug in the calling code.
fprintf(stderr, "WARNING: Dynamic mode not active, loadDataFromRawAddress has no effect!");
}
void unloadData() {
// This is a bug in the calling code.
fprintf(stderr, "WARNING: Dynamic mode not active, unloadData has no effect!");
}
#endif // #ifdef CLD2_DYNAMIC_MODE

View File

@@ -0,0 +1,59 @@
#!/bin/sh
#
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
trap 'echo "FAILED!" && exit 1' INT TERM EXIT
# ----------------------------------------------------------------------------
echo "--> [1 of 7] Invoking: compile.sh..."
./compile.sh
echo "--> [2 of 7] Testing results of compile.sh..."
echo "--> compact_lang_det_test_chrome... "
echo "this is some english text" | ./compact_lang_det_test_chrome
echo -n "--> cld2_unittest... "
./cld2_unittest > /dev/null
echo -n "--> cld2_unittest_avoid... "
./cld2_unittest_avoid > /dev/null
# ----------------------------------------------------------------------------
echo "--> [3 of 7] Invoking: compile_libs.sh..."
./compile_libs.sh
# ----------------------------------------------------------------------------
echo "--> [4 of 7] Invoking: compile_full.sh..."
./compile_full.sh
echo "--> [5 of 7] Testing results of compile_full.sh..."
echo "--> compact_lang_det_test_full... "
echo "this is some english text" | ./compact_lang_det_test_full
echo -n "--> cld2_unittest_full... "
./cld2_unittest_full > /dev/null
echo -n "--> cld2_unittest_full_avoid... "
./cld2_unittest_full_avoid > /dev/null
# ----------------------------------------------------------------------------
echo "--> [6 of 7] Invoking: compile_dynamic.sh..."
./compile_dynamic.sh
echo "--> [6 of 7] Dumping dynamic data to cld2_data.bin..."
./cld2_dynamic_data_tool --dump cld2_data.bin
echo "--> [6 of 7] Verifying dynamic data in cld2_data.bin..."
./cld2_dynamic_data_tool --verify cld2_data.bin
echo "--> [7 of 7] Testing results of compile_dynamic.sh..."
echo "--> compact_lang_det_dynamic_test_chrome... "
echo "this is some english text" | ./compact_lang_det_dynamic_test_chrome --data-file cld2_data.bin
echo -n "--> cld2_dynamic_unittest... "
./cld2_dynamic_unittest --data-file cld2_data.bin > /dev/null
trap - INT TERM EXIT
echo "All libraries compiled and all tests passed!"