def test_simple_creation(self): """ Basic creation of ShellCommand Step """ step = ShellCommandStep( builder = self.builder, name = "shell command", command = "./run", ) step.save() self.assertTrue(step.id != None) self.assertEqual(unicode(step), "shell command") self.assertEqual(step.get_config_type(), _("shell command")) # simple update should not cause any problems step.name = "run stuff" step.save() args = step.get_config_args() self.assertEqual(args.get("name", None), "run stuff") # check command was generated correctly cmd = args.get("command", []) self.assertEqual(len(cmd), 1) self.assertEqual(cmd[0], "./run") # try instantiating buildbot config object self.assert_valid_buildbot_config(step.get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(step)
def test_with_more_options(self): """ test step creation with more options """ step = ShellCommandStep( builder = self.builder, name = "shell command", command = "./run", arguments = "-f --long-args = xyz --long-args2=nospace val_1 val_2", always_run = True, halt_on_failure = False, flunk_on_warning = True, warn_on_failure = True, warning_pattern = ".*warning.*", want_stdout = False, want_stderr = False, timeout_silence = 11, timeout_runtime = 13, ) step.save() self.assertTrue(step.id != None) self.assertEqual(unicode(step), "shell command") self.assertEqual(step.get_config_type(), _("shell command")) # check additional args args = step.get_config_args() self.assertEqual(args.get("alwaysRun", None), True) self.assertEqual(args.get("haltOnFailure", None), False) self.assertEqual(args.get("flunkOnWarning", None), True) self.assertEqual(args.get("warnOnFailure", None), True) self.assertEqual(args.get("name", None), "shell command") self.assertEqual(args.get("warningPattern", None), ".*warning.*") self.assertEqual(args.get("want_stdout", None), False) self.assertEqual(args.get("want_stderr", None), False) self.assertEqual(args.get("timeout", None), 11 * 60) self.assertEqual(args.get("maxTime", None), 13 * 60) # check that command was generated correctly cmd = args.get("command", []) self.assertEqual(cmd[0], "./run") self.assertEqual(cmd[1], "-f") self.assertEqual(cmd[2], "--long-args=xyz") self.assertEqual(cmd[3], "--long-args2=nospace") self.assertEqual(cmd[4], "val_1") self.assertEqual(cmd[5], "val_2") self.assertEqual(len(cmd), 6) # try instantiating buildbot config object self.assert_valid_buildbot_config(step.get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(step)