def test_command_failure(self): self.setup_step(cppcheck.Cppcheck(enable=['all'], inconclusive=True)) self.expect_commands( ExpectShell(workdir='wkdir', command=[ 'cppcheck', '.', '--enable=all', '--inconclusive' ]).stdout('Checking file1.c...').exit(1)) self.expect_outcome(result=FAILURE, state_string="cppcheck (failure)") return self.run_step()
def test_success(self): self.setupStep(cppcheck.Cppcheck(enable=['all'], inconclusive=True)) self.expectCommands( ExpectShell( workdir='wkdir', command=['cppcheck', '.', '--enable=all', '--inconclusive']) + ExpectShell.log('stdio', stdout='Checking file1.c...') + 0) self.expectOutcome(result=SUCCESS, state_string="cppcheck") return self.runStep()
def test_renderables(self): P = WithProperties self.setup_step( cppcheck.Cppcheck(binary=P('a'), source=[P('.'), P('f.c')], extra_args=[P('--p'), P('--p')])) self.expect_commands( ExpectShell(workdir='wkdir', command=['a', '.', 'f.c', '--p', '--p']).stdout('Checking file1.c...').exit(0)) self.expect_outcome(result=SUCCESS, state_string="cppcheck") return self.run_step()
def test_renderables(self): P = WithProperties self.setupStep(cppcheck.Cppcheck( binary=P('a'), source=[P('.'), P('f.c')], extra_args=[P('--p'), P('--p')])) self.expectCommands( ExpectShell(workdir='wkdir', command=['a', '.', 'f.c', '--p', '--p'], usePTY='slave-config') + ExpectShell.log( 'stdio', stdout='Checking file1.c...') + 0) self.expectOutcome(result=SUCCESS, state_string="cppcheck") return self.runStep()
def test_errors(self): self.setup_step(cppcheck.Cppcheck(extra_args=['--my-param=5'])) self.expect_commands( ExpectShell(workdir='wkdir', command=['cppcheck', '.', '--my-param=5']). stdout( 'Checking file1.c...\n' '[file1.c:3]: (error) Possible null pointer dereference: filter\n' '[file1.c:4]: (error) Memory leak: columns\n' "[file1.c:7]: (style) The scope of the variable 'pid' can be reduced" ).exit(0)) self.expect_outcome(result=FAILURE, state_string="cppcheck error=2 style=1 (failure)") return self.run_step()
def test_warnings(self): self.setupStep(cppcheck.Cppcheck(source=['file1.c'], enable=['warning', 'performance'])) self.expectCommands( ExpectShell(workdir='wkdir', command=[ 'cppcheck', 'file1.c', '--enable=warning,performance'], usePTY='slave-config') + ExpectShell.log( 'stdio', stdout=('Checking file1.c...\n' '[file1.c:3]: (warning) Logical disjunction always evaluates to true: t >= 0 || t < 65.\n' '(information) Cppcheck cannot find all the include files (use --check-config for details)')) + 0) self.expectOutcome(result=WARNINGS, state_string="cppcheck warning=1 information=1 (warnings)") return self.runStep()