def test_describe_fail(self): step = shell.ShellCommand(command=object()) self.assertEqual((step.describe(), step.describe(done=True)), (['???'],) * 2) # (describe is called twice, so two exceptions) self.assertEqual(len(self.flushLoggedErrors(TypeError)), 2)
def test_describe_from_long_command_list(self): step = shell.ShellCommand(command="this is a long command".split()) self.assertEqual((step.describe(), step.describe(done=True)), (["'this", "is", "...'"], ) * 2)
def test_describe_from_nested_command_list_deep(self): step = shell.ShellCommand(command=[["this", [[["is", ["a"]]]]]]) self.assertEqual((step.describe(), step.describe(done=True)), (["'this", "is", "...'"], ) * 2)
def test_getLegacySummary_from_short_command_list(self): step = shell.ShellCommand(workdir='build', command=["true"]) step.rendered = True self.assertLegacySummary(step, "'true'")
def test_missing_command_error(self): # this checks that an exception is raised for invalid arguments with self.assertRaisesConfigError( "ShellCommand's `command' argument is not specified"): shell.ShellCommand()
def test_getLegacySummary_unrendered_custom_new_style_class_renderable( self): step = shell.ShellCommand(command=object()) step.rendered = True self.assertLegacySummary(step, None)
def test_doStepIf_False(self): self.setupStep(shell.ShellCommand(command="echo hello", doStepIf=False)) self.expectOutcome(result=SKIPPED, state_string=u"'echo hello' (skipped)") return self.runStep()
def gen_tarball_updated_factory(rooturl, nocheck=False, configure_opts=[]): """ Make a factory for doing builds from tarballs. """ configure_cmd = [ "sh", "configure", ] + configure_opts f = factory.BuildFactory() f.addStep( shell.ShellCommand(command=[ "python", "-c", "try: import urllib2 as u\nexcept: import urllib.request as u\nopen('get_tarballs.py', 'wb').write(u.urlopen('%s').read())" % 'http://trac.xapian.org/export/HEAD/trunk/xapian-maintainer-tools/buildbot/scripts/get_tarballs.py' ], workdir='.', haltOnFailure=True)) f.addStep( shell.ShellCommand(command=["python", 'get_tarballs.py', rooturl], workdir='.', haltOnFailure=True)) f.addStep( shell.Configure(workdir='build/xapian-core', command=configure_cmd)) f.addStep(QuietenLibtool(['xapian-core/libtool'])) f.addStep(shell.Compile(workdir='build/xapian-core')) if not nocheck: f.addStep( shell.Test(workdir='build/xapian-core', name="check", command=[ "make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND=" ])) f.addStep( shell.Configure(workdir='build/xapian-omega', command=["./configure", xapian_config_arg] + configure_opts)) f.addStep(QuietenLibtool(['xapian-omega/libtool'])) f.addStep(shell.Compile(workdir='build/xapian-omega')) if not nocheck: f.addStep( shell.Test(workdir='build/xapian-omega', name="check", command=[ "make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND=" ])) f.addStep( shell.Configure(workdir='build/xapian-bindings', command=["./configure", xapian_config_arg] + configure_opts)) f.addStep(QuietenLibtool(['xapian-bindings/libtool'])) f.addStep(shell.Compile(workdir='build/xapian-bindings', command=["make"])) if not nocheck: f.addStep( shell.Test(workdir='build/xapian-bindings', name="check", command=[ "make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND=" ])) # If everything passed, there's not much point keeping the build - we'd # delete the old build tree and download new tarballs next time anyway. f.addStep(slave.RemoveDirectory('build')) return f
def test_getLegacySummary_from_med_command_list(self): step = shell.ShellCommand(command=["echo", "hello"]) step.rendered = True self.assertLegacySummary(step, "'echo hello'")
def test_describe_from_empty_command(self): # this is more of a regression test for a potential failure, really step = shell.ShellCommand(workdir='build', command=' ') self.assertEqual((step.describe(), step.describe(done=True)), (['???'],) * 2)
def test_describe_from_short_command_list(self): step = shell.ShellCommand(workdir='build', command=["true"]) self.assertEqual((step.describe(), step.describe(done=True)), (["'true'"],) * 2)
def test_describe_no_command(self): step = shell.ShellCommand(workdir='build') self.assertEqual((step.describe(), step.describe(done=True)), (['???'],) * 2)
def test_constructor_args_lists(self): step = shell.ShellCommand(workdir='build', command="echo hello", usePTY=False, description=["echoing"], descriptionDone=["echoed"]) self.assertEqual(step.description, ['echoing']) self.assertEqual(step.descriptionDone, ['echoed'])
def test_doStepIf_False(self): self.setupStep( shell.ShellCommand(command="echo hello", doStepIf=False)) self.expectOutcome(result=SKIPPED, status_text=["'echo", "hello'", "skipped"]) return self.runStep()
def test_getLegacySummary_with_suffix(self): step = shell.ShellCommand(command="echo hello", descriptionSuffix="suffix") step.rendered = True self.assertLegacySummary(step, u"'echo hello' suffix")
def test_getLegacySummary_unrendered_custom_old_style_class_renderable(self): class C: pass step = shell.ShellCommand(command=C()) step.rendered = True self.assertLegacySummary(step, None)
def test_getLegacySummary_unrendered_WithProperties(self): step = shell.ShellCommand(command=properties.WithProperties('')) step.rendered = True self.assertLegacySummary(step, None)
def test_constructor_args_validity(self): # this checks that an exception is raised for invalid arguments self.assertRaisesConfigError( "Invalid argument(s) passed to RemoteShellCommand: ", lambda: shell.ShellCommand(workdir='build', command="echo Hello World", wrongArg1=1, wrongArg2='two'))
def test_getLegacySummary_unrendered_WithProperties_list(self): step = shell.ShellCommand( command=['x', properties.WithProperties(''), 'y']) step.rendered = True self.assertLegacySummary(step, "'x y'")
def test_getLegacySummary_from_long_command_list(self): step = shell.ShellCommand(command="this is a long command".split()) step.rendered = True self.assertLegacySummary(step, u"'this is ...'")
def test_getLegacySummary_from_empty_command(self): # this is more of a regression test for a potential failure, really step = shell.ShellCommand(workdir='build', command=' ') step.rendered = True self.assertLegacySummary(step, None)
def test_getLegacySummary_from_nested_command_tuples(self): step = shell.ShellCommand(command=["this", ("is", "a"), "nested"]) step.rendered = True self.assertLegacySummary(step, u"'this is ...'")
def test_getLegacySummary_from_med_command(self): step = shell.ShellCommand(command="echo hello") step.rendered = True self.assertLegacySummary(step, u"'echo hello'")
def test_getLegacySummary_from_nested_command_list_empty(self): step = shell.ShellCommand(command=["this", [], ["is", "a"], "nested"]) step.rendered = True self.assertLegacySummary(step, u"'this is ...'")
def test_describe_from_med_command_list(self): step = shell.ShellCommand(command=["echo", "hello"]) self.assertEqual((step.describe(), step.describe(done=True)), (["'echo", "hello'"], ) * 2)
def test_getLegacySummary_from_nested_command_list_deep(self): step = shell.ShellCommand(command=[["this", [[["is", ["a"]]]]]]) step.rendered = True self.assertLegacySummary(step, u"'this is ...'")
def test_describe_from_nested_command_tuples(self): step = shell.ShellCommand(command=["this", ("is", "a"), "nested"]) self.assertEqual((step.describe(), step.describe(done=True)), (["'this", "is", "...'"], ) * 2)
def test_getLegacySummary_custom(self): step = shell.ShellCommand(command="echo hello", description=["echoing"], descriptionDone=["echoed"]) step.rendered = True self.assertLegacySummary(step, None) # handled by parent class
def test_describe_custom(self): step = shell.ShellCommand(command="echo hello", description=["echoing"], descriptionDone=["echoed"]) self.assertEqual((step.describe(), step.describe(done=True)), (['echoing'], ['echoed']))
def test_describe_unrendered_WithProperties_list(self): step = shell.ShellCommand( command=['x', properties.WithProperties(''), 'y']) self.assertEqual((step.describe(), step.describe(done=True)), (["'x", "y'"],) * 2)