17075980 pkg strips newlines from release notes
17076039 pkg could be more helpful about release notes when using -R
17089043 Several tests fail when run in locales other than C
--- a/src/client.py Mon Jul 08 13:23:41 2013 -0700
+++ b/src/client.py Mon Jul 15 11:07:32 2013 -0700
@@ -1145,7 +1145,7 @@
for a in plan.get_release_notes():
logger.info(" %s", a)
else:
- if not plan.new_be:
+ if not plan.new_be and api_inst.is_liveroot and not DebugValues["GenerateNotesFile"]:
logger.info(_("Release notes can be viewed with 'pkg history -n 1 -N'"))
else:
tmp_path = __write_tmp_release_notes(plan)
@@ -1155,13 +1155,15 @@
logger.info(_("After rebooting, use 'pkg history -n 1 -N' to view release notes."))
def __write_tmp_release_notes(plan):
- """write release notes out to a file in /tmp and return the name"""
+ """try to write release notes out to a file in /tmp and return the name"""
if plan.has_release_notes:
try:
fd, path = tempfile.mkstemp(suffix=".txt", prefix="release-notes")
tmpfile = os.fdopen(fd, "w+b")
for a in plan.get_release_notes():
- tmpfile.write(a)
+ if isinstance(a, unicode):
+ a = a.encode("utf-8")
+ print >> tmpfile, a
tmpfile.close()
return path
except Exception:
@@ -4735,7 +4737,7 @@
return EXIT_OK
def list_variant(op, api_inst, pargs, omit_headers, output_format,
- list_all_items, list_installed, verbose):
+ list_all_items, list_installed, verbose):
"""pkg variant [-Haiv] [-F format] [<variant_pattern> ...]"""
subcommand = "variant"
--- a/src/tests/cli/t_actuators.py Mon Jul 08 13:23:41 2013 -0700
+++ b/src/tests/cli/t_actuators.py Mon Jul 15 11:07:32 2013 -0700
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
import testutils
if __name__ == "__main__":
@@ -468,19 +468,21 @@
add file tmp/release-note-6 mode=0644 owner=root group=root path=/usr/share/doc/release-notes/release-note-6 release-note=feature/pkg/self@0
close """
+ multi_unicode = u"Eels are best smoked\nМоё судно на воздушной подушке полно угрей\nHovercraft can be smoked, too.\n"
+ multi_ascii = "multi-line release notes\nshould work too,\nwe'll see if they do.\n"
misc_files = {
"tmp/release-note-1":"bobcats are fun!",
"tmp/release-note-2":"wombats are fun!",
"tmp/release-note-3":"no animals were hurt...",
"tmp/release-note-4":"no vegetables were hurt...",
- "tmp/release-note-5":"multi-line release notes\nshould work too,\nwe'll see if they do.",
- "tmp/release-note-6":u"Eels are best smoked\nМоё судно на воздушной подушке полно угрей\nHovercraft can be smoked, too.\n",
+ "tmp/release-note-5":multi_ascii,
+ "tmp/release-note-6":multi_unicode
}
def setUp(self):
pkg5unittest.SingleDepotTestCase.setUp(self)
self.make_misc_files(self.misc_files)
- self.pkgsend_bulk(self.rurl, self.foo10 + self.foo11 +
+ self.pkgsend_bulk(self.rurl, self.foo10 + self.foo11 +
self.foo12 + self.foo13 + self.bar10 + self.bar11 + self.baz10 +
self.hovercraft)
self.image_create(self.rurl)
@@ -499,9 +501,9 @@
# but that user is prompted that notes are available.
self.pkg("update [email protected]")
assert self.output.find("no vegetables") == -1
+ self.pkg("uninstall '*'")
def test_release_note_2(self):
- self.pkg("uninstall '*'")
# check that release notes are printed with just -n
self.pkg("install -vn [email protected]")
self.output.index("bobcats are fun!")
@@ -518,11 +520,11 @@
# check that we say yes that release notes are available
self.pkg("history -Hn 1 -o release_notes")
self.output.index("Yes")
+ self.pkg("uninstall '*'")
def test_release_note_3(self):
# check that release notes are printed properly
# when needed and dependency is on other pkg
- self.pkg("uninstall '*'")
self.pkg("install [email protected]")
self.pkg("install -v [email protected]")
self.output.index("multi-line release notes")
@@ -535,27 +537,71 @@
# no output expected here since [email protected] isn't part of original image.
self.pkg("install [email protected] [email protected]")
assert self.output.find("multi-line release notes") == -1
+ self.pkg("uninstall '*'")
def test_release_note_4(self):
# make sure that parseable option works properly
- self.pkg("uninstall '*'")
self.pkg("install [email protected]")
self.pkg("install --parsable 0 [email protected]")
self.output.index("multi-line release notes")
self.output.index("should work too,")
self.output.index("we'll see if they do.")
self.pkg("uninstall '*'")
- # test unicode character in files
+
+ def test_release_note_5(self):
+ # test unicode character in release notes
self.pkg("install -n [email protected]")
unicode(self.output, "utf-8").index(u"Моё судно на воздушной подушке полно угрей")
unicode(self.output, "utf-8").index(u"Eels are best smoked")
- self.pkg("install -v [email protected]")
+ self.pkg("install -v [email protected]")
+ unicode(self.output, "utf-8").index(u"Моё судно на воздушной подушке полно угрей")
+ unicode(self.output, "utf-8").index(u"Eels are best smoked")
+ self.pkg("uninstall '*'")
+
+ def test_release_note_6(self):
+ # test parsable unicode
+ self.pkg("install --parsable 0 [email protected]")
+ self.pkg("history -n 1 -N")
unicode(self.output, "utf-8").index(u"Моё судно на воздушной подушке полно угрей")
unicode(self.output, "utf-8").index(u"Eels are best smoked")
self.pkg("uninstall '*'")
- self.pkg("install --parsable 0 [email protected]")
- self.pkg("history -n 1 -N")
- unicode(self.output, "utf-8").index(u"Моё судно на воздушной подушке полно угрей")
- unicode(self.output, "utf-8").index(u"Eels are best smoked")
+
+ def test_release_note_7(self):
+ # check that multiple release notes are composited properly
+ self.pkg("install [email protected]")
+ self.pkg("install -n [email protected] [email protected]")
+ uni_out = unicode(self.output, "utf-8")
+ # we indent the release notes for readability, so a strict
+ # index or compare won't work unless we remove indenting
+ # this works for our test cases since they have no leading
+ # spaces
+
+ # removing indent
+ uni_out = "\n".join((n.lstrip() for n in uni_out.split("\n")))
+
+ uni_out.index(self.multi_unicode)
+ uni_out.index(self.multi_ascii)
+ self.pkg("uninstall '*'")
+
+ def test_release_note_8(self):
+ # verify that temporary file is correctly written with /n characters
+ self.pkg("-D GenerateNotesFile=1 install [email protected]")
+ # find name of file containing release notes in output.
+ for field in unicode(self.output, "utf-8").split(u" "):
+ try:
+ if field.index(u"release-note"):
+ break
+ except:
+ pass
+ else:
+ assert "output file not found" == 0
+
+ # read release note file and check to make sure
+ # entire contents are there verbatim
+ release_note = unicode(file(field).read(), "utf-8")
+ assert self.multi_unicode == release_note
+ self.pkg("uninstall '*'")
+
+
if __name__ == "__main__":
unittest.main()
--- a/src/tests/cli/t_pkg_composite.py Mon Jul 08 13:23:41 2013 -0700
+++ b/src/tests/cli/t_pkg_composite.py Mon Jul 15 11:07:32 2013 -0700
@@ -22,6 +22,7 @@
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+
import testutils
if __name__ == "__main__":
testutils.setup_environment("../../../proto")
@@ -326,6 +327,10 @@
"""Verify that the info operation works as expected when
compositing publishers.
"""
+ # because we compare date strings we must run this in
+ # a consistent locale, which we made 'C'
+
+ os.environ['LC_ALL'] = 'C'
# Create an image and verify no packages are known.
self.image_create(self.empty_rurl, prefix=None)
--- a/src/tests/cli/t_pkg_info.py Mon Jul 08 13:23:41 2013 -0700
+++ b/src/tests/cli/t_pkg_info.py Mon Jul 15 11:07:32 2013 -0700
@@ -323,6 +323,11 @@
multiple publishers provide the same package based on
publisher search order."""
+ # because we compare date strings we must run this in
+ # a consistent locale, which we made 'C'
+
+ os.environ['LC_ALL'] = 'C'
+
# Create an isolated repository for this test
repodir = os.path.join(self.test_root, "test-ranked")
self.create_repo(repodir)
@@ -473,6 +478,11 @@
"""Verify that info returns the expected output for renamed
packages."""
+ # because we compare date strings we must run this in
+ # a consistent locale, which we made 'C'
+
+ os.environ['LC_ALL'] = 'C'
+
target10 = """
open [email protected]
close
--- a/src/tests/cli/t_pkg_temp_sources.py Mon Jul 08 13:23:41 2013 -0700
+++ b/src/tests/cli/t_pkg_temp_sources.py Mon Jul 15 11:07:32 2013 -0700
@@ -21,7 +21,7 @@
#
#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
#
import testutils
@@ -422,6 +422,10 @@
"""Verify that the info operation works as expected for
temporary origins.
"""
+ # because we compare date strings we must run this in
+ # a consistent locale, which we made 'C'
+
+ os.environ['LC_ALL'] = 'C'
# Create an image and verify no packages are known.
self.image_create(self.empty_rurl, prefix=None)