@@ -29,13 +29,19 @@ namespace fs = cppcoro::filesystem;
29
29
30
30
namespace
31
31
{
32
+ template <bool use_current_dir = false >
32
33
class temp_dir_fixture
33
34
{
34
35
public:
35
36
36
37
temp_dir_fixture ()
37
38
{
38
- auto tempDir = fs::temp_directory_path ();
39
+ fs::path tempDir;
40
+ if constexpr (use_current_dir) {
41
+ tempDir = fs::current_path () / " tmp" ;
42
+ } else {
43
+ tempDir = fs::temp_directory_path ();
44
+ }
39
45
40
46
std::random_device random;
41
47
for (int attempt = 1 ;; ++attempt)
@@ -72,14 +78,23 @@ namespace
72
78
73
79
};
74
80
81
+ template <bool use_current_dir = false >
75
82
class temp_dir_with_io_service_fixture :
76
83
public io_service_fixture,
77
- public temp_dir_fixture
84
+ public temp_dir_fixture<use_current_dir>
78
85
{
79
86
};
80
87
}
81
88
82
- TEST_CASE_FIXTURE (temp_dir_fixture, " write a file" )
89
+ #ifdef CPPCORO_TESTS_LIMITED_RESOURCES
90
+ using tmp_dir_fixture = temp_dir_fixture<true >;
91
+ using tmp_dir_with_io_service_fixture = temp_dir_with_io_service_fixture<true >;
92
+ #else
93
+ using tmp_dir_fixture = temp_dir_fixture<>;
94
+ using tmp_dir_with_io_service_fixture = temp_dir_with_io_service_fixture<>;
95
+ #endif
96
+
97
+ TEST_CASE_FIXTURE (tmp_dir_fixture, " write a file" )
83
98
{
84
99
auto filePath = temp_dir () / " foo" ;
85
100
@@ -143,7 +158,7 @@ TEST_CASE_FIXTURE(temp_dir_fixture, "write a file")
143
158
}()));
144
159
}
145
160
146
- TEST_CASE_FIXTURE (temp_dir_with_io_service_fixture , " read write file" )
161
+ TEST_CASE_FIXTURE (tmp_dir_with_io_service_fixture , " read write file" )
147
162
{
148
163
auto run = [&]() -> cppcoro::task<>
149
164
{
@@ -168,7 +183,7 @@ TEST_CASE_FIXTURE(temp_dir_with_io_service_fixture, "read write file")
168
183
cppcoro::sync_wait (run ());
169
184
}
170
185
171
- TEST_CASE_FIXTURE (temp_dir_with_io_service_fixture , " cancel read" )
186
+ TEST_CASE_FIXTURE (tmp_dir_with_io_service_fixture , " cancel read" )
172
187
{
173
188
cppcoro::sync_wait ([&]() -> cppcoro::task<>
174
189
{
0 commit comments