diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-06-21 23:12:24 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-08-10 17:25:26 +0200 |
commit | 81460e32961bb0b9922bf8a1a27d87705d8c3e51 (patch) | |
tree | d366b8219da9a84de67d725c0f113ea5d4a470ce /test/libapt | |
parent | 463c8d801595ce5ac94d7c032264820be7434232 (diff) |
bring back deb822 sources.list entries as .sources
Having two different formats in the same file is very dirty and causes
external tools to fail hard trying to parse them. It is probably not a
good idea for them to parse them in the first place, but they do and we
shouldn't break them if there is a better way.
So we solve this issue for now by giving our deb822 format a new
filename extension ".sources" which unsupporting applications are likely
to ignore an can begin gradually moving forward rather than waiting for
the unknown applications to catch up.
Currently and for the forseeable future apt is going to support both
with the same feature set as documented in the manpage, with the
longtime plan of adopting the 'new' format as default, but that is a
long way to go and might get going more from having an easier time
setting options than from us pushing it explicitely.
Diffstat (limited to 'test/libapt')
-rw-r--r-- | test/libapt/file-helpers.cc | 11 | ||||
-rw-r--r-- | test/libapt/sourcelist_test.cc | 15 |
2 files changed, 14 insertions, 12 deletions
diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc index 387192868..6811c4158 100644 --- a/test/libapt/file-helpers.cc +++ b/test/libapt/file-helpers.cc @@ -56,10 +56,17 @@ void helperCreateLink(std::string const &dir, std::string const &targetname, std void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content) { std::string name("apt-test-"); - name.append(id).append(".XXXXXXXX"); + name.append(id); + size_t const giventmp = name.find(".XXXXXX."); + if (giventmp == std::string::npos) + name.append(".XXXXXX"); char * tempfile = strdup(name.c_str()); ASSERT_STRNE(NULL, tempfile); - int tempfile_fd = mkstemp(tempfile); + int tempfile_fd; + if (giventmp == std::string::npos) + tempfile_fd = mkstemp(tempfile); + else + tempfile_fd = mkstemps(tempfile, name.length() - (giventmp + 7)); ASSERT_NE(-1, tempfile_fd); if (filename != NULL) *filename = tempfile; diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 9e6f82213..83c441092 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -12,31 +12,26 @@ #include "file-helpers.h" -class SourceList : public pkgSourceList { - public: - using pkgSourceList::ParseFileDeb822; -}; - TEST(SourceListTest,ParseFileDeb822) { FileFd fd; std::string tempfile; - createTemporaryFile("parsefiledeb822", fd, &tempfile, + createTemporaryFile("parsefiledeb822.XXXXXX.sources", fd, &tempfile, "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" "Suites: stable\n" - "Sections: main\n" + "Components: main\n" "Description: short\n" " long description that can be very long\n" "\n" "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" "Suites: unstable\n" - "Sections: main non-free\n"); + "Components: main non-free\n"); fd.Close(); - SourceList sources; - EXPECT_EQ(2, sources.ParseFileDeb822(tempfile)); + pkgSourceList sources; + EXPECT_EQ(true, sources.Read(tempfile)); EXPECT_EQ(2, sources.size()); if (tempfile.empty() == false) |