Dan,
Very nice! I really like that it appears that this will work for
multiple platforms, right?
Also, the information that is dumped on a failure will be very helpful
in finding which test failed.
If you wouldn't mind sharing some early changes, I'd be willing to try
this out on some other platforms as well (e.g., Windows).
I gather from below that the self.pkg(...) call automatically checks for
a 0 return code unless there is a second argument?
Thanks.
Tom
Dan Price wrote:
I'm working on rewriting the test harness for the CLI testing in
terms of python's unittest framework, to achieve a higher level of
uniformity among our test cases, and also cut down the time it
takes to develop a new test case.
At the end of this mail I've included a sample test case using
my new harness. Feedback appreciated on the usability of this
sort of API.
Notably, all of the error checking is built into the superclass
infrastructure-- so if something exits with an unexpected status or
does a traceback, we get an exception and therefore a traceback.
The depot is created for you before the test case starts and shutdown
at the end. The whole pkgsend PKG_TRANS_ID stuff is all taken care
of automagically by the "pkgsend()" routine.
The code is also designed (although not implemented) so that we should
be able to drop in a "TwoDepotTestCase" superclass which starts up
multiple depots, similar to our existing two-depot.ksh tests.
Running the attached code yields:
xanadu # python t_pkg_install_basics.py
.
----------------------------------------------------------------------
Ran 1 test in 2.707s
Something going wrong looks like this (contrived example):
E
======================================================================
ERROR: Send empty package [EMAIL PROTECTED], install and uninstall
----------------------------------------------------------------------
Traceback (most recent call last):
File "t_pkg_install_basics.py", line 51, in test_basics_1
self.pkg("verify", exit = 1)
File "/net/snowdog/aux/dp/ips-fixes/gate/src/tests/cli/testutils.py", line
94, in pkg
raise UnexpectedReturnException(output)
UnexpectedReturnException
----------------------------------------------------------------------
Ran 1 test in 2.706s
FAILED (errors=1)
Comments appreciated,
-dp
----------------- ----------------- ----------------- -----------------
#!/usr/bin/python
#
import unittest
import os
import testutils
class TestPkgInstallBasics(testutils.SingleDepotTestCase):
def test_basics_1(self):
""" Send empty package [EMAIL PROTECTED], install and uninstall
"""
durl = self.dc.get_depot_url()
self.pkgsend(durl, "open [EMAIL PROTECTED],5.11-0")
self.pkgsend(durl, "close")
self.image_create(durl)
self.pkg("status -a")
self.pkg("status", exit=1)
self.pkg("install foo")
self.pkg("status")
self.pkg("verify")
self.pkg("uninstall foo")
self.pkg("verify")
if __name__ == "__main__":
unittest.main()
----------------- ----------------- ----------------- -----------------
begin:vcard
fn:Tom Mueller
n:Mueller;Tom
org:Sun Microsystems, Inc.;Update Center/OpenInstaller Software
adr:;;21915 Hillandale Dr;Elkhorn;NE;68022;USA
email;internet:[EMAIL PROTECTED]
title:Senior Staff Engineer
tel;work:877-250-4011
tel;fax:877-250-4011
tel;home:402-916-9943
x-mozilla-html:TRUE
version:2.1
end:vcard
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss