コード例 #1
0
 def test_warn_with_decoderc(self):
     self.setupStep(
         shell.WarningCountingShellCommand(command=['make'],
                                           decodeRC={3: WARNINGS}))
     self.expectCommands(
         ExpectShell(
             workdir='wkdir',
             command=["make"],
         ) + ExpectShell.log('stdio', stdout='I might fail with rc') + 3)
     self.expectOutcome(result=WARNINGS)
     self.expectProperty("warnings-count", 0)
     return self.runStep()
コード例 #2
0
 def test_default_pattern(self):
     self.setupStep(shell.WarningCountingShellCommand(command=['make']))
     self.expectCommands(
         ExpectShell(
             workdir='wkdir', usePTY='slave-config', command=["make"]) +
         ExpectShell.log(
             'stdio', stdout='normal: foo\nwarning: blarg!\nalso normal') +
         0)
     self.expectOutcome(result=WARNINGS, status_text=["'make'", "warnings"])
     self.expectProperty("warnings-count", 1)
     self.expectLogfile("warnings (1)", "warning: blarg!\n")
     return self.runStep()
コード例 #3
0
 def test_fail_with_warnings(self):
     self.setupStep(shell.WarningCountingShellCommand(command=['make']))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=["make"])
         + ExpectShell.log('stdio', stdout='warning: I might fail')
         + 3
     )
     self.expectOutcome(result=FAILURE)
     self.expectProperty("warnings-count", 1)
     self.expectLogfile("warnings (1)", "warning: I might fail\n")
     return self.runStep()
コード例 #4
0
 def test_default_pattern(self):
     self.setupStep(shell.WarningCountingShellCommand(command=['make']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=["make"]) +
         ExpectShell.log('stdio',
                         stdout='normal: foo\nwarning: blarg!\n'
                         'also normal\nWARNING: blarg!\n') + 0)
     self.expectOutcome(result=WARNINGS)
     self.expectProperty("warnings-count", 2)
     self.expectLogfile("warnings (2)",
                        "warning: blarg!\nWARNING: blarg!\n")
     return self.runStep()
コード例 #5
0
 def test_maxWarnCount(self):
     self.setupStep(shell.WarningCountingShellCommand(command=['make'],
                                                      maxWarnCount=9))
     self.expectCommands(
         ExpectShell(workdir='wkdir',
                     command=["make"])
         + ExpectShell.log('stdio', stdout='warning: noo!\n' * 10)
         + 0
     )
     self.expectOutcome(result=FAILURE)
     self.expectProperty("warnings-count", 10)
     return self.runStep()
コード例 #6
0
 def test_no_warnings(self):
     self.setupStep(shell.WarningCountingShellCommand(workdir='w',
                                                      command=['make']))
     self.expectCommands(
         ExpectShell(workdir='w',
                     command=["make"])
         + ExpectShell.log('stdio', stdout='blarg success!')
         + 0
     )
     self.expectOutcome(result=SUCCESS)
     self.expectProperty("warnings-count", 0)
     return self.runStep()
コード例 #7
0
ファイル: test_shell.py プロジェクト: pmisik/buildbot
 def test_warn_with_decoderc(self):
     self.setup_step(
         shell.WarningCountingShellCommand(command=['make'],
                                           decodeRC={3: WARNINGS}))
     self.expect_commands(
         ExpectShell(
             workdir='wkdir',
             command=["make"],
         ).stdout('I might fail with rc').exit(3))
     self.expect_outcome(result=WARNINGS)
     self.expect_property("warnings-count", 0)
     return self.run_step()
コード例 #8
0
ファイル: test_shell.py プロジェクト: pmisik/buildbot
 def test_custom_pattern(self):
     self.setup_step(
         shell.WarningCountingShellCommand(command=['make'],
                                           warningPattern=r"scary:.*"))
     self.expect_commands(
         ExpectShell(workdir='wkdir', command=[
             "make"
         ]).stdout('scary: foo\nwarning: bar\nscary: bar').exit(0))
     self.expect_outcome(result=WARNINGS)
     self.expect_property("warnings-count", 2)
     self.expect_log_file("warnings (2)", "scary: foo\nscary: bar\n")
     return self.run_step()
コード例 #9
0
 def test_suppressions_warningExtractor_exc(self):
     def warningExtractor(step, line, match):
         raise RuntimeError("oh noes")
     step = shell.WarningCountingShellCommand(command=['make'],
                                              suppressionFile='supps',
                                              warningExtractor=warningExtractor)
     # need at least one supp to trigger warningExtractor
     supps_file = 'x:y'
     stdout = "abc.c:99: warning: seen 1"
     yield self.do_test_suppressions(step, supps_file, stdout,
                                     exp_exception=True)
     self.assertEqual(len(self.flushLoggedErrors(RuntimeError)), 1)
