Commit c498701d by Paul Betts

Fix tests to use portable setenv

parent 222d057c
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "test_helpers.h" #include "test_helpers.h"
#include <git2.h> #include <git2.h>
#include <posix.h>
#include "filebuf.h" #include "filebuf.h"
#define CONFIG_BASE TEST_RESOURCES "/config" #define CONFIG_BASE TEST_RESOURCES "/config"
...@@ -217,7 +218,7 @@ BEGIN_TEST(config10, "a repo's config overrides the global config") ...@@ -217,7 +218,7 @@ BEGIN_TEST(config10, "a repo's config overrides the global config")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", CONFIG_BASE, 1); p_setenv("HOME", CONFIG_BASE, 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -226,7 +227,7 @@ BEGIN_TEST(config10, "a repo's config overrides the global config") ...@@ -226,7 +227,7 @@ BEGIN_TEST(config10, "a repo's config overrides the global config")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
...@@ -237,7 +238,7 @@ BEGIN_TEST(config11, "fall back to the global config") ...@@ -237,7 +238,7 @@ BEGIN_TEST(config11, "fall back to the global config")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", CONFIG_BASE, 1); p_setenv("HOME", CONFIG_BASE, 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -246,7 +247,7 @@ BEGIN_TEST(config11, "fall back to the global config") ...@@ -246,7 +247,7 @@ BEGIN_TEST(config11, "fall back to the global config")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "test_helpers.h" #include "test_helpers.h"
#include <git2.h> #include <git2.h>
#include <posix.h>
BEGIN_TEST(remotes0, "remote parsing works") BEGIN_TEST(remotes0, "remote parsing works")
git_remote *remote; git_remote *remote;
...@@ -34,7 +35,7 @@ BEGIN_TEST(remotes0, "remote parsing works") ...@@ -34,7 +35,7 @@ BEGIN_TEST(remotes0, "remote parsing works")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", "/dev/null", 1); p_setenv("HOME", "/dev/null", 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -46,7 +47,7 @@ BEGIN_TEST(remotes0, "remote parsing works") ...@@ -46,7 +47,7 @@ BEGIN_TEST(remotes0, "remote parsing works")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
...@@ -58,7 +59,7 @@ BEGIN_TEST(refspec0, "remote with refspec works") ...@@ -58,7 +59,7 @@ BEGIN_TEST(refspec0, "remote with refspec works")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", "/dev/null", 1); p_setenv("HOME", "/dev/null", 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -71,7 +72,7 @@ BEGIN_TEST(refspec0, "remote with refspec works") ...@@ -71,7 +72,7 @@ BEGIN_TEST(refspec0, "remote with refspec works")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
...@@ -83,7 +84,7 @@ BEGIN_TEST(refspec1, "remote fnmatch works as expected") ...@@ -83,7 +84,7 @@ BEGIN_TEST(refspec1, "remote fnmatch works as expected")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", "/dev/null", 1); p_setenv("HOME", "/dev/null", 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -96,7 +97,7 @@ BEGIN_TEST(refspec1, "remote fnmatch works as expected") ...@@ -96,7 +97,7 @@ BEGIN_TEST(refspec1, "remote fnmatch works as expected")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
...@@ -109,7 +110,7 @@ BEGIN_TEST(refspec2, "refspec transform") ...@@ -109,7 +110,7 @@ BEGIN_TEST(refspec2, "refspec transform")
char *old_home; char *old_home;
old_home = git__strdup(getenv("HOME")); old_home = git__strdup(getenv("HOME"));
setenv("HOME", "/dev/null", 1); p_setenv("HOME", "/dev/null", 1);
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_repository_config(&cfg, repo, NULL)); must_pass(git_repository_config(&cfg, repo, NULL));
...@@ -122,7 +123,7 @@ BEGIN_TEST(refspec2, "refspec transform") ...@@ -122,7 +123,7 @@ BEGIN_TEST(refspec2, "refspec transform")
git_config_free(cfg); git_config_free(cfg);
git_repository_free(repo); git_repository_free(repo);
setenv("HOME", old_home, 1); p_setenv("HOME", old_home, 1);
free(old_home); free(old_home);
END_TEST END_TEST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment