summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-05-11 20:31:57 -0400
committerKenneth Heafield <github@kheafield.com>2012-05-11 20:31:57 -0400
commit708ad7d7dbfc8f8d52312c3989f86b183e12af45 (patch)
tree50400d1eecea4c8bbb85b4a13ca28b5906604b08
parente1cc454db3be1a5eedc3dba7022e813a772696d7 (diff)
Fix relative paths in tests.
-rw-r--r--Jamroot9
-rw-r--r--decoder/Jamfile2
-rw-r--r--decoder/grammar_test.cc6
-rw-r--r--mteval/Jamfile2
-rw-r--r--mteval/scorer_test.cc9
-rw-r--r--sanity.jam12
6 files changed, 22 insertions, 18 deletions
diff --git a/Jamroot b/Jamroot
index ad09509d..c9a8ee76 100644
--- a/Jamroot
+++ b/Jamroot
@@ -14,16 +14,15 @@ if [ test_header boost/serialization/map.hpp ] && [ test_library boost_serializa
project : requirements $(requirements) ;
project : default-build <threading>single <warnings>on <variant>release ;
-install-bin-libs utils//programs mteval//programs klm/lm//programs decoder//cdec ;
+install-bin-libs utils//programs mteval//programs klm/lm//programs decoder//cdec phrasinator//programs ;
-build-project mteval ;
-build-project decoder ;
+build-projects mteval decoder klm/lm ;
#Compile everything ending with _test.cc into a test and run it.
-rule all_tests ( targets * : dependencies ) {
+rule all_tests ( targets * : dependencies : properties * ) {
targets ?= [ glob *_test.cc ] ;
for t in $(targets) {
local base = [ MATCH "^(.*).cc$" : $(t) ] ;
- unit-test $(base) : $(t) $(dependencies) ..//boost_unit_test_framework ;
+ unit-test $(base) : $(t) $(dependencies) ..//boost_unit_test_framework : $(properties) ;
}
}
diff --git a/decoder/Jamfile b/decoder/Jamfile
index d7d42f28..f8112cae 100644
--- a/decoder/Jamfile
+++ b/decoder/Jamfile
@@ -65,7 +65,7 @@ lib cdec_lib :
exe cdec : cdec.cc cdec_lib ;
-all_tests [ glob *_test.cc : cfg_test.cc ] : cdec_lib ;
+all_tests [ glob *_test.cc : cfg_test.cc ] : cdec_lib : <testing.arg>$(TOP)/decoder/test_data ;
install legacy : cdec
: <location>$(TOP)/cdec <install-type>EXE <install-dependencies>on <link>shared:<dll-path>$(TOP)/cdec <link>shared:<install-type>LIB ;
diff --git a/decoder/grammar_test.cc b/decoder/grammar_test.cc
index e1a94709..4500490a 100644
--- a/decoder/grammar_test.cc
+++ b/decoder/grammar_test.cc
@@ -17,7 +17,8 @@ using namespace std;
struct GrammarTest {
GrammarTest() {
- Weights::InitFromFile("test_data/weights.gt", &wts);
+ std::string path(boost::unit_test::framework::master_test_suite().argc == 2 ? boost::unit_test::framework::master_test_suite().argv[1] : "test_data");
+ Weights::InitFromFile(path + "/weights.gt", &wts);
}
vector<weight_t> wts;
};
@@ -40,7 +41,8 @@ BOOST_AUTO_TEST_CASE(TestTextGrammar) {
}
BOOST_AUTO_TEST_CASE(TestTextGrammarFile) {
- GrammarPtr g(new TextGrammar("./test_data/grammar.prune"));
+ std::string path(boost::unit_test::framework::master_test_suite().argc == 2 ? boost::unit_test::framework::master_test_suite().argv[1] : "test_data");
+ GrammarPtr g(new TextGrammar(path + "/grammar.prune"));
vector<GrammarPtr> grammars(1, g);
LatticeArc a(TD::Convert("ein"), 0.0, 1);
diff --git a/mteval/Jamfile b/mteval/Jamfile
index f671134a..24a95e8f 100644
--- a/mteval/Jamfile
+++ b/mteval/Jamfile
@@ -5,4 +5,4 @@ exe fast_score : fast_score.cc mteval ..//utils ..//boost_program_options ;
exe mbr_kbest : mbr_kbest.cc mteval ..//utils ..//boost_program_options ;
alias programs : fast_score mbr_kbest ;
-unit-test scorer_test : scorer_test.cc mteval ..//utils ..//z ..//boost_unit_test_framework ;
+unit-test scorer_test : scorer_test.cc mteval ..//utils ..//z ..//boost_unit_test_framework : <testing.arg>$(TOP)/mteval/test_data ;
diff --git a/mteval/scorer_test.cc b/mteval/scorer_test.cc
index 0e400a3a..9b765d0f 100644
--- a/mteval/scorer_test.cc
+++ b/mteval/scorer_test.cc
@@ -36,11 +36,12 @@ struct Stuff {
BOOST_FIXTURE_TEST_SUITE( s, Stuff );
BOOST_AUTO_TEST_CASE(TestCreateFromFiles) {
+ std::string path(boost::unit_test::framework::master_test_suite().argc == 2 ? boost::unit_test::framework::master_test_suite().argv[1] : "test_data");
vector<string> files;
- files.push_back("test_data/re.txt.0");
- files.push_back("test_data/re.txt.1");
- files.push_back("test_data/re.txt.2");
- files.push_back("test_data/re.txt.3");
+ files.push_back(path + "/re.txt.0");
+ files.push_back(path + "/re.txt.1");
+ files.push_back(path + "/re.txt.2");
+ files.push_back(path + "/re.txt.3");
DocScorer ds(IBM_BLEU, files);
}
diff --git a/sanity.jam b/sanity.jam
index 1b37a4e7..a89e95f9 100644
--- a/sanity.jam
+++ b/sanity.jam
@@ -21,11 +21,7 @@ rule test_flags ( flags * ) {
echo $(cmd) ;
echo $(ret) ;
}
- if $(ret[2]) = 0 {
- return true ;
- } else {
- return ;
- }
+ return $(ret[2]) == 0 ;
}
rule test_header ( name ) {
@@ -182,3 +178,9 @@ rule install-headers ( name : list * : source-root ? ) {
source-root ?= "." ;
install $(name) : $(list) : <location>$(includedir) <install-source-root>$(source-root) ;
}
+
+rule build-projects ( projects * ) {
+ for p in $(projects) {
+ build-project $(p) ;
+ }
+}