aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:12:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:12:49 +0000
commit52deabd1187061e1218492422675b9cdedba68e5 (patch)
treec098afb86fa32c4b4dfe3a199032e5b05d6e57c6
parent52789fcda8fe25b7a001d400f4c6023f0f3ae0fe (diff)
downloadpaludis-52deabd1187061e1218492422675b9cdedba68e5.tar.gz
paludis-52deabd1187061e1218492422675b9cdedba68e5.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc72
2 files changed, 35 insertions, 41 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 006d453..3d875ea 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -434,13 +434,15 @@ aa_visitor_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
fetch_visitor_TEST_SOURCES = fetch_visitor_TEST.cc
fetch_visitor_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
fetch_visitor_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+fetch_visitor_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
source_uri_finder_TEST_SOURCES = source_uri_finder_TEST.cc
source_uri_finder_TEST_LDADD = \
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index 0619199..239c62f 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -20,25 +20,30 @@
#include <paludis/repositories/e/fetch_visitor.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_parser.hh>
+
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/sequence.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/fs_stat.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/stringify.hh>
+
+#include <paludis/standard_output_manager.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+
#include <iterator>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
using namespace paludis::erepository;
@@ -56,45 +61,32 @@ namespace
}
}
-namespace test_cases
+TEST(FetchVisitor, Works)
{
- struct FetchVisitorTest : TestCase
- {
- FetchVisitorTest() : TestCase("fetch visitor") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- env.add_repository(1, repo);
- std::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
-
- TEST_CHECK(FSPath("fetch_visitor_TEST_dir/in/input1").stat().exists());
- TEST_CHECK(! FSPath("fetch_visitor_TEST_dir/out/input1").stat().exists());
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> repo(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("repo")
+ )));
+ env.add_repository(1, repo);
+ std::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
- const std::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string("exheres-0"));
- FetchVisitor v(&env, *env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("=cat/pkg-1",
- &env, { }), make_null_shared_ptr(), { }))]->begin(),
- *eapi, FSPath("fetch_visitor_TEST_dir/out"),
- false, false, "test", std::make_shared<URIListedThenMirrorsLabel>("listed-then-mirrors"), false,
- std::make_shared<StandardOutputManager>(), get_mirrors_fn);
- parse_fetchable_uri("file:///" + stringify(FSPath("fetch_visitor_TEST_dir/in/input1").realpath()), &env, *eapi, false)->top()->accept(v);
+ ASSERT_TRUE(FSPath("fetch_visitor_TEST_dir/in/input1").stat().exists());
+ ASSERT_TRUE(! FSPath("fetch_visitor_TEST_dir/out/input1").stat().exists());
- TEST_CHECK(FSPath("fetch_visitor_TEST_dir/out/input1").stat().is_regular_file());
- SafeIFStream f(FSPath("fetch_visitor_TEST_dir/out/input1"));
- TEST_CHECK(f);
- std::string s((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
- TEST_CHECK_EQUAL(s, "contents of one\n");
- }
+ const std::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string("exheres-0"));
+ FetchVisitor v(&env, *env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("=cat/pkg-1",
+ &env, { }), make_null_shared_ptr(), { }))]->begin(),
+ *eapi, FSPath("fetch_visitor_TEST_dir/out"),
+ false, false, "test", std::make_shared<URIListedThenMirrorsLabel>("listed-then-mirrors"), false,
+ std::make_shared<StandardOutputManager>(), get_mirrors_fn);
+ parse_fetchable_uri("file:///" + stringify(FSPath("fetch_visitor_TEST_dir/in/input1").realpath()), &env, *eapi, false)->top()->accept(v);
- bool repeatable() const
- {
- return false;
- }
- } test_fetch_visitor;
+ ASSERT_TRUE(FSPath("fetch_visitor_TEST_dir/out/input1").stat().is_regular_file());
+ SafeIFStream f(FSPath("fetch_visitor_TEST_dir/out/input1"));
+ ASSERT_TRUE(f);
+ std::string s((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
+ EXPECT_EQ("contents of one\n", s);
}