aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:15:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-24 23:15:59 +0000
commitbf1d668f76ff870ac767accf85816e49c9718fe0 (patch)
tree6c30829cb5eecce26d373fdf66cc694c0a360739
parent57bbb2a8aca253593c3ed4cdeea25b2c6dab4f20 (diff)
downloadpaludis-bf1d668f76ff870ac767accf85816e49c9718fe0.tar.gz
paludis-bf1d668f76ff870ac767accf85816e49c9718fe0.tar.xz
gtest more
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/tar_merger_TEST.cc177
2 files changed, 79 insertions, 100 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 989ed31..944c634 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -98,7 +98,7 @@ add(`spec_tree', `hh', `fwd', `cc')
add(`standard_output_manager', `hh', `cc', `fwd')
add(`stripper', `hh', `cc', `fwd', `test', `testscript')
add(`syncer', `hh', `cc')
-add(`tar_merger', `hh', `cc', `fwd', `test', `testscript', `se')
+add(`tar_merger', `hh', `cc', `fwd', `gtest', `testscript', `se')
add(`tee_output_manager', `hh', `cc', `fwd')
add(`unchoices_key', `hh', `cc', `fwd')
add(`unformatted_pretty_printer', `hh', `cc', `fwd')
diff --git a/paludis/tar_merger_TEST.cc b/paludis/tar_merger_TEST.cc
index 9627cdd..9d4725e 100644
--- a/paludis/tar_merger_TEST.cc
+++ b/paludis/tar_merger_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2010 Ciaran McCreesh
+ * Copyright (c) 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,8 +18,11 @@
*/
#include <paludis/tar_merger.hh>
-#include <paludis/environments/test/test_environment.hh>
#include <paludis/hooker.hh>
+#include <paludis/hook.hh>
+
+#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/timestamp.hh>
@@ -28,14 +31,12 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/fs_stat.hh>
-#include <paludis/hook.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
+#include <gtest/gtest.h>
#include "config.h"
using namespace paludis;
-using namespace test;
namespace
{
@@ -44,10 +45,7 @@ namespace
{
return std::make_pair(-1, -1);
}
-}
-namespace
-{
struct TestTarMerger :
TarMerger
{
@@ -82,101 +80,82 @@ namespace
};
}
-namespace test_cases
-{
#if ENABLE_PBINS
- struct SimpleTarMergerTest : TestCase
- {
- SimpleTarMergerTest() : TestCase("simple tar merge") { }
-
- bool repeatable() const
- {
- return false;
- }
-
- void run()
- {
- auto output(FSPath("tar_merger_TEST_dir") / "simple.tar");
-
- TestEnvironment env;
- TestTarMerger merger(make_named_values<TarMergerParams>(
- n::compression() = tmc_none,
- n::environment() = &env,
- n::fix_mtimes_before() = Timestamp(0, 0),
- n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,
- n::image() = FSPath("tar_merger_TEST_dir") / "simple",
- n::install_under() = FSPath("/"),
- n::maybe_output_manager() = make_null_shared_ptr(),
- n::merged_entries() = std::make_shared<FSPathSet>(),
- n::no_chown() = true,
- n::options() = MergerOptions(),
- n::root() = FSPath("/"),
- n::tar_file() = output
- ));
-
- TEST_CHECK(! output.stat().is_regular_file());
-
- merger.merge();
- output = FSPath(stringify(output));
-
- TEST_CHECK(output.stat().is_regular_file());
- TEST_CHECK(output.stat().file_size() > 100);
-
- Process untar_process(ProcessCommand({"sh", "-c", "tar xf ../simple.tar 2>&1"}));
- untar_process.chdir(FSPath("tar_merger_TEST_dir/simple_extract"));
- TEST_CHECK_EQUAL(0, untar_process.run().wait());
-
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "file").stat().is_regular_file());
- TEST_CHECK_EQUAL((FSPath("tar_merger_TEST_dir") / "simple_extract" / "file").stat().file_size(),
- (FSPath("tar_merger_TEST_dir") / "simple" / "file").stat().file_size());
-
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "another").stat().is_regular_file());
-
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").stat().is_regular_file());
- TEST_CHECK(0 != ((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").stat().permissions() & S_IXUSR));
-
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "goodsym").stat().is_symlink());
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "goodsym").readlink() == "file");
-
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "badsym").stat().is_symlink());
- TEST_CHECK((FSPath("tar_merger_TEST_dir") / "simple_extract" / "badsym").readlink() == "nothing");
- }
- } test_simple_tar_merger;
+TEST(TarMerger, Works)
+{
+ auto output(FSPath("tar_merger_TEST_dir") / "simple.tar");
+
+ TestEnvironment env;
+ TestTarMerger merger(make_named_values<TarMergerParams>(
+ n::compression() = tmc_none,
+ n::environment() = &env,
+ n::fix_mtimes_before() = Timestamp(0, 0),
+ n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,
+ n::image() = FSPath("tar_merger_TEST_dir") / "simple",
+ n::install_under() = FSPath("/"),
+ n::maybe_output_manager() = make_null_shared_ptr(),
+ n::merged_entries() = std::make_shared<FSPathSet>(),
+ n::no_chown() = true,
+ n::options() = MergerOptions(),
+ n::root() = FSPath("/"),
+ n::tar_file() = output
+ ));
+
+ ASSERT_TRUE(! output.stat().is_regular_file());
+
+ merger.merge();
+ output = FSPath(stringify(output));
+
+ ASSERT_TRUE(output.stat().is_regular_file());
+ EXPECT_TRUE(output.stat().file_size() > 100);
+
+ Process untar_process(ProcessCommand({"sh", "-c", "tar xf ../simple.tar 2>&1"}));
+ untar_process.chdir(FSPath("tar_merger_TEST_dir/simple_extract"));
+ ASSERT_EQ(0, untar_process.run().wait());
+
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "file").stat().is_regular_file());
+ EXPECT_EQ((FSPath("tar_merger_TEST_dir") / "simple_extract" / "file").stat().file_size(),
+ (FSPath("tar_merger_TEST_dir") / "simple" / "file").stat().file_size());
+
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "another").stat().is_regular_file());
+
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").stat().is_regular_file());
+ EXPECT_TRUE(0 != ((FSPath("tar_merger_TEST_dir") / "simple_extract" / "subdir" / "subsubdir" / "script").stat().permissions() & S_IXUSR));
+
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "goodsym").stat().is_symlink());
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "goodsym").readlink() == "file");
+
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "badsym").stat().is_symlink());
+ EXPECT_TRUE((FSPath("tar_merger_TEST_dir") / "simple_extract" / "badsym").readlink() == "nothing");
+}
#else
- struct TarMergerNotAvailable : TestCase
- {
- TarMergerNotAvailable() : TestCase("tar merger not available") { }
-
- void run()
- {
- auto output(FSPath("tar_merger_TEST_dir") / "simple.tar");
-
- TestEnvironment env;
- TestTarMerger merger(make_named_values<TarMergerParams>(
- n::compression() = tmc_none,
- n::environment() = &env,
- n::fix_mtimes_before() = Timestamp(0, 0),
- n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,
- n::image() = FSPath("tar_merger_TEST_dir") / "simple",
- n::install_under() = FSPath("/"),
- n::maybe_output_manager() = make_null_shared_ptr(),
- n::merged_entries() = std::make_shared<FSPathSet>(),
- n::no_chown() = true,
- n::options() = MergerOptions(),
- n::root() = FSPath("/"),
- n::tar_file() = output
- ));
-
- TEST_CHECK(! output.stat().is_regular_file());
-
- TEST_CHECK_THROWS(merger.merge(), NotAvailableError);
- }
- } test_tar_merger_not_available;
+TEST(TarMerger, NotAvailable)
+{
+ auto output(FSPath("tar_merger_TEST_dir") / "simple.tar");
+
+ TestEnvironment env;
+ TestTarMerger merger(make_named_values<TarMergerParams>(
+ n::compression() = tmc_none,
+ n::environment() = &env,
+ n::fix_mtimes_before() = Timestamp(0, 0),
+ n::get_new_ids_or_minus_one() = &get_new_ids_or_minus_one,
+ n::image() = FSPath("tar_merger_TEST_dir") / "simple",
+ n::install_under() = FSPath("/"),
+ n::maybe_output_manager() = make_null_shared_ptr(),
+ n::merged_entries() = std::make_shared<FSPathSet>(),
+ n::no_chown() = true,
+ n::options() = MergerOptions(),
+ n::root() = FSPath("/"),
+ n::tar_file() = output
+ ));
+
+ ASSERT_TRUE(! output.stat().is_regular_file());
+
+ EXPECT_THROW(merger.merge(), NotAvailableError);
+}
#endif
-}
-