mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Update SCM tests to new API
This is both the new test system and the new (non-blocking) SCM API.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
SOURCES = src/**/*.cc
|
||||
TEST_SOURCES = tests/t_*.cc
|
||||
TESTS = tests/t_*.cc
|
||||
CP_Resources = resources/*
|
||||
EXPORT = src/{scm{,_ng},status,snapshot}.h
|
||||
LINK += text cf io settings
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
#include <scm/snapshot.h>
|
||||
#include <test/jail.h>
|
||||
|
||||
class FsTreeTests : public CxxTest::TestSuite
|
||||
void test_fs_tree ()
|
||||
{
|
||||
public:
|
||||
void test_fs_tree ()
|
||||
{
|
||||
std::string path = path::join(__FILE__, "../../..");
|
||||
TS_ASSERT_EQUALS(fs::snapshot_t(path), fs::snapshot_t(path));
|
||||
std::string path = path::join(__FILE__, "../../..");
|
||||
OAK_ASSERT_EQ(fs::snapshot_t(path), fs::snapshot_t(path));
|
||||
|
||||
test::jail_t jail;
|
||||
fs::snapshot_t jailSnapshot(jail.path());
|
||||
TS_ASSERT_DIFFERS(jailSnapshot, fs::snapshot_t(path));
|
||||
TS_ASSERT_EQUALS(jailSnapshot, fs::snapshot_t(jail.path()));
|
||||
jail.touch("foo");
|
||||
TS_ASSERT_DIFFERS(jailSnapshot, fs::snapshot_t(jail.path()));
|
||||
}
|
||||
};
|
||||
test::jail_t jail;
|
||||
fs::snapshot_t jailSnapshot(jail.path());
|
||||
OAK_ASSERT_NE(jailSnapshot, fs::snapshot_t(path));
|
||||
OAK_ASSERT_EQ(jailSnapshot, fs::snapshot_t(jail.path()));
|
||||
jail.touch("foo");
|
||||
OAK_ASSERT_NE(jailSnapshot, fs::snapshot_t(jail.path()));
|
||||
}
|
||||
|
||||
@@ -3,245 +3,242 @@
|
||||
#include <io/io.h>
|
||||
#include <test/jail.h>
|
||||
|
||||
CXXTEST_ENUM_TRAITS(scm::status::type,
|
||||
CXXTEST_ENUM_MEMBER(scm::status::unknown);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::none);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::unversioned);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::modified);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::added);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::deleted);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::conflicted);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::ignored);
|
||||
CXXTEST_ENUM_MEMBER(scm::status::mixed);
|
||||
);
|
||||
|
||||
class git_tests : public CxxTest::TestSuite
|
||||
struct setup_t
|
||||
{
|
||||
struct setup_t
|
||||
setup_t (std::string const& cmd)
|
||||
{
|
||||
setup_t (std::string const& cmd)
|
||||
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)
|
||||
{
|
||||
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());
|
||||
if(info = scm::ng::info(jail.path()))
|
||||
{
|
||||
wait_for_status(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
OAK_FAIL("no SCM info for path: " + jail.path());
|
||||
}
|
||||
}
|
||||
|
||||
scm::status::type status (std::string const& path) const
|
||||
else
|
||||
{
|
||||
return info->status(jail.path(path));
|
||||
OAK_FAIL("error in setup: " + script);
|
||||
}
|
||||
|
||||
std::string variable (std::string const& var) const
|
||||
{
|
||||
auto vars = info->variables();
|
||||
return vars.find(var) != vars.end() ? vars[var] : NULL_STR;
|
||||
}
|
||||
|
||||
private:
|
||||
test::jail_t jail;
|
||||
scm::info_ptr info;
|
||||
};
|
||||
|
||||
public:
|
||||
// =================
|
||||
// = Folder Status =
|
||||
// =================
|
||||
|
||||
void test_variables ()
|
||||
{
|
||||
setup_t wc("true");
|
||||
TS_ASSERT_EQUALS(wc.variable("TM_SCM_NAME"), "git");
|
||||
TS_ASSERT_EQUALS(wc.variable("TM_SCM_BRANCH"), "master");
|
||||
}
|
||||
|
||||
void test_empty_folder ()
|
||||
scm::status::type status (std::string const& path) const
|
||||
{
|
||||
setup_t wc("mkdir folder");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::none);
|
||||
return info->status(jail.path(path));
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_file ()
|
||||
std::string variable (std::string const& var) const
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::unversioned);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::unversioned);
|
||||
auto vars = info->variables();
|
||||
return vars.find(var) != vars.end() ? vars[var] : NULL_STR;
|
||||
}
|
||||
|
||||
void test_folder_with_ignored_file ()
|
||||
{
|
||||
setup_t wc("echo a > .git/info/exclude && mkdir folder && touch folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_and_ignored_file ()
|
||||
{
|
||||
setup_t wc("echo a > .git/info/exclude && mkdir folder && touch folder/{a,b}");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::unversioned);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_and_folder ()
|
||||
{
|
||||
setup_t wc("mkdir -p folder/b && touch folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::unversioned);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::unversioned);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/b"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_added_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::added);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_folder_with_added_and_untracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::mixed);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::added);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_added_and_ignored_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a && echo b > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::added);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::added);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/b"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_modified_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && echo update > folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::modified);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_folder_with_tracked_and_untracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a && git commit -mInitial");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::mixed);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_missing_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_missing_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a && rmdir folder");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_untracked_file ()
|
||||
{
|
||||
setup_t wc("echo folder > .git/info/exclude && mkdir folder && touch folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && echo folder > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::none);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_missing_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_missing_ignored_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a && rmdir folder && echo folder > .git/info/exclude && echo folder > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("folder"), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
// ===============
|
||||
// = File Status =
|
||||
// ===============
|
||||
|
||||
void test_untracked_file ()
|
||||
{
|
||||
setup_t wc("touch file");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_added_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_tracked_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_modified_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo update > file");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_deleted_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && rm file");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::deleted);
|
||||
}
|
||||
|
||||
// =============================
|
||||
// = Also mark file as ignored =
|
||||
// =============================
|
||||
|
||||
void test_ignored_file ()
|
||||
{
|
||||
setup_t wc("touch file && echo file > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_added_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && echo file > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_ignored_tracked_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo file > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_modified_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo update > file && echo file > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_ignored_deleted_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && rm file && echo file > .git/info/exclude");
|
||||
TS_ASSERT_EQUALS(wc.status("file"), scm::status::deleted);
|
||||
}
|
||||
private:
|
||||
test::jail_t jail;
|
||||
scm::ng::info_ptr info;
|
||||
};
|
||||
|
||||
// =================
|
||||
// = Folder Status =
|
||||
// =================
|
||||
|
||||
void test_variables ()
|
||||
{
|
||||
setup_t wc("true");
|
||||
OAK_ASSERT_EQ(wc.variable("TM_SCM_NAME"), "git");
|
||||
OAK_ASSERT_EQ(wc.variable("TM_SCM_BRANCH"), "master");
|
||||
}
|
||||
|
||||
void test_empty_folder ()
|
||||
{
|
||||
setup_t wc("mkdir folder");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::unversioned);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_ignored_file ()
|
||||
{
|
||||
setup_t wc("echo a > .git/info/exclude && mkdir folder && touch folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_and_ignored_file ()
|
||||
{
|
||||
setup_t wc("echo a > .git/info/exclude && mkdir folder && touch folder/{a,b}");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::unversioned);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_untracked_and_folder ()
|
||||
{
|
||||
setup_t wc("mkdir -p folder/b && touch folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::unversioned);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::unversioned);
|
||||
OAK_ASSERT_EQ(wc.status("folder/b"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_added_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::added);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_folder_with_added_and_untracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::mixed);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::added);
|
||||
OAK_ASSERT_EQ(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_added_and_ignored_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a && echo b > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::added);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::added);
|
||||
OAK_ASSERT_EQ(wc.status("folder/b"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_folder_with_modified_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && echo update > folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::modified);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_folder_with_tracked_and_untracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/{a,b} && git add folder/a && git commit -mInitial");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::mixed);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/b"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_folder_with_missing_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_missing_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a && rmdir folder");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_untracked_file ()
|
||||
{
|
||||
setup_t wc("echo folder > .git/info/exclude && mkdir folder && touch folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && echo folder > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::none);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_folder_with_missing_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
void test_missing_ignored_folder_with_tracked_file ()
|
||||
{
|
||||
setup_t wc("mkdir folder && touch folder/a && git add folder/a && git commit -mInitial && rm folder/a && rmdir folder && echo folder > .git/info/exclude && echo folder > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("folder"), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(wc.status("folder/a"), scm::status::deleted);
|
||||
}
|
||||
|
||||
// ===============
|
||||
// = File Status =
|
||||
// ===============
|
||||
|
||||
void test_untracked_file ()
|
||||
{
|
||||
setup_t wc("touch file");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::unversioned);
|
||||
}
|
||||
|
||||
void test_added_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_tracked_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_modified_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo update > file");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_deleted_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && rm file");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::deleted);
|
||||
}
|
||||
|
||||
// =============================
|
||||
// = Also mark file as ignored =
|
||||
// =============================
|
||||
|
||||
void test_ignored_file ()
|
||||
{
|
||||
setup_t wc("touch file && echo file > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_added_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && echo file > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::added);
|
||||
}
|
||||
|
||||
void test_ignored_tracked_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo file > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::none);
|
||||
}
|
||||
|
||||
void test_ignored_modified_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && echo update > file && echo file > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::modified);
|
||||
}
|
||||
|
||||
void test_ignored_deleted_file ()
|
||||
{
|
||||
setup_t wc("touch file && git add file && git commit -mInitial && rm file && echo file > .git/info/exclude");
|
||||
OAK_ASSERT_EQ(wc.status("file"), scm::status::deleted);
|
||||
}
|
||||
|
||||
@@ -2,39 +2,34 @@
|
||||
#include <test/jail.h>
|
||||
#include <io/path.h>
|
||||
|
||||
class hg_tests : public CxxTest::TestSuite
|
||||
void test_basic_status ()
|
||||
{
|
||||
public:
|
||||
void test_basic_status ()
|
||||
test::jail_t jail;
|
||||
|
||||
OAK_MASSERT_EQ("\n\n Unable to test mercurial driver (hg 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 mercurial\n", system("which -s hg"), 0);
|
||||
|
||||
std::string const wcPath = jail.path();
|
||||
std::string const script = text::format("{ cd '%s' && hg init && touch {clean,ignored,modified,added,missing,untracked}.txt && echo ignored.txt > .hgignore && hg add {.hgignore,{clean,modified,missing}.txt} && hg commit -u 'Test User' -m 'Initial commit' && hg add added.txt && rm missing.txt && echo foo > modified.txt; } >/dev/null", wcPath.c_str());
|
||||
if(system(script.c_str()) != 0)
|
||||
OAK_FAIL("error in setup: " + script);
|
||||
|
||||
if(auto info = scm::ng::info(jail.path()))
|
||||
{
|
||||
test::jail_t jail;
|
||||
wait_for_status(info);
|
||||
|
||||
TSM_ASSERT_EQUALS("\n\n Unable to test mercurial driver (hg 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 mercurial\n", system("which -s hg"), 0);
|
||||
auto vars = info->variables();
|
||||
OAK_ASSERT_EQ(vars["TM_SCM_NAME"], "hg");
|
||||
OAK_ASSERT_EQ(vars["TM_SCM_BRANCH"], "default");
|
||||
|
||||
std::string const wcPath = jail.path();
|
||||
std::string const script = text::format("{ cd '%s' && hg init && touch {clean,ignored,modified,added,missing,untracked}.txt && echo ignored.txt > .hgignore && hg add {.hgignore,{clean,modified,missing}.txt} && hg commit -u 'Test User' -m 'Initial commit' && hg add added.txt && rm missing.txt && echo foo > modified.txt; } >/dev/null", wcPath.c_str());
|
||||
if(system(script.c_str()) != 0)
|
||||
{
|
||||
TS_FAIL(("error in setup: " + script).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if(scm::info_ptr info = scm::info(jail.path("clean.txt")))
|
||||
{
|
||||
auto vars = info->variables();
|
||||
TS_ASSERT_EQUALS(vars["TM_SCM_NAME"], "hg");
|
||||
TS_ASSERT_EQUALS(vars["TM_SCM_BRANCH"], "default");
|
||||
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("clean.txt")), scm::status::none);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("ignored.txt")), scm::status::ignored);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("modified.txt")), scm::status::modified);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("added.txt")), scm::status::added);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("missing.txt")), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path("untracked.txt")), scm::status::unversioned);
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_FAIL(("error getting wc: " + wcPath).c_str());
|
||||
}
|
||||
OAK_ASSERT_EQ(info->status(jail.path("clean.txt")), scm::status::none);
|
||||
OAK_ASSERT_EQ(info->status(jail.path("ignored.txt")), scm::status::ignored);
|
||||
OAK_ASSERT_EQ(info->status(jail.path("modified.txt")), scm::status::modified);
|
||||
OAK_ASSERT_EQ(info->status(jail.path("added.txt")), scm::status::added);
|
||||
OAK_ASSERT_EQ(info->status(jail.path("missing.txt")), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(info->status(jail.path("untracked.txt")), scm::status::unversioned);
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
OAK_FAIL("error getting wc: " + wcPath);
|
||||
}
|
||||
}
|
||||
|
||||
9
Frameworks/scm/tests/t_scm.cc
Normal file
9
Frameworks/scm/tests/t_scm.cc
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <scm/scm.h>
|
||||
#include <test/jail.h>
|
||||
|
||||
void test_disabling_scm ()
|
||||
{
|
||||
test::jail_t jail;
|
||||
jail.set_content(".tm_properties", "scmStatus = false\n");
|
||||
OAK_ASSERT_EQ(scm::ng::info(jail.path()) ? true : false, false);
|
||||
}
|
||||
@@ -3,60 +3,49 @@
|
||||
#include <test/jail.h>
|
||||
#include <io/path.h>
|
||||
|
||||
class svn_tests : public CxxTest::TestSuite
|
||||
void test_basic_status ()
|
||||
{
|
||||
public:
|
||||
void test_basic_status ()
|
||||
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);
|
||||
|
||||
OAK_MASSERT_EQ("\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' && \"${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)
|
||||
OAK_FAIL("error in setup: " + script);
|
||||
|
||||
if(auto info = scm::ng::info(jail.path(wcName)))
|
||||
{
|
||||
test::jail_t jail;
|
||||
wait_for_status(info);
|
||||
|
||||
auto tmEnv = variables_for_path();
|
||||
std::string expectedBranch = text::format("file://%s/%s", jailPath.c_str(), repoName.c_str());
|
||||
|
||||
auto pathVar = tmEnv.find("PATH");
|
||||
if(pathVar != tmEnv.end())
|
||||
setenv("PATH", pathVar->second.c_str(), 1);
|
||||
auto vars = info->variables();
|
||||
OAK_ASSERT_EQ(vars["TM_SCM_NAME"], "svn");
|
||||
OAK_ASSERT_EQ(vars["TM_SCM_BRANCH"], expectedBranch);
|
||||
|
||||
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' && \"${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)
|
||||
{
|
||||
TS_FAIL(("error in setup: " + script).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if(scm::info_ptr info = scm::info(jail.path(path::join(wcName, "clean.txt"))))
|
||||
{
|
||||
std::string expectedBranch = text::format("file://%s/%s", jailPath.c_str(), repoName.c_str());
|
||||
|
||||
TS_ASSERT_EQUALS(expectedBranch, info->branch());
|
||||
|
||||
auto vars = info->variables();
|
||||
TS_ASSERT_EQUALS(vars["TM_SCM_NAME"], "svn");
|
||||
TS_ASSERT_EQUALS(vars["TM_SCM_BRANCH"], expectedBranch);
|
||||
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "clean.txt"))), scm::status::none);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "ignored.txt"))), scm::status::ignored);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "modified.txt"))), scm::status::modified);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "added.txt"))), scm::status::added);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "missing.txt"))), scm::status::deleted);
|
||||
TS_ASSERT_EQUALS(info->status(jail.path(path::join(wcName, "untracked.txt"))), scm::status::unversioned);
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_FAIL(("error getting wc: " + jailPath).c_str());
|
||||
}
|
||||
|
||||
jail.set_content(".tm_properties", "scmStatus = false\n");
|
||||
scm::info_ptr info = scm::info(jail.path(path::join(wcName, "clean.txt")));
|
||||
TS_ASSERT_EQUALS(info ? true : false, false);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "clean.txt"))), scm::status::none);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "ignored.txt"))), scm::status::ignored);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "modified.txt"))), scm::status::modified);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "added.txt"))), scm::status::added);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "missing.txt"))), scm::status::deleted);
|
||||
OAK_ASSERT_EQ(info->status(jail.path(path::join(wcName, "untracked.txt"))), scm::status::unversioned);
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
OAK_FAIL("error getting wc: " + jailPath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user