mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Use io::exec() instead of system()
The motivation for this change is that we may enable MallocDebug when running tests, which is done via environment variables that we do not want to be passed on to the shell tools we execute.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <scm/scm.h>
|
||||
#include <text/format.h>
|
||||
#include <io/io.h>
|
||||
#include <io/exec.h>
|
||||
#include <test/jail.h>
|
||||
|
||||
struct setup_t
|
||||
@@ -10,7 +11,7 @@ struct setup_t
|
||||
{
|
||||
static std::string const git = scm::find_executable("git", "TM_GIT");
|
||||
std::string const script = text::format("{ cd '%1$s' && '%2$s' init && '%2$s' config user.email 'test@example.com' && '%2$s' config user.name 'Test Test' && touch .dummy && '%2$s' add .dummy && '%2$s' commit .dummy -mGetHead && %3$s ; } >/dev/null", jail.path().c_str(), git.c_str(), cmd.c_str());
|
||||
if(system(script.c_str()) == 0)
|
||||
if(io::exec("/bin/sh", "-c", script.c_str(), nullptr) != NULL_STR)
|
||||
{
|
||||
if(info = scm::info(jail.path()))
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <scm/scm.h>
|
||||
#include <test/jail.h>
|
||||
#include <io/path.h>
|
||||
#include <io/exec.h>
|
||||
|
||||
void test_basic_status ()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void test_basic_status ()
|
||||
|
||||
std::string const wcPath = jail.path();
|
||||
std::string const script = text::format("{ cd '%1$s' && '%2$s' init && touch {clean,ignored,modified,added,missing,untracked}.txt && echo ignored.txt > .hgignore && '%2$s' add {.hgignore,{clean,modified,missing}.txt} && '%2$s' commit -u 'Test User' -m 'Initial commit' && '%2$s' add added.txt && rm missing.txt && echo foo > modified.txt; } >/dev/null", wcPath.c_str(), hg.c_str());
|
||||
if(system(script.c_str()) != 0)
|
||||
if(io::exec("/bin/sh", "-c", script.c_str(), nullptr) == NULL_STR)
|
||||
OAK_FAIL("error in setup: " + script);
|
||||
|
||||
if(auto info = scm::info(jail.path()))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <settings/settings.h>
|
||||
#include <test/jail.h>
|
||||
#include <io/path.h>
|
||||
#include <io/exec.h>
|
||||
|
||||
void test_basic_status ()
|
||||
{
|
||||
@@ -16,7 +17,7 @@ void test_basic_status ()
|
||||
std::string const jailPath = jail.path();
|
||||
std::string const script = text::format("{ cd '%1$s' && '%2$sadmin' create '%3$s' && '%2$s' co 'file://%1$s/%3$s' %4$s && cd '%4$s' && touch {clean,ignored,modified,added,missing,untracked}.txt && '%2$s' propset svn:ignore 'ignored.txt' . && '%2$s' add {clean,modified,missing}.txt && '%2$s' commit -m 'Initial commit' && '%2$s' add added.txt && '%2$s' rm missing.txt && echo foo > modified.txt; } >/dev/null", jailPath.c_str(), svn.c_str(), repoName.c_str(), wcName.c_str());
|
||||
|
||||
if(system(script.c_str()) != 0)
|
||||
if(io::exec("/bin/sh", "-c", script.c_str(), nullptr) == NULL_STR)
|
||||
OAK_FAIL("error in setup: " + script);
|
||||
|
||||
if(auto info = scm::info(jail.path(wcName)))
|
||||
|
||||
Reference in New Issue
Block a user