コード例 #10
0
ファイル: test_steps_shell.py プロジェクト: rayalan/buildbot
 def test_custom_pattern(self):
     self.setupStep(
         shell.WarningCountingShellCommand(command=['make'],
                                           warningPattern=r"scary:.*"))
     self.expectCommands(
         ExpectShell(
             workdir='wkdir', usePTY='slave-config', command=["make"]) +
         ExpectShell.log('stdio',
                         stdout='scary: foo\nwarning: bar\nscary: bar') + 0)
     self.expectOutcome(result=WARNINGS)
     self.expectProperty("warnings-count", 2)
     self.expectLogfile("warnings (2)", "scary: foo\nscary: bar\n")
     return self.runStep()
コード例 #11
0
 def test_suppressions_directories_custom(self):
     def warningExtractor(step, line, match):
         return line.split(':', 2)
     step = shell.WarningCountingShellCommand(command=['make'],
                                              suppressionFile='supps',
                                              warningExtractor=warningExtractor,
                                              directoryEnterPattern="^IN: (.*)",
                                              directoryLeavePattern="^OUT:")
     supps_file = "dir1/dir2/abc.c : .*"
     stdout = textwrap.dedent(u"""\
         IN: dir1
         IN: decoy
         OUT: decoy
         IN: dir2
         abc.c:123: warning: hello
         """)
     return self.do_test_suppressions(step, supps_file, stdout, 0, '')
コード例 #12
0
 def test_suppressions_linenos(self):
     def warningExtractor(step, line, match):
         return line.split(':', 2)
     step = shell.WarningCountingShellCommand(command=['make'],
                                              suppressionFile='supps',
                                              warningExtractor=warningExtractor)
     supps_file = "abc.c:.*:100-199\ndef.c:.*:22"
     stdout = textwrap.dedent(u"""\
         abc.c:99: warning: seen 1
         abc.c:150: warning: unseen
         def.c:22: warning: unseen
         abc.c:200: warning: seen 2
         """)
     exp_warning_log = textwrap.dedent(u"""\
         abc.c:99: warning: seen 1
         abc.c:200: warning: seen 2
         """)
     return self.do_test_suppressions(step, supps_file, stdout, 2,
                                      exp_warning_log)
コード例 #13
0
    def test_suppressions_suppressionsParameter(self):
        def warningExtractor(step, line, match):
            return line.split(':', 2)

        supps = (
                   ("abc.c", ".*", 100, 199),
                   ("def.c", ".*", 22, 22),
                )
        step = shell.WarningCountingShellCommand(command=['make'],
                                                 suppressionList=supps,
                                                 warningExtractor=warningExtractor)
        stdout = textwrap.dedent(u"""\
            abc.c:99: warning: seen 1
            abc.c:150: warning: unseen
            def.c:22: warning: unseen
            abc.c:200: warning: seen 2
            """)
        exp_warning_log = textwrap.dedent(u"""\
            abc.c:99: warning: seen 1
            abc.c:200: warning: seen 2
            """)
        return self.do_test_suppressions(step, None, stdout, 2,
                                         exp_warning_log)
コード例 #14
0
ファイル: test_shell.py プロジェクト: ynezz/buildbot
    def test_suppressions(self):
        step = shell.WarningCountingShellCommand(command=['make'], suppressionFile='supps')
        supps_file = textwrap.dedent("""\
            # example suppressions file

            amar.c : .*unused variable.*
            holding.c : .*invalid access to non-static.*
            """).strip()
        stdout = textwrap.dedent("""\
            /bin/sh ../libtool --tag=CC  --silent --mode=link gcc blah
            /bin/sh ../libtool --tag=CC  --silent --mode=link gcc blah
            amar.c: In function 'write_record':
            amar.c:164: warning: unused variable 'x'
            amar.c:164: warning: this should show up
            /bin/sh ../libtool --tag=CC  --silent --mode=link gcc blah
            /bin/sh ../libtool --tag=CC  --silent --mode=link gcc blah
            holding.c: In function 'holding_thing':
            holding.c:984: warning: invalid access to non-static 'y'
            """)
        exp_warning_log = textwrap.dedent("""\
            amar.c:164: warning: this should show up
        """)
        return self.do_test_suppressions(step, supps_file, stdout, 1,
                                         exp_warning_log)
コード例 #15
0
ファイル: test_steps_shell.py プロジェクト: rayalan/buildbot
 def test_missing_command_error(self):
     # this checks that an exception is raised for invalid arguments
     self.assertRaisesConfigError(
         "WarningCountingShellCommand's `command' argument is not "
         "specified", lambda: shell.WarningCountingShellCommand())