git test: don't fail in unconfigured envs

git commit fails when user.name and user.email aren't set. Unfortunately
using git commit --author='Test Test <test@example.com>' doesn't work.

This could happen in environments where pristine users are used to build
software.

This patch is public domain.
This commit is contained in:
Clemens Lang
2012-08-12 21:22:12 +02:00
committed by Allan Odgaard
parent a92c7cda68
commit b08daa7f97

View File

@@ -20,7 +20,7 @@ class git_tests : public CxxTest::TestSuite
{
setup_t (std::string const& cmd)
{
std::string const script = text::format("{ cd '%1$s' && git init && touch .dummy && git add .dummy && git commit .dummy -mGetHead && %2$s ; } >/dev/null", jail.path().c_str(), cmd.c_str());
std::string const script = text::format("{ cd '%1$s' && git init && git config user.email 'test@example.com' && git config user.name 'Test Test' && touch .dummy && git add .dummy && git commit .dummy -mGetHead && %2$s ; } >/dev/null", jail.path().c_str(), cmd.c_str());
if(system(script.c_str()) != 0 || !(info = scm::info(jail.path(".dummy"))))
TS_FAIL(("error in setup: " + script).c_str());
}