def test_mode_incremental_no_existing_repo(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='incremental')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/.bzr', log_environ=True).exit(1), ExpectShell(workdir='wkdir', command=[ 'bzr', 'checkout', 'http://bzr.squid-cache.org/bzr/squid3/trunk', '.' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'bzr', 'version-info', '--custom', "--template='{revno}" ]).stdout('100\n').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100\n', 'Bzr') return self.run_step()
def testShellArgsAreRendered(self): arg1 = shellsequence.ShellArg( command=WithProperties('make %s', 'project')) self.setup_step( shellsequence.ShellSequence(commands=[arg1], workdir='build')) self.properties.setProperty("project", "BUILDBOT-TEST", "TEST") self.expect_commands( ExpectShell(workdir='build', command='make BUILDBOT-TEST').exit(0)) # TODO: need to factor command-summary stuff into a utility method and # use it here self.expect_outcome(result=SUCCESS, state_string="'make BUILDBOT-TEST'") return self.run_step()
def test_new_version_success(self): self.setup_step(shell.PerlModuleTest(command="cmd")) self.expect_commands( ExpectShell(workdir='wkdir', command="cmd").stdout( textwrap.dedent("""\ This junk ignored Test Summary Report Result: PASS Tests: 10 Failed: 0 Tests: 10 Failed: 0 Files=93, Tests=20""")).exit(0)) self.expect_outcome(result=SUCCESS, state_string='20 tests 20 passed') return self.run_step()
def test_noproj_build(self): self.setup_step( vstudio.VC7(projectfile='pf', config='cfg', mode='build')) self.expect_commands( ExpectShell( workdir='wkdir', command=['devenv.com', 'pf', '/Build', 'cfg'], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio .NET 2003')). exit(0)) self.expect_outcome(result=SUCCESS, state_string="compile 0 projects 0 files") return self.run_step()
def test_run_property_no_strip(self): self.setup_step( shell.SetPropertyFromCommand(property="res", command="cmd", strip=False)) self.expect_commands( ExpectShell(workdir='wkdir', command="cmd").stdout('\n\nabcdef\n').exit(0)) self.expect_outcome(result=SUCCESS, state_string="property 'res' set") self.expect_property("res", "\n\nabcdef\n") self.expect_log_file('property changes', r"res: " + repr('\n\nabcdef\n')) return self.run_step()
def test_renderable_workdir(self): self.setup_step( shell.SetPropertyFromCommand( property="res", command="cmd", workdir=properties.Interpolate('wkdir'))) self.expect_commands( ExpectShell(workdir='wkdir', command="cmd").stdout('\n\nabcdef\n').exit(0)) self.expect_outcome(result=SUCCESS, state_string="property 'res' set") self.expect_property("res", "abcdef") # note: stripped self.expect_log_file('property changes', r"res: " + repr('abcdef')) return self.run_step()
def test_run_decodeRC(self, rc=1, results=WARNINGS, extra_text=" (warnings)"): self.setup_step( shell.ShellCommand(workdir='build', command="echo hello", decodeRC={1: WARNINGS})) self.expect_commands( ExpectShell(workdir='build', command='echo hello').exit(rc)) self.expect_outcome(result=results, state_string="'echo hello'" + extra_text) return self.run_step()
def test_mode_full_copy(self): self.setup_step( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='copy')) self.expect_commands( ExpectShell(workdir='wkdir', command=['bzr', '--version']).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectRmdir(dir='build', log_environ=True).exit(0), ExpectStat(file='source/.bzr', log_environ=True).exit(0), ExpectShell(workdir='source', command=['bzr', 'update']).exit(0), ExpectCpdir(fromdir='source', log_environ=True, todir='build').exit(0), ExpectShell(workdir='source', command=[ 'bzr', 'version-info', '--custom', "--template='{revno}" ]).stdout('100').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', '100', 'Bzr') return self.run_step()
def test_architecture(self): self.setup_step(pbuilder.DebPbuilder(architecture='amd64')) self.expect_commands( ExpectStat( file='/var/cache/pbuilder/stable-amd64-buildbot.tgz').exit(1), ExpectShell(workdir='wkdir', command=[ 'sudo', '/usr/sbin/pbuilder', '--create', '--basetgz', '/var/cache/pbuilder/stable-amd64-buildbot.tgz', '--distribution', 'stable', '--mirror', 'http://cdn.debian.net/debian/', '--architecture', 'amd64' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/pbuilder', '--architecture', 'amd64', '--', '--buildresult', '.', '--basetgz', '/var/cache/pbuilder/stable-amd64-buildbot.tgz' ]).exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_installdir(self): self.setup_step( vstudio.VC11(projectfile='pf', config='cfg', project='pj')) self.expect_commands( ExpectShell( workdir='wkdir', command=[ 'devenv.com', 'pf', '/Rebuild', 'cfg', '/Project', 'pj' ], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio 11.0')).exit(0)) self.expect_outcome(result=SUCCESS, state_string="compile 0 projects 0 files") return self.run_step()
def test_env_setup_existing(self): self.setup_step( VCx(INCLUDE=[r'c:\INC1', r'c:\INC2'], LIB=[r'c:\LIB1', r'C:\LIB2'], PATH=[r'c:\P1', r'C:\P2'])) self.expect_commands( ExpectShell(workdir='wkdir', command=['command', 'here'], env=dict(INCLUDE=r'c:\INC1;c:\INC2;', LIB=r'c:\LIB1;C:\LIB2;', PATH=r'c:\P1;C:\P2;')).exit(0)) self.expect_outcome(result=SUCCESS, state_string="compile 0 projects 0 files") return self.run_step()
def test_success_suppressTags(self): self.setup_step( lintian.DebLintian( 'foo_0.23_i386.changes', suppressTags=['bad-distribution-in-changes-file'])) self.expect_commands( ExpectShell(workdir='wkdir', command=[ 'lintian', '-v', 'foo_0.23_i386.changes', '--suppress-tags', 'bad-distribution-in-changes-file' ]).exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_run_nested_description(self): self.setup_step( shell.ShellCommand( workdir='build', command=properties.FlattenList( ['trial', ['-b', '-B'], 'buildbot.test']), descriptionDone=properties.FlattenList(['test', ['done']]), descriptionSuffix=properties.FlattenList(['suff', ['ix']]))) self.expect_commands( ExpectShell(workdir='build', command=['trial', '-b', '-B', 'buildbot.test']).exit(0)) self.expect_outcome(result=SUCCESS, state_string='test done suff ix') return self.run_step()
def test_autoRelease(self): self.setup_step( rpmbuild.RpmBuild(specfile="foo.spec", autoRelease=True)) self.expect_commands( ExpectShell( workdir='wkdir', command='rpmbuild --define "_topdir ' '`pwd`" --define "_builddir `pwd`" --define "_rpmdir `pwd`" ' '--define "_sourcedir `pwd`" --define "_specdir `pwd`" ' '--define "_srcrpmdir `pwd`" --define "_release 0" ' '--define "dist .el6" -ba foo.spec').stdout( 'Your code has been rated at 10/10').exit(0)) self.expect_outcome(result=SUCCESS, state_string='RPMBUILD') return self.run_step()
def test_success(self): stream = io.BytesIO() client = TestProtocolClient(stream) test = FakeTest(id='test1') client.startTest(test) client.stopTest(test) self.setup_step(subunit.SubunitShellCommand(command='test')) self.expect_commands( ExpectShell(workdir='wkdir', command="test").stdout(stream.getvalue()).exit(0)) self.expect_outcome(result=SUCCESS, state_string="shell 1 test passed") return self.run_step()
def test_buildonly(self): self.setup_step(pbuilder.DebCowbuilder()) self.expect_commands( ExpectStat(file='/var/cache/pbuilder/stable-local-buildbot.cow/'). stat_dir(mtime=int(time.time())).exit(0), ExpectShell(workdir='wkdir', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/cowbuilder', '--', '--buildresult', '.', '--basepath', '/var/cache/pbuilder/stable-local-buildbot.cow/' ]).exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
def test_new(self): self.setup_step(pbuilder.UbuCowbuilder(distribution='oneiric')) self.expect_commands( ExpectStat(file='/var/cache/pbuilder/oneiric-local-buildbot.cow/'). exit(1), ExpectShell(workdir='wkdir', command=[ 'sudo', '/usr/sbin/cowbuilder', '--create', '--basepath', '/var/cache/pbuilder/oneiric-local-buildbot.cow/', '--distribution', 'oneiric', '--mirror', 'http://archive.ubuntu.com/ubuntu/', '--components', 'main universe' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/cowbuilder', '--', '--buildresult', '.', '--basepath', '/var/cache/pbuilder/oneiric-local-buildbot.cow/' ]).exit(0)) self.expect_outcome(result=SUCCESS, state_string='built') return self.run_step()
def test_run_extract_fn_cmdfail(self): def extract_fn(rc, stdout, stderr): self.assertEqual((rc, stdout, stderr), (3, '', '')) return dict(a=1, b=2) self.setup_step( shell.SetPropertyFromCommand(extract_fn=extract_fn, command="cmd")) self.expect_commands( ExpectShell(workdir='wkdir', command="cmd").exit(3)) # note that extract_fn *is* called anyway self.expect_outcome(result=FAILURE, state_string="2 properties set (failure)") self.expect_log_file('property changes', 'a: 1\nb: 2') return self.run_step()
def test_components(self): self.setup_step(pbuilder.DebPbuilder(components='main universe')) self.expect_commands( ExpectStat( file='/var/cache/pbuilder/stable-local-buildbot.tgz').exit(1), ExpectShell(workdir='wkdir', command=[ 'sudo', '/usr/sbin/pbuilder', '--create', '--basetgz', '/var/cache/pbuilder/stable-local-buildbot.tgz', '--distribution', 'stable', '--mirror', 'http://cdn.debian.net/debian/', '--components', 'main universe' ]).exit(0), ExpectShell(workdir='wkdir', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/pbuilder', '--', '--buildresult', '.', '--basetgz', '/var/cache/pbuilder/stable-local-buildbot.tgz' ]).exit(0)) self.expect_outcome(result=SUCCESS) return self.run_step()
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_regex_text_ids_0_24(self): # pylint >= 0.24.0 prints out column offsets when using text format self.setup_step(python.PyLint(command=['pylint'], store_results=False)) self.expect_commands( ExpectShell(workdir='wkdir', command=['pylint']) .stdout('W0311: 11,0: Bad indentation.\n' 'C0111: 3,10:foo123: Missing docstring\n') .exit((python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))) self.expect_outcome(result=WARNINGS, state_string='pylint convention=1 warning=1 (warnings)') self.expect_property('pylint-warning', 1) self.expect_property('pylint-convention', 1) self.expect_property('pylint-total', 2) return self.run_step()
def test_warnings(self): self.setup_step(python.Sphinx(sphinx_builddir="_build")) self.expect_commands( ExpectShell(workdir='wkdir', command=['sphinx-build', '.', '_build']) .stdout(log_output_warnings) .exit(0) ) self.expect_outcome(result=WARNINGS, state_string="sphinx 2 warnings (warnings)") self.expect_log_file("warnings", warnings) yield self.run_step() self.assertEqual(self.step.statistics, {'warnings': 2})
def test_failure_zero_returncode(self): # Make sure that errors result in a failed step when pylint's # return code is 0, e.g. when run through a wrapper script. self.setup_step(python.PyLint(command=['pylint'], store_results=False)) self.expect_commands( ExpectShell(workdir='wkdir', command=['pylint']) .stdout('W: 11: Bad indentation. Found 6 spaces, expected 4\n' 'E: 12: Undefined variable \'foo\'\n') .exit(0)) self.expect_outcome(result=FAILURE, state_string='pylint error=1 warning=1 (failure)') self.expect_property('pylint-warning', 1) self.expect_property('pylint-error', 1) return self.run_step()
def test_mode_full_copy(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='copy', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']).stdout(self.MTN_VER).exit(0), ExpectStat(file='db.mtn', log_environ=True).exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']).stdout('').exit(0), ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]).exit(0), ExpectRmdir(dir='wkdir', log_environ=True, timeout=1200).exit(0), ExpectStat(file='source/_MTN', log_environ=True).exit(0), ExpectShell(workdir='source', command=[ 'mtn', 'update', '--revision', 'h:master', '--branch', 'master' ]).exit(0), ExpectCpdir(fromdir='source', todir='build', log_environ=True, timeout=1200).exit(0), ExpectShell(workdir='build', command=['mtn', 'automate', 'select', 'w:']).stdout(self.REVID).exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_mode_full_clobber_retry(self): self.setup_step( darcs.Darcs(repourl='http://localhost/darcs', mode='full', method='clobber', retry=(0, 2))) self.expect_commands( ExpectShell(workdir='wkdir', command=['darcs', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['darcs', 'get', '--verbose', '--lazy', '--repo-name', 'wkdir', 'http://localhost/darcs']) .exit(1), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['darcs', 'get', '--verbose', '--lazy', '--repo-name', 'wkdir', 'http://localhost/darcs']) .exit(1), ExpectRmdir(dir='wkdir', log_environ=True) .exit(0), ExpectShell(workdir='.', command=['darcs', 'get', '--verbose', '--lazy', '--repo-name', 'wkdir', 'http://localhost/darcs']) .exit(0), ExpectShell(workdir='wkdir', command=['darcs', 'changes', '--max-count=1']) .stdout('Tue Aug 20 09:18:41 IST 2013 [email protected]') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property( 'got_revision', 'Tue Aug 20 09:18:41 IST 2013 [email protected]', 'Darcs') return self.run_step()
def test_mode_incremental_given_revision(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master'), dict(revision='abcdef01', )) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']).stdout(self.MTN_VER).exit(0), ExpectStat(file='db.mtn', log_environ=True).exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']).stdout('').exit(0), ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True).exit(0), ExpectShell(workdir='wkdir', command=[ 'mtn', 'update', '--revision', 'abcdef01', '--branch', 'master' ]).exit(0), ExpectShell( workdir='wkdir', command=[ 'mtn', 'automate', 'select', 'w:' ]).stdout('abcdef019a9f8b6f5c9664e3807cd34617ea928c').exit(0)) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', 'abcdef019a9f8b6f5c9664e3807cd34617ea928c', 'Monotone') return self.run_step()
def test_mode_full_clean_no_existing_checkout(self): self.setup_step( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='clean', branch='master')) self.expect_commands( ExpectShell(workdir='wkdir', command=['mtn', '--version']).stdout(self.MTN_VER).exit(0), ExpectStat(file='db.mtn', log_environ=True).exit(0), ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']).stdout('').exit(0), ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]).exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True).exit(1), ExpectStat(file='wkdir/_MTN', log_environ=True).exit(1), ExpectRmdir(dir='wkdir', log_environ=True).exit(0), ExpectShell(workdir='.', command=[ 'mtn', 'checkout', 'wkdir', '--db', 'db.mtn', '--branch', 'master' ]).exit(0), ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']).stdout(self.REVID).exit(0), ) self.expect_outcome(result=SUCCESS) self.expect_property('got_revision', self.REVID, 'Monotone') return self.run_step()
def test_regex_text_1_3_1(self): # at least pylint 1.3.1 prints out space padded column offsets when # using text format self.setup_step(python.PyLint(command=['pylint'], store_results=False)) self.expect_commands( ExpectShell(workdir='wkdir', command=['pylint']) .stdout('W: 11, 0: Bad indentation. Found 6 spaces, expected 4\n' 'C: 3,10:foo123: Missing docstring\n') .exit((python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))) self.expect_outcome(result=WARNINGS, state_string='pylint convention=1 warning=1 (warnings)') self.expect_property('pylint-warning', 1) self.expect_property('pylint-convention', 1) self.expect_property('pylint-total', 2) return self.run_step()
def test_error(self, name, store_results): self.setup_step(python.PyLint(command=['pylint'], store_results=store_results)) self.expect_commands( ExpectShell(workdir='wkdir', command=['pylint']) .stdout('W: 11: Bad indentation. Found 6 spaces, expected 4\n' 'E: 12: Undefined variable \'foo\'\n') .exit((python.PyLint.RC_WARNING | python.PyLint.RC_ERROR))) self.expect_outcome(result=FAILURE, state_string='pylint error=1 warning=1 (failure)') self.expect_property('pylint-warning', 1) self.expect_property('pylint-error', 1) if store_results: self.expect_test_result_sets([('Pylint warnings', 'code_issue', 'message')]) # note that no results are submitted for tests where we don't know the location return self.run_step()
def test_mode_incremental(self): self.setup_step( darcs.Darcs(repourl='http://localhost/darcs', mode='incremental')) self.expect_commands( ExpectShell(workdir='wkdir', command=['darcs', '--version']) .exit(0), ExpectStat(file='wkdir/.buildbot-patched', log_environ=True) .exit(1), ExpectStat(file='wkdir/_darcs', log_environ=True) .exit(0), ExpectShell(workdir='wkdir', command=['darcs', 'pull', '--all', '--verbose']) .exit(0), ExpectShell(workdir='wkdir', command=['darcs', 'changes', '--max-count=1']) .stdout('Tue Aug 20 09:18:41 IST 2013 [email protected]') .exit(0) ) self.expect_outcome(result=SUCCESS) self.expect_property( 'got_revision', 'Tue Aug 20 09:18:41 IST 2013 [email protected]', 'Darcs') return self.run_step()