def test_mode_full_copy(self): self.setupStep(mtn.Monotone(repourl="mtn://localhost/monotone", mode="full", method="copy", branch="master")) self.expectCommands( ExpectShell(workdir="wkdir", command=["mtn", "--version"]) + ExpectShell.log("stdio", stdout="monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)") + 0, ExpectShell(workdir="wkdir", command=["mtn", "db", "info", "--db", "../db.mtn"]) + ExpectShell.log("stdio", stdout="") + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 1, Expect("rmdir", dict(dir="wkdir", logEnviron=True, timeout=1200)) + 0, Expect("stat", dict(file="source/_MTN", logEnviron=True)) + 0, Expect("stat", dict(file="db.mtn", logEnviron=True)) + 0, ExpectShell( workdir="source", command=["mtn", "pull", "mtn://localhost/monotone?master", "--db=../db.mtn", "--ticker=dot"], ) + 0, ExpectShell(workdir="source", command=["mtn", "update", "--db=../db.mtn", "-r", "h:master", "-b", "master"]) + 0, Expect("cpdir", {"fromdir": "source", "todir": "build", "logEnviron": True, "timeout": 1200}) + 0, ExpectShell(workdir="build", command=["mtn", "automate", "select", "w:"]) + ExpectShell.log("stdio", stdout="95215e2a9a9f8b6f5c9664e3807cd34617ea928c") + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty("got_revision", "95215e2a9a9f8b6f5c9664e3807cd34617ea928c", "Monotone") return self.runStep()
def test_new_version_failed(self): self.setupStep(shell.PerlModuleTest(command="cmd")) self.expectCommands( ExpectShell(workdir='wkdir', usePTY='worker-config', command="cmd") + ExpectShell.log('stdio', stdout=textwrap.dedent("""\ foo.pl .. 1/4""")) + ExpectShell.log('stdio', stderr=textwrap.dedent("""\ # Failed test 2 in foo.pl at line 6 # foo.pl line 6 is: ok(0);""")) + ExpectShell.log('stdio', stdout=textwrap.dedent("""\ foo.pl .. Failed 1/4 subtests Test Summary Report ------------------- foo.pl (Wstat: 0 Tests: 4 Failed: 1) Failed test: 0 Files=1, Tests=4, 0 wallclock secs ( 0.06 usr 0.01 sys + 0.03 cusr 0.01 csys = 0.11 CPU) Result: FAIL""")) + ExpectShell.log('stdio', stderr=textwrap.dedent("""\ Failed 1/1 test programs. 1/4 subtests failed.""")) + 1 ) self.expectOutcome(result=FAILURE, state_string='4 tests 3 passed 1 failed (failure)') return self.runStep()
def test_mode_incremental_patched(self): self.setupStep(mtn.Monotone(repourl="mtn://localhost/monotone", mode="incremental", branch="master")) self.expectCommands( ExpectShell(workdir="wkdir", command=["mtn", "--version"]) + ExpectShell.log("stdio", stdout="monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)") + 0, ExpectShell(workdir="wkdir", command=["mtn", "db", "info", "--db", "../db.mtn"]) + ExpectShell.log("stdio", stdout="") + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 0, ExpectShell(workdir="wkdir", command=["mtn", "ls", "unknown"]) + ExpectShell.log("stdio", stdout="file1\nfile2") + 0, Expect("rmdir", dict(dir=["wkdir/file1", "wkdir/file2"], logEnviron=True)) + 0, Expect("stat", dict(file="wkdir/_MTN", logEnviron=True)) + 0, Expect("stat", dict(file="db.mtn", logEnviron=True)) + 0, ExpectShell( workdir="wkdir", command=["mtn", "pull", "mtn://localhost/monotone?master", "--db=../db.mtn", "--ticker=dot"], ) + 0, ExpectShell(workdir="wkdir", command=["mtn", "update", "--db=../db.mtn", "-r", "h:master", "-b", "master"]) + 0, ExpectShell(workdir="wkdir", command=["mtn", "automate", "select", "w:"]) + ExpectShell.log("stdio", stdout="95215e2a9a9f8b6f5c9664e3807cd34617ea928c") + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty("got_revision", "95215e2a9a9f8b6f5c9664e3807cd34617ea928c", "Monotone") return self.runStep()
def test_mode_full_fresh_keep_on_purge(self): self.setupStep( svn.SVN(svnurl='http://svn.local/app/trunk@HEAD', mode='full', keep_on_purge=['svn_external_path/unversioned_file1'])) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, ExpectLogged('stat', {'file': 'wkdir/.svn', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'status', '--xml', '--no-ignore', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout=self.svn_st_xml) + 0, ExpectLogged('rmdir', {'dir': 'wkdir/svn_external_path/unversioned_file2', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100\n') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_no_existing_repo_dirname(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='incremental', branchType='dirname'), ) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 1, # does not exist ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'locate', 'set:added()']) + 1, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'parents', '--template', '{node}\\n']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) return self.runStep()
def test_mode_incremental(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='incremental',username='******', password='******', extra_args=['--random'])) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache', '--username', 'user', '--password', 'pass', '--random']) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache', '--username', 'user', '--password', 'pass', '--random']) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info']) + ExpectShell.log('stdio', stdout=self.svn_info_stdout) + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty('got_revision', '100', 'SVN') return self.runStep()
def test_mode_incremental_repourl_not_updatable_svninfo_mismatch(self): self.setupStep( svn.SVN(repourl=ConstantRenderable('http://svn.local/trunk/app'), mode='incremental')) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', # expecting ../trunk/app stdout="URL: http://svn.local/branch/foo/app") + 0, Expect('rmdir', {'dir': 'wkdir', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'checkout', 'http://svn.local/trunk/app', '.', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info']) + ExpectShell.log('stdio', stdout=self.svn_info_stdout) + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty('got_revision', '100', 'SVN') return self.runStep()
def test_mode_incremental_repourl_renderable(self): self.setupStep( svn.SVN(repourl=ConstantRenderable('http://svn.local/trunk'), mode='incremental')) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout="URL: http://svn.local/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info']) + ExpectShell.log('stdio', stdout=self.svn_info_stdout) + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty('got_revision', '100', 'SVN') return self.runStep()
def test_mode_full_clobber_no_existing_db(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='clobber', branch='master')) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log('stdio', stdout=self.MTN_VER) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 1, ExpectShell(workdir='.', command=['mtn', 'db', 'init', '--db', 'db.mtn']) + 0, ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) + 0, Expect('rmdir', dict(dir='wkdir', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'checkout', 'wkdir', '--db', 'db.mtn', '--branch', 'master']) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log('stdio', stdout=self.REVID) + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', self.REVID, 'Monotone') return self.runStep()
def test_mode_full_clean_logEnviron(self): self.setupStep( mercurial.Mercurial( repourl="http://hg.mozilla.org", mode="full", method="clean", branchType="inrepo", logEnviron=False ) ) self.expectCommands( ExpectShell(workdir="wkdir", command=["hg", "--verbose", "--version"], logEnviron=False) + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=False)) + 1, Expect("stat", dict(file="wkdir/.hg", logEnviron=False)) + 0, ExpectShell( workdir="wkdir", command=["hg", "--verbose", "--config", "extensions.purge=", "purge"], logEnviron=False ) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "pull", "http://hg.mozilla.org"], logEnviron=False) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "identify", "--branch"], logEnviron=False) + ExpectShell.log("stdio", stdout="default") + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "locate", "set:added()"], logEnviron=False) + 1, ExpectShell( workdir="wkdir", command=["hg", "--verbose", "update", "--clean", "--rev", "default"], logEnviron=False ) + 0, ExpectShell( workdir="wkdir", command=["hg", "--verbose", "parents", "--template", "{node}\\n"], logEnviron=False ) + ExpectShell.log("stdio", stdout="\n") + ExpectShell.log("stdio", stdout="f6ad368298bd941e934a41f3babc827b2aa95a1d") + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_retry(self): self.setupStep( mercurial.Mercurial(repourl="http://hg.mozilla.org", mode="incremental", branchType="dirname", retry=(0, 1)) ) self.expectCommands( ExpectShell(workdir="wkdir", command=["hg", "--verbose", "--version"]) + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 1, Expect("stat", dict(file="wkdir/.hg", logEnviron=True)) + 1, # does not exist ExpectShell( workdir="wkdir", command=["hg", "--verbose", "clone", "--noupdate", "http://hg.mozilla.org", "."] ) + 1, Expect("rmdir", dict(dir="wkdir", logEnviron=True)) + 0, ExpectShell( workdir="wkdir", command=["hg", "--verbose", "clone", "--noupdate", "http://hg.mozilla.org", "."] ) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "locate", "set:added()"]) + 1, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "update", "--clean"]) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "parents", "--template", "{node}\\n"]) + ExpectShell.log("stdio", stdout="\n") + ExpectShell.log("stdio", stdout="f6ad368298bd941e934a41f3babc827b2aa95a1d") + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_getDescription_failed(self): # clone of: test_mode_incremental # only difference is to set the getDescription property # this tests when 'git describe' fails; for example, there are no # tags in the repository self.setupStep( git.Git(repourl="http://github.com/buildbot/buildbot.git", mode="incremental", getDescription=True) ) self.expectCommands( ## copied from test_mode_incremental: ExpectShell(workdir="wkdir", command=["git", "--version"]) + 0, Expect("stat", dict(file="wkdir/.git", logEnviron=True)) + 0, ExpectShell( workdir="wkdir", command=["git", "fetch", "-t", "http://github.com/buildbot/buildbot.git", "HEAD"] ) + 0, ExpectShell(workdir="wkdir", command=["git", "reset", "--hard", "FETCH_HEAD", "--"]) + 0, ExpectShell(workdir="wkdir", command=["git", "rev-parse", "HEAD"]) + ExpectShell.log("stdio", stdout="f6ad368298bd941e934a41f3babc827b2aa95a1d") + 0, ## plus this to test describe: ExpectShell(workdir="wkdir", command=["git", "describe", "HEAD"]) + ExpectShell.log("stdio", stdout="") + 128, # error, but it's suppressed ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty("got_revision", "f6ad368298bd941e934a41f3babc827b2aa95a1d", "Git") self.expectNoProperty("commit-description") return self.runStep()
def test_mode_full_clean(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='clean', branchType='inrepo')) self.expectCommands( ExpectLogged('stat', dict(file='wkdir/.hg')) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--config', 'extensions.purge=', 'purge']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) + ExpectShell.log('stdio', stdout='default') + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--id', '--debug']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_branch_change_dirname(self): self.setupStep( mercurial.Mercurial(baseURL='http://hg.mozilla.org/', mode='incremental', branchType='dirname', defaultBranch='devel'), dict(branch='stable') ) self.expectCommands( ExpectLogged('stat', dict(file='wkdir/.hg')) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org/stable', '--update']) + 0, ExpectLogged('rmdir', dict(dir='wkdir')) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org/stable', '.']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--id', '--debug']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_fresh_no_existing_repo(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='fresh', branchType='inrepo')) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 1, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean', '--rev', 'default'], logEnviron=True) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'parents', '--template', '{node}\\n']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) return self.runStep()
def test_maintenance_branch(self): self.buildStep('release-maintenance/flocker-1.2.3/destroy-the-sun-500') self.expectCommands( ExpectShell(workdir='wkdir', command=['git', 'fetch', 'git://twisted', 'release/flocker-1.2.3'], env=self.env) + 0, ExpectShell(workdir='wkdir', command=['git', 'log', '--format=%ci', '-n1'], env=self.env) + ExpectShell.log('stdio', stdout=COMMIT_DATE_NL) + 0, ExpectShell(workdir='wkdir', command=['git', 'merge', '--no-ff', '--no-stat', 'FETCH_HEAD'], env=self.date_env) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'FETCH_HEAD'], env=self.date_env) + ExpectShell.log('stdio', stdout=COMMIT_HASH_NL) + 0, ) self.expectOutcome(result=SUCCESS, status_text=['merge', 'forward']) self.expectProperty('lint_revision', COMMIT_HASH) return self.runStep()
def test_rmdir_fails_purge(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='full', keep_on_purge=['svn_external_path/unversioned_file1'])) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', {'file': 'wkdir/.svn', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache' ]) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'status', '--xml', '--no-ignore', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout=self.svn_st_xml) + 0, Expect('rmdir', {'dir': 'wkdir/svn_external_path/unversioned_file2', 'logEnviron': True}) + 1, ) self.expectOutcome(result=FAILURE, status_text=["updating"]) return self.runStep()
def test_branch_with_merge_target(self): self.buildStep('destroy-the-sun-5000') self.properties.setProperty( 'merge_target', 'merge-hash', source='test') self.expectCommands( ExpectShell(workdir='wkdir', command=['git', 'fetch', 'git://twisted', 'master'], env=self.env) + 0, ExpectShell(workdir='wkdir', command=['git', 'log', '--format=%ci', '-n1'], env=self.env) + ExpectShell.log('stdio', stdout=COMMIT_DATE_NL) + 0, ExpectShell(workdir='wkdir', command=['git', 'merge', '--no-ff', '--no-stat', 'merge-hash'], env=self.date_env) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'merge-hash'], env=self.date_env) + ExpectShell.log('stdio', stdout=COMMIT_HASH_NL) + 0, ) self.expectOutcome(result=SUCCESS, status_text=['merge', 'forward']) self.expectProperty('lint_revision', COMMIT_HASH) return self.runStep()
def test_mode_full_export(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='full', method='export')) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('rmdir', dict(dir='wkdir', logEnviron=True)) + 0, Expect('stat', dict(file='source/.svn', logEnviron=True)) + 0, ExpectShell(workdir='source', command=['svn', 'info', '--non-interactive', '--no-auth-cache' ]) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='source', command=['svn', 'update', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='', command=['svn', 'export', 'source', 'wkdir']) + 0, ExpectShell(workdir='source', command=['svnversion']) + ExpectShell.log('stdio', stdout='100') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_bogus_svnversion(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='incremental',username='******', password='******', extra_args=['--random'])) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache', '--username', 'user', '--password', 'pass', '--random']) + ExpectShell.log('stdio', stdout=textwrap.dedent("""\ Path: /a/b/c URL: http://svn.local/app/trunk""")) + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache', '--username', 'user', '--password', 'pass', '--random']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='1x0y0') + 0, ) self.expectOutcome(result=FAILURE, status_text=["updating"]) return self.runStep()
def test_mode_incremental_baseURL_not_updatable_svninfo_mismatch(self): self.setupStep( svn.SVN(baseURL='http://svn.local/%%BRANCH%%/app', mode='incremental', defaultBranch='trunk')) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', # expecting ../trunk/app stdout="URL: http://svn.local/branch/foo/app") + 0, Expect('rmdir', {'dir': 'wkdir', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'checkout', 'http://svn.local/trunk/app', '.', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_given_revision(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='incremental'), dict( revision='100', )) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', dict(file='wkdir/.svn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--revision', '100', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_no_existing_repo_dirname(self): self.setupStep( mercurial.Mercurial(baseURL='http://hg.mozilla.org', mode='incremental', branchType='dirname'), ) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 1, # does not exist ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'clone', 'http://hg.mozilla.org', '.', '--noupdate']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--id', '--debug']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_clean_patch_fail(self): self.setupStep( mtn.Monotone(repourl="mtn://localhost/monotone", mode="full", method="clean", branch="master"), patch=(1, "patch"), ) self.expectCommands( ExpectShell(workdir="wkdir", command=["mtn", "--version"]) + ExpectShell.log("stdio", stdout="monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)") + 0, ExpectShell(workdir="wkdir", command=["mtn", "db", "info", "--db", "../db.mtn"]) + ExpectShell.log("stdio", stdout="") + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 1, Expect("stat", dict(file="wkdir/_MTN", logEnviron=True)) + 0, Expect("stat", dict(file="db.mtn", logEnviron=True)) + 0, ExpectShell(workdir="wkdir", command=["mtn", "ls", "unknown"]) + ExpectShell.log("stdio", stdout="file1\nfile2") + 0, Expect("rmdir", dict(dir=["wkdir/file1", "wkdir/file2"], logEnviron=True)) + 0, ExpectShell( workdir="wkdir", command=["mtn", "pull", "mtn://localhost/monotone?master", "--db=../db.mtn", "--ticker=dot"], ) + 0, ExpectShell(workdir="wkdir", command=["mtn", "update", "--db=../db.mtn", "-r", "h:master", "-b", "master"]) + 0, Expect( "downloadFile", dict( blocksize=16384, maxsize=None, reader=ExpectRemoteRef(_FileReader), slavedest=".buildbot-diff", workdir="wkdir", mode=None, ), ) + 0, Expect( "downloadFile", dict( blocksize=16384, maxsize=None, reader=ExpectRemoteRef(_FileReader), slavedest=".buildbot-patched", workdir="wkdir", mode=None, ), ) + 0, ExpectShell( workdir="wkdir", command=["patch", "-p1", "--remove-empty-files", "--force", "--forward", "-i", ".buildbot-diff"], ) + 0, Expect("rmdir", dict(dir="wkdir/.buildbot-diff", logEnviron=True)) + 1, ) self.expectOutcome(result=FAILURE, state_string="update (failure)") return self.runStep()
def test_mode_full_clean_new_rmdir(self): self.setupStep(svn.SVN(repourl="http://svn.local/app/trunk", mode="full", method="clean")) self.patch_slaveVersionIsOlderThan(False) self.expectCommands( ExpectShell(workdir="wkdir", command=["svn", "--version"]) + 0, Expect("stat", {"file": "wkdir/.svn", "logEnviron": True}) + 0, ExpectShell(workdir="wkdir", command=["svn", "info", "--non-interactive", "--no-auth-cache"]) + ExpectShell.log("stdio", stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir="wkdir", command=["svn", "status", "--xml", "--non-interactive", "--no-auth-cache"]) + ExpectShell.log("stdio", stdout=self.svn_st_xml) + 0, Expect( "rmdir", { "dir": ["wkdir/svn_external_path/unversioned_file1", "wkdir/svn_external_path/unversioned_file2"], "logEnviron": True, }, ) + 0, ExpectShell(workdir="wkdir", command=["svn", "update", "--non-interactive", "--no-auth-cache"]) + 0, ExpectShell(workdir="wkdir", command=["svn", "info"]) + ExpectShell.log("stdio", stdout=self.svn_info_stdout) + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_branch_change_no_clobberOnBranchChange(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='incremental', branchType='inrepo', clobberOnBranchChange=False), dict( branch='stable', )) self.expectCommands( ExpectLogged('stat', dict(file='wkdir/.hg')) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org', '--update']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) + ExpectShell.log('stdio', stdout='default') + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--id', '--debug']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_branch_change(self): self.setupStep( mercurial.Mercurial(repourl="http://hg.mozilla.org", mode="incremental", branchType="inrepo"), dict(branch="stable"), ) self.expectCommands( ExpectShell(workdir="wkdir", command=["hg", "--verbose", "--version"]) + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 1, Expect("stat", dict(file="wkdir/.hg", logEnviron=True)) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "pull", "http://hg.mozilla.org"]) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "identify", "--branch"]) + ExpectShell.log("stdio", stdout="default") + 0, Expect("rmdir", dict(dir="wkdir", logEnviron=True)) + 0, ExpectShell( workdir="wkdir", command=["hg", "--verbose", "clone", "--noupdate", "http://hg.mozilla.org", "."] ) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "update", "--clean", "--rev", "stable"]) + 0, ExpectShell(workdir="wkdir", command=["hg", "--verbose", "parents", "--template", "{node}\\n"]) + ExpectShell.log("stdio", stdout="\n") + ExpectShell.log("stdio", stdout="f6ad368298bd941e934a41f3babc827b2aa95a1d") + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_clean_no_existing_repo(self): self.setupStep(mtn.Monotone(repourl="mtn://localhost/monotone", mode="full", method="clean", branch="master")) self.expectCommands( ExpectShell(workdir="wkdir", command=["mtn", "--version"]) + ExpectShell.log("stdio", stdout="monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)") + 0, ExpectShell(workdir="wkdir", command=["mtn", "db", "info", "--db", "../db.mtn"]) + ExpectShell.log("stdio", stdout="") + 0, Expect("stat", dict(file="wkdir/.buildbot-patched", logEnviron=True)) + 1, Expect("stat", dict(file="wkdir/_MTN", logEnviron=True)) + 1, ExpectShell(workdir="wkdir", command=["mtn", "db", "init", "--db", "../db.mtn"]) + 0, ExpectShell( workdir="wkdir", command=["mtn", "pull", "mtn://localhost/monotone?master", "--db=../db.mtn", "--ticker=dot"], ) + 0, ExpectShell(workdir="wkdir", command=["mtn", "checkout", ".", "--db=../db.mtn", "--branch", "master"]) + 0, ExpectShell(workdir="wkdir", command=["mtn", "automate", "select", "w:"]) + ExpectShell.log("stdio", stdout="95215e2a9a9f8b6f5c9664e3807cd34617ea928c") + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty("got_revision", "95215e2a9a9f8b6f5c9664e3807cd34617ea928c", "Monotone") return self.runStep()
def test_mode_full_clean_no_existing_repo(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='clean', branchType='inrepo')) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 1, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'clone', 'http://hg.mozilla.org', '.']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--id', '--debug']) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_clean(self): self.setupStep( svn.SVN(svnurl='http://svn.local/app/trunk@HEAD', mode='full', method='clean')) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, ExpectLogged('stat', {'file': 'wkdir/.svn', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'status', '--xml', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout=self.svn_st_xml_empty) + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100\n') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_clean(self): self.setupStep( gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='clean')) self.build.setProperty("event.patchSet.ref", "gerrit_branch") self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + ExpectShell.log('stdio', stdout='git version 1.7.5') + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('listdir', { 'dir': 'wkdir', 'logEnviron': True, 'timeout': 1200 }) + Expect.update('files', ['.git']) + 0, ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']) + 0, ExpectShell( workdir='wkdir', command=[ 'git', 'fetch', '-t', 'http://github.com/buildbot/buildbot.git', 'gerrit_branch' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD', '--' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'checkout', '-B', 'gerrit_branch']) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log( 'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Gerrit') return self.runStep()
def test_database_empty(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master')) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log('stdio', stdout=self.MTN_VER) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) + ExpectShell.log('stdio', stdout='database has no tables') + 0, Expect('rmdir', dict(dir='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'db', 'init', '--db', 'db.mtn']) + 0, ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=[ 'mtn', 'update', '--revision', 'h:master', '--branch', 'master' ]) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log('stdio', stdout=self.REVID) + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', self.REVID, 'Monotone') return self.runStep()
def test_mode_incremental(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master')) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log( 'stdio', stdout= 'monotone 1.0 (base revision: a7c3a1d9de1ba7a62c9dd9efee17252234bb502c)' ) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'db', 'info', '--db', '../db.mtn']) + ExpectShell.log('stdio', stdout='') + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db=../db.mtn', '--ticker=dot' ]) + 0, ExpectShell(workdir='wkdir', command=[ 'mtn', 'update', '--db=../db.mtn', '-r', 'h:master', '-b', 'master' ]) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log( 'stdio', stdout='95215e2a9a9f8b6f5c9664e3807cd34617ea928c') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty('got_revision', '95215e2a9a9f8b6f5c9664e3807cd34617ea928c', 'Monotone') return self.runStep()
def test_mode_full_fresh_keep_on_purge(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='full', keep_on_purge=['svn_external_path/unversioned_file1'])) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', {'file': 'wkdir/.svn', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache' ]) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'status', '--xml', '--no-ignore', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout=self.svn_st_xml) + 0, Expect('rmdir', {'dir': 'wkdir/svn_external_path/unversioned_file2', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100\n') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_copy(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='copy', branch='master')) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log('stdio', stdout=self.MTN_VER) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) + ExpectShell.log('stdio', stdout='') + 0, ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]) + 0, Expect('rmdir', dict(dir='wkdir', logEnviron=True, timeout=1200)) + 0, Expect('stat', dict(file='source/_MTN', logEnviron=True)) + 0, ExpectShell(workdir='source', command=[ 'mtn', 'update', '--revision', 'h:master', '--branch', 'master' ]) + 0, Expect( 'cpdir', { 'fromdir': 'source', 'todir': 'build', 'logEnviron': True, 'timeout': 1200 }) + 0, ExpectShell(workdir='build', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log('stdio', stdout=self.REVID) + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', self.REVID, 'Monotone') return self.runStep()
def _full(self, client_stdin='', p4client='p4_client1', p4user='******', workdir='wkdir', extra_args=None, obfuscated_pass=True): if extra_args is None: extra_args = [] if obfuscated_pass: expected_pass = ('obfuscated', 'pass', 'XXXXXX') else: expected_pass = '******' self.expectCommands( ExpectShell(workdir=workdir, command=['p4', '-V' ]) # expected remote command + 0, # expected exit status ExpectShell(workdir=workdir, command=[ 'p4', '-p', 'localhost:12000', '-u', p4user, '-P', expected_pass, '-c', p4client, 'client', '-i' ], initialStdin=client_stdin) + 0, ExpectShell(workdir=workdir, command=[ 'p4', '-p', 'localhost:12000', '-u', p4user, '-P', expected_pass, '-c', p4client ] + extra_args + ['sync', '#none']) + 0, Expect('rmdir', { 'dir': workdir, 'logEnviron': True }) + 0, ExpectShell(workdir=workdir, command=[ 'p4', '-p', 'localhost:12000', '-u', p4user, '-P', expected_pass, '-c', p4client ] + extra_args + ['sync']) + 0, ExpectShell( workdir=workdir, command=[ 'p4', '-p', 'localhost:12000', '-u', p4user, '-P', expected_pass, '-c', p4client, 'changes', '-m1', '#have' ]) + ExpectShell.log( 'stdio', stdout="Change 100 on 2013/03/21 by user@machine \'duh\'") + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', '100', 'P4') return self.runStep()
def test_with_merge_branch(self): self.setupStep( self.stepClass( repourl='[email protected]:mmusterman/awesome_project.git', mode='full', method='clean'), dict(branch='master', revision='12345678')) self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + ExpectShell.log('stdio', stdout='git version 1.7.5') + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('listdir', { 'dir': 'wkdir', 'logEnviron': True, 'timeout': 1200 }) + Expect.update('files', ['.git']) + 0, ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']) + 0, # here we always ignore revision, and fetch the merge branch ExpectShell(workdir='wkdir', command=[ 'git', 'fetch', '-t', '[email protected]:build/awesome_project.git', 'ms-viewport' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD', '--' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'checkout', '-B', 'ms-viewport']) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log( 'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'GitLab') return self.runStep()
def test_buildonly(self): self.setupStep(pbuilder.DebCowbuilder()) self.expectCommands( Expect('stat', {'file': '/var/cache/pbuilder/stable-local-buildbot.cow/'}) + Expect.update( 'stat', [stat.S_IFDIR, 99, 99, 1, 0, 0, 99, 0, int(time.time()), 0]) + 0, ExpectShell(workdir='wkdir', usePTY='slave-config', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/cowbuilder', '--', '--buildresult', '.', '--basepath', '/var/cache/pbuilder/stable-local-buildbot.cow/' ]) + 0) self.expectOutcome(result=SUCCESS, status_text=['pdebuild']) return self.runStep()
def test_args_x64(self): self.setupStep( vstudio.VC8(projectfile='pf', config='cfg', project='pj', arch='x64')) self.expectCommands( ExpectShell( workdir='wkdir', usePTY='slave-config', command=[ 'devenv.com', 'pf', '/Rebuild', 'cfg', '/Project', 'pj' ], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio 8', x64=True)) + 0) self.expectOutcome(result=SUCCESS, status_text=["compile", "0 projects", "0 files"]) return self.runStep()
def test_rendering(self): self.setupStep(vstudio.VC8(projectfile='pf', config='cfg', arch=Property('a'))) self.properties.setProperty('a', 'x64', 'Test') self.expectCommands( ExpectShell(workdir='wkdir', usePTY='slave-config', command=['devenv.com', 'pf', '/Rebuild', 'cfg'], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio 8', x64=True)) # property has expected effect + 0 ) self.expectOutcome(result=SUCCESS, status_text=["compile", "0 projects", "0 files"]) d = self.runStep() def check_props(_): self.assertEqual(self.step.arch, 'x64') d.addCallback(check_props) return d
def test_mode_build_env(self): self.setupStep( vstudio.VCExpress9(projectfile='pf', config='cfg', project='pj', mode='build', INCLUDE=['i'])) self.expectCommands( ExpectShell(workdir='wkdir', command=[ 'vcexpress', 'pf', '/Build', 'cfg', '/UseEnv', '/Project', 'pj' ], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio 8', i='i')) + 0) self.expectOutcome(result=SUCCESS, state_string="compile 0 projects 0 files") return self.runStep()
def test_clean(self): self.setupStep( vstudio.VC7(projectfile='pf', config='cfg', project='pj', mode='clean')) self.expectCommands( ExpectShell( workdir='wkdir', usePTY='slave-config', command=[ 'devenv.com', 'pf', '/Clean', 'cfg', '/Project', 'pj' ], env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio .NET 2003')) + 0) self.expectOutcome(result=SUCCESS, status_text=["compile", "0 projects", "0 files"]) return self.runStep()
def test_mode_incremental_retry(self): self.setupStep( mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='incremental', branchType='dirname', retry=(0, 1)), ) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 1, # does not exist ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.' ]) + 1, Expect('rmdir', dict(dir='wkdir', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'clone', '--noupdate', 'http://hg.mozilla.org', '.' ]) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'locate', 'set:added()']) + 1, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'update', '--clean']) + 0, ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'parents', '--template', '{node}\\n' ]) + ExpectShell.log('stdio', stdout='\n') + ExpectShell.log( 'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) return self.runStep()
def test_buildonly_reg(self): self.setupStep( pbuilder.DebCowbuilder( basetgz='/var/cache/pbuilder/stable-local-buildbot.cow')) self.expectCommands( Expect('stat', {'file': '/var/cache/pbuilder/stable-local-buildbot.cow'}) + Expect.update( 'stat', [stat.S_IFREG, 99, 99, 1, 0, 0, 99, 0, int(time.time()), 0]) + 0, ExpectShell(workdir='wkdir', command=[ 'pdebuild', '--buildresult', '.', '--pbuilder', '/usr/sbin/cowbuilder', '--', '--buildresult', '.', '--basepath', '/var/cache/pbuilder/stable-local-buildbot.cow' ]) + 1) self.expectOutcome(result=FAILURE, state_string='built (failure)') return self.runStep()
def test_mode_full_clean_patch_worker_2_16(self): self.setupStep( bzr.Bzr(repourl='http://bzr.squid-cache.org/bzr/squid3/trunk', mode='full', method='clean'), patch=(1, 'patch'), worker_version={'*': '2.16'}) self.expectCommands( ExpectShell(workdir='wkdir', command=['bzr', '--version']) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/.bzr', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['bzr', 'clean-tree', '--ignored', '--force']) + 0, ExpectShell(workdir='wkdir', command=['bzr', 'update']) + 0, Expect('downloadFile', dict(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.FileReader), slavedest='.buildbot-diff', workdir='wkdir', mode=None)) + 0, Expect('downloadFile', dict(blocksize=32768, maxsize=None, reader=ExpectRemoteRef( remotetransfer.FileReader), slavedest='.buildbot-patched', workdir='wkdir', mode=None)) + 0, ExpectShell(workdir='wkdir', command=['patch', '-p1', '--remove-empty-files', '--force', '--forward', '-i', '.buildbot-diff']) + 0, Expect('rmdir', dict(dir='wkdir/.buildbot-diff', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['bzr', 'version-info', '--custom', "--template='{revno}"]) + ExpectShell.log('stdio', stdout='100') + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', '100', 'Bzr') return self.runStep()
def test_mode_incremental_retryFetch_branch(self): self.setupStep( git.Git(repourl='http://github.com/buildbot/buildbot.git', mode='incremental', retryFetch=True, branch='test-branch')) self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + 0, Expect('stat', dict(file='wkdir/.git', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['git', 'fetch', '-t', 'http://github.com/buildbot/buildbot.git', 'test-branch']) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD']) + 1, ExpectShell(workdir='wkdir', command=['git', 'fetch', '-t', 'http://github.com/buildbot/buildbot.git', 'test-branch']) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD']) + 0, ExpectShell(workdir='wkdir', command=['git', 'branch', '-M', 'test-branch']) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_success(self): self.setupStep(mock.MockRebuild(root='TESTROOT', srpm="foo.src.rpm")) self.expectCommands( Expect('rmdir', { 'dir': ['build/build.log', 'build/root.log', 'build/state.log'] }) + 0, ExpectShell( workdir='wkdir', command=[ 'mock', '--root', 'TESTROOT', '--rebuild', 'foo.src.rpm' ], logfiles={ 'build.log': 'build.log', 'root.log': 'root.log', 'state.log': 'state.log' }, ) + 0) self.expectOutcome(result=SUCCESS, state_string='mock rebuild srpm') return self.runStep()
def test_mode_full_clean_patch_fail(self): self.setupStep(mercurial.Mercurial(repourl='http://hg.mozilla.org', mode='full', method='clean', branchType='inrepo'), patch=(1, 'patch')) self.expectCommands( ExpectShell(workdir='wkdir', command=['hg', '--verbose', '--version']) + 0, Expect('stat', dict(file='wkdir/.hg', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', '--config', 'extensions.purge=', 'purge' ]) + 0, ExpectShell( workdir='wkdir', command=['hg', '--verbose', 'pull', 'http://hg.mozilla.org']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) + ExpectShell.log('stdio', stdout='default') + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'locate', 'set:added()']) + 1, ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'update', '--clean', '--rev', 'default' ]) + 0, ExpectShell(workdir='wkdir', command=[ 'hg', '--verbose', 'import', '--no-commit', '-p', '1', '-' ], initialStdin='patch') + 1, ) self.expectOutcome(result=FAILURE, status_text=["updating"]) return self.runStep()
def test_error(self): stream = io.BytesIO() client = TestProtocolClient(stream) test = FakeTest(id='test1') client.startTest(test) client.addError(test, create_error('error1')) client.stopTest(test) self.setupStep(subunit.SubunitShellCommand(command='test')) self.expectCommands( ExpectShell(workdir='wkdir', command="test") + Expect.log('stdio', stdout=stream.getvalue()) + 0) self.expectOutcome( result=FAILURE, state_string="shell Total 1 test(s) 1 error (failure)") self.expectLogfile('problems', re.compile(r'''test1 testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error1' .*''', re.MULTILINE | re.DOTALL)) # noqa pylint: disable=line-too-long return self.runStep()
def test_with_head_branch(self): self.setupStep( self.stepClass(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='clean'), dict(branch='refs/pull/1234/head', revision='12345678')) self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + ExpectShell.log('stdio', stdout='git version 1.7.5') + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('listdir', { 'dir': 'wkdir', 'logEnviron': True, 'timeout': 1200 }) + Expect.update('files', ['.git']) + 0, ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']) + 0, # in the case of the head, we try to find if the head is already present # and reset to that without fetching ExpectShell(workdir='wkdir', command=['git', 'cat-file', '-e', '12345678']) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', '12345678', '--']) + 0, ExpectShell(workdir='wkdir', command=['git', 'branch', '-M', 'refs/pull/1234/head' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log( 'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'GitHub') return self.runStep()
def _run_simple_test(self, source, destination, expected_args=None, expected_code=0, expected_res=SUCCESS, **kwargs): s = mswin.Robocopy(source, destination, **kwargs) self.setupStep(s) s.rendered = True command = ['robocopy', source, destination] if expected_args: command += expected_args command += ['/TEE', '/NP'] self.expectCommands( ExpectShell( workdir='wkdir', command=command, ) + expected_code ) state_string = "'robocopy %s ...'" % source if expected_res != SUCCESS: state_string += ' (%s)' % (Results[expected_res]) self.expectOutcome(result=expected_res, state_string=state_string) return self.runStep()
def test_mode_full_clean_force_build(self): self.setupStep( gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='clean')) self.build.setProperty("gerrit_change", "1234/567") self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + ExpectShell.log('stdio', stdout='git version 1.7.5') + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/.git', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-f', '-d']) + 0, ExpectShell(workdir='wkdir', command=[ 'git', 'fetch', '-t', 'http://github.com/buildbot/buildbot.git', 'refs/changes/34/1234/567' ]) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD', '--' ]) + 0, ExpectShell( workdir='wkdir', command=['git', 'branch', '-M', 'refs/changes/34/1234/567']) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log( 'stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Gerrit') return self.runStep()
def test_build_project(self): self.setupStep( vstudio.MsBuild(projectfile='pf', config='cfg', platform='Win32', project='pj')) self.expectCommands( ExpectShell( workdir='wkdir', usePTY='slave-config', command=[ '%VCENV_BAT%', 'x86', '&&', 'msbuild', 'pf', '/p:Configuration=cfg', '/p:Platform=Win32', '/t:pj' ], env={ 'VCENV_BAT': '"${VS110COMNTOOLS}..\\..\\VC\\vcvarsall.bat"' }) + 0) self.expectOutcome(result=SUCCESS, state_string="built pj for cfg|Win32") return self.runStep()
def test_rendering(self): self.setupStep( VCx(projectfile=Property('a'), config=Property('b'), project=Property('c'))) self.properties.setProperty('a', 'aa', 'Test') self.properties.setProperty('b', 'bb', 'Test') self.properties.setProperty('c', 'cc', 'Test') self.expectCommands( ExpectShell(workdir='wkdir', command=['command', 'here']) + 0) self.expectOutcome(result=SUCCESS, state_string="compile 0 projects 0 files") d = self.runStep() def check_props(_): self.assertEqual( [self.step.projectfile, self.step.config, self.step.project], ['aa', 'bb', 'cc']) d.addCallback(check_props) return d
def test_mode_full_fresh_submodule(self): self.setupStep( git.Git(repourl='http://github.com/buildbot/buildbot.git', mode='full', method='fresh', submodules=True)) self.expectCommands( ExpectShell(workdir='wkdir', command=['git', '--version']) + 0, Expect('stat', dict(file='wkdir/.git', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=['git', 'clean', '-f', '-d', '-x']) + 0, ExpectShell(workdir='wkdir', command=['git', 'fetch', '-t', 'http://github.com/buildbot/buildbot.git', 'HEAD']) + 0, ExpectShell(workdir='wkdir', command=['git', 'reset', '--hard', 'FETCH_HEAD']) + 0, ExpectShell(workdir='wkdir', command=['git', 'submodule', 'update', '--recursive']) + 0, ExpectShell(workdir='wkdir', command=['git', 'submodule', 'foreach', 'git', 'clean', '-f', '-d', '-x']) + 0, ExpectShell(workdir='wkdir', command=['git', 'rev-parse', 'HEAD']) + ExpectShell.log('stdio', stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_full_clean_given_revision(self): self.setupStep( svn.SVN(repourl='http://svn.local/app/trunk', mode='full', method='clean'),dict( revision='100', )) self.expectCommands( ExpectShell(workdir='wkdir', command=['svn', '--version']) + 0, Expect('stat', {'file': 'wkdir/.svn', 'logEnviron': True}) + 0, ExpectShell(workdir='wkdir', command=['svn', 'info', '--non-interactive', '--no-auth-cache' ]) + ExpectShell.log('stdio', stdout="URL: http://svn.local/app/trunk") + 0, ExpectShell(workdir='wkdir', command=['svn', 'status', '--xml', '--non-interactive', '--no-auth-cache']) + ExpectShell.log('stdio', stdout=self.svn_st_xml_empty) + 0, ExpectShell(workdir='wkdir', command=['svn', 'update', '--revision', '100', '--non-interactive', '--no-auth-cache']) + 0, ExpectShell(workdir='wkdir', command=['svnversion']) + ExpectShell.log('stdio', stdout='100\n') + 0, ) self.expectOutcome(result=SUCCESS, status_text=["update"]) return self.runStep()
def test_mode_incremental_given_revision(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='incremental', branch='master'), dict(revision='abcdef01', )) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log('stdio', stdout=self.MTN_VER) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) + ExpectShell.log('stdio', stdout='') + 0, ExpectShell(workdir='.', command=[ 'mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot' ]) + 0, Expect('stat', dict(file='wkdir/.buildbot-patched', logEnviron=True)) + 1, Expect('stat', dict(file='wkdir/_MTN', logEnviron=True)) + 0, ExpectShell(workdir='wkdir', command=[ 'mtn', 'update', '--revision', 'abcdef01', '--branch', 'master' ]) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log( 'stdio', stdout='abcdef019a9f8b6f5c9664e3807cd34617ea928c') + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', 'abcdef019a9f8b6f5c9664e3807cd34617ea928c', 'Monotone') return self.runStep()
def test_mode_full_clobber(self): self.setupStep( mtn.Monotone(repourl='mtn://localhost/monotone', mode='full', method='clobber', branch='master')) self.expectCommands( ExpectShell(workdir='wkdir', command=['mtn', '--version']) + ExpectShell.log('stdio', stdout=self.MTN_VER) + 0, Expect('stat', dict(file='db.mtn', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'db', 'info', '--db', 'db.mtn']) + ExpectShell.log('stdio', stdout='') + 0, ExpectShell(workdir='.', command=['mtn', 'pull', 'mtn://localhost/monotone?master', '--db', 'db.mtn', '--ticker=dot']) + 0, Expect('rmdir', dict(dir='wkdir', logEnviron=True)) + 0, ExpectShell(workdir='.', command=['mtn', 'checkout', 'wkdir', '--db', 'db.mtn', '--branch', 'master']) + 0, ExpectShell(workdir='wkdir', command=['mtn', 'automate', 'select', 'w:']) + ExpectShell.log('stdio', stdout=self.REVID) + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty('got_revision', self.REVID, 'Monotone') return self.runStep()
def test_resultdir_success(self): self.setupStep(mock.Mock(root='TESTROOT', resultdir='RESULT')) self.expectCommands( Expect( 'rmdir', { 'dir': [ 'build/RESULT/build.log', 'build/RESULT/root.log', 'build/RESULT/state.log' ] }) + 0, ExpectShell(workdir='wkdir', command=[ 'mock', '--root', 'TESTROOT', '--resultdir', 'RESULT' ], logfiles={ 'build.log': 'RESULT/build.log', 'root.log': 'RESULT/root.log', 'state.log': 'RESULT/state.log' }) + 0) self.expectOutcome(result=SUCCESS) return self.runStep()
def test_env_prepend(self): self.setupStep( vstudio.VC6(projectfile='pf', config='cfg', project='pj', PATH=['p'], INCLUDE=['i'], LIB=['l'])) self.expectCommands( ExpectShell( workdir='wkdir', command=[ 'msdev', 'pf', '/MAKE', 'pj - cfg', '/REBUILD', '/USEENV' ], # note extra param env=self.getExpectedEnv( r'C:\Program Files\Microsoft Visual Studio', l='l', p='p', i='i')) + 0) self.expectOutcome(result=SUCCESS, state_string="compile 0 projects 0 files") return self.runStep()