You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2021/03/01 20:19:26 UTC

[celix] branch feature/utils_zip_extract updated: Updates used file and dir in the utils test so that it can be used in mac and linux

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/utils_zip_extract
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/utils_zip_extract by this push:
     new e8afdfe  Updates used file and dir in the utils test so that it can be used in mac and linux
e8afdfe is described below

commit e8afdfe3051c684ec41cbcd21c9813dc36d53bb8
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Mon Mar 1 21:18:33 2021 +0100

    Updates used file and dir in the utils test so that it can be used in mac and linux
---
 libs/utils/gtest/CMakeLists.txt            |  2 ++
 libs/utils/gtest/src/FileUtilsTestSuite.cc | 10 +++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libs/utils/gtest/CMakeLists.txt b/libs/utils/gtest/CMakeLists.txt
index 4b36c0d..8111df3 100644
--- a/libs/utils/gtest/CMakeLists.txt
+++ b/libs/utils/gtest/CMakeLists.txt
@@ -48,6 +48,8 @@ endif()
 add_custom_target(test_utils_resources DEPENDS ${TEST_ZIP_FILE})
 add_dependencies(test_utils test_utils_resources)
 target_compile_definitions(test_utils PRIVATE -DTEST_ZIP_LOCATION=\"${TEST_ZIP_FILE}\")
+target_compile_definitions(test_utils PRIVATE -DTEST_A_FILE_LOCATION=\"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\")
+target_compile_definitions(test_utils PRIVATE -DTEST_A_DIR_LOCATION=\"${CMAKE_CURRENT_SOURCE_DIR}\")
 
 ####### linkig zip against test executable to text extract zip from data ###############################################
 if (UNIX AND NOT APPLE)
diff --git a/libs/utils/gtest/src/FileUtilsTestSuite.cc b/libs/utils/gtest/src/FileUtilsTestSuite.cc
index d254761..def7809 100644
--- a/libs/utils/gtest/src/FileUtilsTestSuite.cc
+++ b/libs/utils/gtest/src/FileUtilsTestSuite.cc
@@ -25,12 +25,12 @@
 class FileUtilsTestSuite : public ::testing::Test {};
 
 TEST_F(FileUtilsTestSuite, TestFileAndDirectoryExists) {
-    EXPECT_TRUE(celix_utils_fileExists("/etc"));
-    EXPECT_TRUE(celix_utils_fileExists("/etc/shadow"));
+    EXPECT_TRUE(celix_utils_fileExists(TEST_A_DIR_LOCATION));
+    EXPECT_TRUE(celix_utils_fileExists(TEST_A_FILE_LOCATION));
     EXPECT_FALSE(celix_utils_fileExists("/file-does-not-exists/check"));
 
-    EXPECT_TRUE(celix_utils_directoryExists("/etc"));
-    EXPECT_FALSE(celix_utils_directoryExists("/etc/shadow"));
+    EXPECT_TRUE(celix_utils_directoryExists(TEST_A_DIR_LOCATION));
+    EXPECT_FALSE(celix_utils_directoryExists(TEST_A_FILE_LOCATION));
     EXPECT_FALSE(celix_utils_directoryExists("/file-does-not-exists/check"));
 }
 
@@ -116,7 +116,7 @@ TEST_F(FileUtilsTestSuite, ExtractZipFileTest) {
     EXPECT_NE(error, nullptr);
 
     //Given an non zip file to extractZipFile fails
-    const char* invalidZip = "/etc/shadow";
+    const char* invalidZip = TEST_A_DIR_LOCATION;
     EXPECT_TRUE(celix_utils_fileExists(invalidZip));
     status = celix_utils_extractZipFile(invalidZip, extractLocation, &error);
     EXPECT_NE(status, CELIX_SUCCESS);