@@ -59,10 +59,10 @@ class E2ETestHelper {
5959
6060 boost::filesystem::create_directories ( TEST_DATA_ROOT_DIR );
6161
62- setTestEnvVar ( " DATA_DIR" , TEST_DATA_ROOT_DIR .c_str () );
62+ TestUtils:: setTestEnvVar ( " DATA_DIR" , TEST_DATA_ROOT_DIR .c_str () );
6363
6464 // Keep default runtime for fast tests unless caller already set TEST_TIME_S.
65- setTestEnvVar ( " TEST_TIME_S" , " 4" , 0 );
65+ TestUtils:: setTestEnvVar ( " TEST_TIME_S" , " 4" , 0 );
6666 }
6767
6868 static void startEngine (
@@ -126,37 +126,6 @@ class E2ETestHelper {
126126 delete _engine;
127127 _engine = nullptr ;
128128 }
129-
130- // ========= Environment variable helpers for tests =========
131- struct TestEnvVarSnapshot {
132- bool hadPreviousValue = false ;
133- string previousValue;
134- };
135-
136- static TestEnvVarSnapshot setTestEnvVar (
137- const string& _envName, const string& _envValue, int _overwrite = 1 ) {
138- TestEnvVarSnapshot snapshot;
139- const char * previousValue = std::getenv ( _envName.c_str () );
140- if ( previousValue != nullptr ) {
141- snapshot.hadPreviousValue = true ;
142- snapshot.previousValue = previousValue;
143- }
144-
145- CATCH_REQUIRE ( setenv ( _envName.c_str (), _envValue.c_str (), _overwrite ) == 0 );
146- return snapshot;
147- }
148-
149- static void unsetTestEnvVar ( const string& _envName ) {
150- CATCH_REQUIRE ( unsetenv ( _envName.c_str () ) == 0 );
151- }
152-
153- static void restoreTestEnvVar ( const string& _envName, const TestEnvVarSnapshot& _snapshot ) {
154- if ( _snapshot.hadPreviousValue ) {
155- CATCH_REQUIRE ( setenv ( _envName.c_str (), _snapshot.previousValue .c_str (), 1 ) == 0 );
156- } else {
157- unsetTestEnvVar ( _envName );
158- }
159- }
160129};
161130
162131} // namespace E2ETestUtils
0 commit comments