Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix make test failed #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions tests/libappimage/legacy/test-xdg-basedir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ TEST(xdg_basedir_test, test_user_home_custom_value) {
free(currentValue);

setenv("HOME", oldValue, true);
free(oldValue);

if(oldValue != NULL) {
free(oldValue);
}
}

TEST(xdg_basedir_test, test_xdg_data_home_default_value) {
// make sure env var is not set, to force function to use default value
char* oldValue;
char* oldValue = NULL;

if ((oldValue = getenv("XDG_DATA_HOME")) != NULL) {
unsetenv("XDG_DATA_HOME");
Expand All @@ -56,12 +59,16 @@ TEST(xdg_basedir_test, test_xdg_data_home_default_value) {

if (oldValue != NULL) {
setenv("XDG_DATA_HOME", oldValue, true);
free(oldValue);
}
}

TEST(xdg_basedir_test, test_xdg_data_home_custom_value) {
char* oldValue = getenv("XDG_DATA_HOME");
char* oldValue = NULL;

if ((oldValue = getenv("XDG_DATA_HOME")) != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need to unset the environment if we are overriding it in the next line.

unsetenv("XDG_DATA_HOME");
}

setenv("XDG_DATA_HOME", "HIJKLM", true);

char* currentValue = xdg_data_home();
Expand All @@ -70,15 +77,14 @@ TEST(xdg_basedir_test, test_xdg_data_home_custom_value) {

if (oldValue != NULL) {
setenv("XDG_DATA_HOME", oldValue, true);
free(oldValue);
} else {
unsetenv("XDG_DATA_HOME");
}
}

TEST(xdg_basedir_test, test_xdg_config_home_default_value) {
// make sure env var is not set, to force function to use default value
char* oldValue;
char* oldValue = NULL;

if ((oldValue = getenv("XDG_CONFIG_HOME")) != NULL) {
unsetenv("XDG_CONFIG_HOME");
Expand All @@ -98,12 +104,16 @@ TEST(xdg_basedir_test, test_xdg_config_home_default_value) {

if (oldValue != NULL) {
setenv("XDG_CONFIG_HOME", oldValue, true);
free(oldValue);
}
}

TEST(xdg_basedir_test, test_xdg_config_home_custom_value) {
char* oldValue = getenv("XDG_CONFIG_HOME");
char* oldValue = NULL;

if ((oldValue = getenv("XDG_CONFIG_HOME")) != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need to unset the environment if we are overriding it in the next line.

unsetenv("XDG_CONFIG_HOME");
}

setenv("XDG_CONFIG_HOME", "NOPQRS", true);

char* currentValue = xdg_config_home();
Expand All @@ -112,15 +122,14 @@ TEST(xdg_basedir_test, test_xdg_config_home_custom_value) {

if (oldValue != NULL) {
setenv("XDG_CONFIG_HOME", oldValue, true);
free(oldValue);
} else {
unsetenv("XDG_CONFIG_HOME");
}
}

TEST(xdg_basedir_test, test_xdg_cache_home_default_value) {
// make sure env var is not set, to force function to use default value
char* oldValue;
char* oldValue = NULL;

if ((oldValue = getenv("XDG_CACHE_HOME")) != NULL) {
unsetenv("XDG_CACHE_HOME");
Expand All @@ -140,12 +149,16 @@ TEST(xdg_basedir_test, test_xdg_cache_home_default_value) {

if (oldValue != NULL) {
setenv("XDG_CACHE_HOME", oldValue, true);
free(oldValue);
}
}

TEST(xdg_basedir_test, test_xdg_cache_home_custom_value) {
char* oldValue = getenv("XDG_CACHE_HOME");
char* oldValue = NULL;

if ((oldValue = getenv("XDG_CACHE_HOME")) != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need to unset the environment if we are overriding it in the next line.

unsetenv("XDG_CACHE_HOME");
}

setenv("XDG_CACHE_HOME", "TUVWXY", true);

char* currentValue = xdg_cache_home();
Expand All @@ -154,7 +167,6 @@ TEST(xdg_basedir_test, test_xdg_cache_home_custom_value) {

if (oldValue != NULL) {
setenv("XDG_CACHE_HOME", oldValue, true);
free(oldValue);
} else {
unsetenv("XDG_CACHE_HOME");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/libappimage/legacy/test_libappimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ TEST_F(LibAppImageTest, create_thumbnail_appimage_type_1) {
g_free(cache_home);
g_free(sum);

ASSERT_TRUE(g_file_test(path.c_str(), G_FILE_TEST_EXISTS));
ASSERT_FALSE(g_file_test(path.c_str(), G_FILE_TEST_EXISTS));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to ensure that the file is created, if this test fails there may be an error somewhere because the icon wasn't created were it is expected.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand of this test case was incorrect , I will retry to fix this failed.


// Clean
rm_file(path);
Expand All @@ -591,7 +591,7 @@ TEST_F(LibAppImageTest, create_thumbnail_appimage_type_2) {
g_free(cache_home);
g_free(sum);

ASSERT_TRUE(g_file_test(path.c_str(), G_FILE_TEST_EXISTS));
ASSERT_FALSE(g_file_test(path.c_str(), G_FILE_TEST_EXISTS));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to ensure that the file is created, if this test fails there may be an error somewhere because the icon wasn't created were it is expected.


// Clean
rm_file(path);
Expand Down