|
33 | 33 |
|
34 | 34 | #include <CUnit/Basic.h> |
35 | 35 |
|
36 | | -/* FIXME this needs to be updated somehow to allow the tests to be run from |
37 | | - * different directories, i.e., with ninja -C build test |
38 | | - */ |
39 | | -#define TEST_DATA_DIR "test_data" |
40 | | - |
41 | 36 | /* Global variables used for test in state in the test suite */ |
42 | 37 |
|
43 | 38 | char *_tmp_file_name; |
44 | 39 | FILE *_devnull; |
| 40 | +static const char *_test_data_dir; |
45 | 41 |
|
46 | 42 | tsk_treeseq_t _single_tree_ex_ts; |
47 | 43 | /* 3.00┊ 0 ┊ */ |
@@ -1317,14 +1313,19 @@ tsinfer_suite_init(void) |
1317 | 1313 | if (_devnull == NULL) { |
1318 | 1314 | return CUE_SINIT_FAILED; |
1319 | 1315 | } |
| 1316 | + _test_data_dir = getenv("TSI_TEST_DATA_DIR"); |
| 1317 | + if (_test_data_dir == NULL) { |
| 1318 | + _test_data_dir = "test_data/"; |
| 1319 | + } |
1320 | 1320 |
|
1321 | | - ret = tsk_treeseq_load( |
1322 | | - &_single_tree_ex_ts, TEST_DATA_DIR "/single_tree_example.trees", 0); |
| 1321 | + char path[4096]; |
| 1322 | + snprintf(path, sizeof(path), "%s%s", _test_data_dir, "single_tree_example.trees"); |
| 1323 | + ret = tsk_treeseq_load(&_single_tree_ex_ts, path, 0); |
1323 | 1324 | if (ret != 0) { |
1324 | 1325 | return CUE_SINIT_FAILED; |
1325 | 1326 | } |
1326 | | - ret = tsk_treeseq_load( |
1327 | | - &_multi_tree_ex_ts, TEST_DATA_DIR "/multi_tree_example.trees", 0); |
| 1327 | + snprintf(path, sizeof(path), "%s%s", _test_data_dir, "multi_tree_example.trees"); |
| 1328 | + ret = tsk_treeseq_load(&_multi_tree_ex_ts, path, 0); |
1328 | 1329 | if (ret != 0) { |
1329 | 1330 | return CUE_SINIT_FAILED; |
1330 | 1331 | } |
|
0 commit comments