diff --git a/lib/pkg_editor/test/pkg_editor_test.cpp b/lib/pkg_editor/test/pkg_editor_test.cpp index d06e38ae..165f904d 100644 --- a/lib/pkg_editor/test/pkg_editor_test.cpp +++ b/lib/pkg_editor/test/pkg_editor_test.cpp @@ -53,6 +53,8 @@ using random_bytes_engine = unsigned int>; namespace fs = std::experimental::filesystem::v1; +int tmpCount = 0; + static void l_remove_file(const char *filename) { #ifdef _WIN32 _unlink(filename); @@ -469,8 +471,9 @@ static bool is_same_tmpdir(const std::vector &files, TEST(package, unpack) { int result; - fs::path tmpdir = "tmp"; - std::string tmpdir_string = tmpdir.string(); + std::string tmpdir_string = "tmp" + std::to_string(tmpCount); + tmpCount++; + fs::path tmpdir = tmpdir_string; const char *tmpdir_c_str = tmpdir_string.c_str(); std::vector files = generate_tmp_folder(tmpdir); @@ -485,12 +488,14 @@ TEST(package, unpack) { // Compare some files to be sure that they are the same. CHECK(is_same_tmpdir(files, PACK_UNPACK_DIR)); + system(("rm -rf " + tmpdir_string).c_str()); } TEST(package, unpack_buffer) { int result; - fs::path tmpdir = "tmp"; - std::string tmpdir_string = tmpdir.string(); + std::string tmpdir_string = "tmp" + std::to_string(tmpCount); + tmpCount++; + fs::path tmpdir = tmpdir_string; const char *tmpdir_c_str = tmpdir_string.c_str(); std::vector files = generate_tmp_folder(tmpdir); // Create a known good input. @@ -521,12 +526,14 @@ TEST(package, unpack_buffer) { CHECK_EQUAL(true, files_same("test/pkg_editor_test.cpp", PACK_UNPACK_DIR "/test/pkg_editor_test.cpp")); CHECK(is_same_tmpdir(files, PACK_UNPACK_DIR)); + system(("rm -rf " + tmpdir_string).c_str()); } TEST(package, unpack_buffer_stdin) { int result; - fs::path tmpdir = "tmp"; - std::string tmpdir_string = tmpdir.string(); + std::string tmpdir_string = "tmp" + std::to_string(tmpCount); + tmpCount++; + fs::path tmpdir = tmpdir_string; const char *tmpdir_c_str = tmpdir_string.c_str(); std::vector files = generate_tmp_folder(tmpdir); @@ -579,5 +586,6 @@ TEST(package, unpack_buffer_stdin) { CHECK_EQUAL(true, files_same("test/pkg_editor_test.cpp", PACK_UNPACK_DIR "/test/pkg_editor_test.cpp")); CHECK(is_same_tmpdir(files, PACK_UNPACK_DIR)); + system(("rm -rf " + tmpdir_string).c_str()); } #endif