1+ module;
2+
3+ #include <CppUtils/System/OS.hpp>
4+
15export module CppUtils.UnitTests.FileSystem.Watcher;
26
37import std;
@@ -10,18 +14,25 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
1014 {"Logger", "FileSystem/Directory", "FileSystem/File"},
1115 [](auto& suite) {
1216 using namespace std::chrono_literals;
17+ #if defined(OS_LINUX)
1318 using Logger = CppUtils::Logger<"CppUtils">;
19+ #endif
1420
1521 suite.addTest("No file", [&] {
1622 CppUtils::FileSystem::TemporaryDirectory{[&suite](const auto& directory) -> void {
1723 auto watcher = CppUtils::FileSystem::Watcher{};
1824 watcher.watch(directory / "test.tmp");
25+ #if defined(OS_LINUX)
1926 watcher.onEvent(
2027 [&suite](
2128 [[maybe_unused]] CppUtils::FileSystem::Event event,
2229 [[maybe_unused]] const std::filesystem::path& filePath) -> void {
2330 suite.expect(false);
2431 });
32+ #else
33+ auto &_ = suite;
34+ #warning "TODO onEvent not implemented for this platform"
35+ #endif
2536 std::this_thread::sleep_for(10ms);
2637 }};
2738 });
@@ -33,12 +44,17 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
3344
3445 auto watcher = CppUtils::FileSystem::Watcher{};
3546 watcher.watch(filePath);
47+ #if defined(OS_LINUX)
3648 watcher.onEvent(
3749 [&suite](
3850 [[maybe_unused]] CppUtils::FileSystem::Event event,
3951 [[maybe_unused]] const std::filesystem::path& filePath) -> void {
4052 suite.expect(false);
4153 });
54+ #else
55+ auto &_ = suite;
56+ #warning "TODO onEvent not implemented for this platform"
57+ #endif
4258 std::this_thread::sleep_for(10ms);
4359 }};
4460 });
@@ -59,6 +75,7 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
5975
6076 auto watcher = CppUtils::FileSystem::Watcher{};
6177 watcher.watch(directory);
78+ #if defined(OS_LINUX)
6279 watcher.onEvent(
6380 [](CppUtils::FileSystem::Event event,
6481 const std::filesystem::path& filePath) -> void {
@@ -80,6 +97,9 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
8097 suite.expectEqual(eventFilePath, filePath);
8198 expectCloseFile = true;
8299 });
100+ #else
101+ #warning "TODO onEvent not implemented for this platform"
102+ #endif
83103
84104 CppUtils::FileSystem::String::write(directory / "test.tmp", "Hello World!");
85105 std::this_thread::sleep_for(100ms);
@@ -96,6 +116,7 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
96116
97117 auto watcher = CppUtils::FileSystem::Watcher{};
98118 watcher.watch(filePath);
119+ #if defined(OS_LINUX)
99120 watcher.onEvent(
100121 [](CppUtils::FileSystem::Event event,
101122 const std::filesystem::path& filePath) -> void {
@@ -109,6 +130,9 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
109130 suite.expectEqual(eventFilePath, filePath);
110131 expectModifyFile = true;
111132 });
133+ #else
134+ #warning "TODO onEvent not implemented for this platform"
135+ #endif
112136
113137 CppUtils::FileSystem::String::write(filePath, "Bar");
114138 std::this_thread::sleep_for(100ms);
@@ -124,6 +148,7 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
124148
125149 auto watcher = CppUtils::FileSystem::Watcher{};
126150 watcher.watch(directory);
151+ #if defined(OS_LINUX)
127152 watcher.onEvent(
128153 [](CppUtils::FileSystem::Event event,
129154 const std::filesystem::path& filePath) -> void {
@@ -137,6 +162,9 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
137162 suite.expectEqual(eventFilePath, filePath);
138163 expectModifyFile = true;
139164 });
165+ #else
166+ #warning "TODO onEvent not implemented for this platform"
167+ #endif
140168
141169 CppUtils::FileSystem::String::write(filePath, "Bar");
142170 std::this_thread::sleep_for(100ms);
@@ -152,6 +180,7 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
152180
153181 auto watcher = CppUtils::FileSystem::Watcher{};
154182 watcher.watch(directory);
183+ #if defined(OS_LINUX)
155184 watcher.onEvent(
156185 [](CppUtils::FileSystem::Event event,
157186 const std::filesystem::path& filePath) -> void {
@@ -165,6 +194,9 @@ export namespace CppUtils::UnitTest::FileSystem::Watcher
165194 suite.expectEqual(eventFilePath, filePath);
166195 expectDeleteFile = true;
167196 });
197+ #else
198+ #warning "TODO onEvent not implemented for this platform"
199+ #endif
168200
169201 std::filesystem::remove(filePath);
170202 std::this_thread::sleep_for(100ms);
0 commit comments