Create test repository with TM’s PATH/TM_SVN

This can still be fooled, as we do not read variables from TextMate’s user defaults, but I think this should solve majority of issues users are reporting.
This commit is contained in:
Allan Odgaard
2012-08-27 22:07:51 +02:00
parent 09573d7e2a
commit 5add8042c1

View File

@@ -1,4 +1,5 @@
#include <scm/scm.h>
#include <settings/settings.h>
#include <test/jail.h>
#include <io/path.h>
@@ -9,12 +10,22 @@ public:
{
test::jail_t jail;
auto tmEnv = variables_for_path();
auto pathVar = tmEnv.find("PATH");
if(pathVar != tmEnv.end())
setenv("PATH", pathVar->second.c_str(), 1);
auto svnExe = tmEnv.find("TM_SVN");
if(svnExe != tmEnv.end())
setenv("TM_SVN", svnExe->second.c_str(), 1);
TSM_ASSERT_EQUALS("\n\n Unable to test subversion driver (svn executable not found).\n\n To skip this test:\n ninja scm/coerce\n\n To install required executable (via MacPorts):\n sudo port install subversion\n", system("which -s svn"), 0);
std::string const repoName = "tm-test-repo";
std::string const wcName = "tm-test-wc";
std::string const jailPath = jail.path();
std::string const script = text::format("{ cd '%s' && svnadmin create '%s' && svn co 'file://%s/%s' %s && cd '%s' && touch {clean,ignored,modified,added,missing,untracked}.txt && svn propset svn:ignore 'ignored.txt' . && svn add {clean,modified,missing}.txt && svn commit -m 'Initial commit' && svn add added.txt && svn rm missing.txt && echo foo > modified.txt; } >/dev/null", jailPath.c_str(), repoName.c_str(), jailPath.c_str(), repoName.c_str(), wcName.c_str(), wcName.c_str());
std::string const script = text::format("{ cd '%s' && \"${TM_SVN:-svn}admin\" create '%s' && \"${TM_SVN:-svn}\" co 'file://%s/%s' %s && cd '%s' && touch {clean,ignored,modified,added,missing,untracked}.txt && \"${TM_SVN:-svn}\" propset svn:ignore 'ignored.txt' . && \"${TM_SVN:-svn}\" add {clean,modified,missing}.txt && \"${TM_SVN:-svn}\" commit -m 'Initial commit' && \"${TM_SVN:-svn}\" add added.txt && \"${TM_SVN:-svn}\" rm missing.txt && echo foo > modified.txt; } >/dev/null", jailPath.c_str(), repoName.c_str(), jailPath.c_str(), repoName.c_str(), wcName.c_str(), wcName.c_str());
if(system(script.c_str()) != 0)
{