@@ -64,6 +64,14 @@ TEST_CASE(basic_tests)
64
64
{" TMP" , env.create_dir (" dir2" )},
65
65
{" TEMP" , env.create_dir (" dir3" )},
66
66
{" TEMPDIR" , env.create_dir (" dir4" )}
67
+ #endif
68
+ };
69
+ TestCase ignored_cases[] = {
70
+ #ifdef _WIN32
71
+ {" TMPDIR" , env.create_dir (" dir5" )},
72
+ {" TEMPDIR" , env.create_dir (" dir6" )},
73
+ #else
74
+ {" USERPROFILE" , env.create_dir (" dir5" )},
67
75
#endif
68
76
};
69
77
for (auto & TC : cases) {
@@ -114,6 +122,7 @@ TEST_CASE(basic_tests)
114
122
UnsetEnv (TC.name );
115
123
}
116
124
// No env variables are defined
125
+ path fallback;
117
126
{
118
127
std::error_code ec = GetTestEC ();
119
128
path ret = temp_directory_path (ec);
@@ -123,6 +132,20 @@ TEST_CASE(basic_tests)
123
132
TEST_CHECK (ret == " /tmp" );
124
133
#endif
125
134
TEST_CHECK (is_directory (ret));
135
+ fallback = ret;
136
+ }
137
+ for (auto & TC : ignored_cases) {
138
+ // Check that certain variables are ignored
139
+ PutEnv (TC.name , TC.p );
140
+ std::error_code ec = GetTestEC ();
141
+ path ret = temp_directory_path (ec);
142
+ TEST_CHECK (!ec);
143
+
144
+ // Check that we return the same as above when no vars were defined.
145
+ TEST_CHECK (ret == fallback);
146
+
147
+ // Finally erase this env variable
148
+ UnsetEnv (TC.name );
126
149
}
127
150
}
128
151
0 commit comments