Skip to content

Commit 1a87d43

Browse files
committed
fixed xenium tests
1 parent 337deb7 commit 1a87d43

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ if(BAYSOR_WITH_TESTS)
186186
tests/test_main.cpp
187187
)
188188
target_link_libraries(baysor_tests PRIVATE baysor_lib GTest::gtest_main)
189-
target_compile_definitions(baysor_tests PRIVATE
190-
BAYSOR_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
191-
)
192189
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
193190
target_compile_options(baysor_tests PRIVATE -Wno-stringop-overflow)
194191
endif()

tests/test_main.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <unordered_set>
3737
#include <vector>
3838
#include <cstdio>
39+
#include <cstdlib>
3940
#include <random>
4041
#include <parquet/arrow/writer.h>
4142
#include <hdf5.h>
@@ -1842,14 +1843,30 @@ TEST(Xenium, ManifestHelpers) {
18421843
EXPECT_TRUE(baysor::is_xenium_manifest_path("experiment.xenium"));
18431844
EXPECT_FALSE(baysor::is_xenium_manifest_path("transcripts.parquet"));
18441845

1845-
const std::filesystem::path dataset_dir =
1846-
std::filesystem::path(BAYSOR_TEST_SOURCE_DIR) /
1847-
"examples/Xenium_pancreas_membrane_377/data";
1846+
char tmpl[] = "/tmp/baysor_xenium_manifest_XXXXXX";
1847+
char* created = mkdtemp(tmpl);
1848+
ASSERT_NE(created, nullptr);
1849+
1850+
const std::filesystem::path dataset_dir(created);
18481851
const std::string manifest_path = (dataset_dir / "experiment.xenium").string();
1852+
{
1853+
std::ofstream manifest(manifest_path);
1854+
ASSERT_TRUE(static_cast<bool>(manifest));
1855+
manifest << "{}\n";
1856+
}
1857+
{
1858+
std::ofstream transcripts((dataset_dir / "transcripts.parquet").string(), std::ios::binary);
1859+
ASSERT_TRUE(static_cast<bool>(transcripts));
1860+
}
1861+
18491862
auto ctx = baysor::load_xenium_manifest_context(manifest_path);
18501863
EXPECT_EQ(ctx.manifest_path, manifest_path);
18511864
EXPECT_EQ(ctx.dataset_dir, dataset_dir.string());
18521865
EXPECT_EQ(ctx.transcripts_path, (dataset_dir / "transcripts.parquet").string());
1866+
1867+
std::error_code ec;
1868+
std::filesystem::remove_all(dataset_dir, ec);
1869+
EXPECT_FALSE(ec) << ec.message();
18531870
}
18541871

18551872
// ============================================================================

0 commit comments

Comments
 (0)