1 #!/usr/bin/env python2.5
2 # Copyright (C) 2007, Thomas Leonard
3 # See the README file for details, or visit http://0install.net.
4 import sys
, os
, shutil
, tempfile
, subprocess
7 sys
.path
.insert(0, '..')
11 mydir
= os
.path
.realpath(os
.path
.dirname(__file__
))
12 release_feed
= mydir
+ '/../0release.xml'
13 test_repo
= mydir
+ '/test-repo.tgz'
14 test_repo_actions
= mydir
+ '/test-repo-actions.tgz'
15 test_gpg
= mydir
+ '/gpg.tgz'
17 def make_releases_dir():
19 support
.check_call(['0launch', release_feed
, '../hello/HelloWorld.xml'])
20 assert os
.path
.isfile('make-release')
22 lines
= file('make-release').readlines()
23 lines
[lines
.index('ARCHIVE_DIR_PUBLIC_URL=\n')] = 'ARCHIVE_DIR_PUBLIC_URL=http://TESTING/releases\n'
24 s
= file('make-release', 'w')
25 s
.write(''.join(lines
))
28 class TestRelease(unittest
.TestCase
):
30 self
.tmp
= tempfile
.mkdtemp(prefix
= '0release-')
32 support
.check_call(['tar', 'xzf', test_gpg
])
34 os
.environ
['GNUPGHOME'] = self
.tmp
+ '/gpg'
35 os
.chmod(os
.environ
['GNUPGHOME'], 0700)
39 shutil
.rmtree(self
.tmp
)
42 support
.check_call(['tar', 'xzf', test_repo
])
45 child
= subprocess
.Popen(['./make-release', '-k', 'Testing'], stdin
= subprocess
.PIPE
)
46 unused
, unused
= child
.communicate('\nP\n\n')
47 assert child
.returncode
== 0
49 child
= subprocess
.Popen(['./make-release', '-k', 'Testing'], stdin
= subprocess
.PIPE
)
50 unused
, unused
= child
.communicate('\nP\n\n')
51 assert child
.returncode
== 0
53 assert 'Prints "Hello World"' in file('0.1/changelog-0.1').read()
54 assert 'Prints "Hello World"' not in file('0.2/changelog-0.2').read()
56 def testUncommitted(self
):
57 support
.check_call(['tar', 'xzf', test_repo_actions
])
60 child
= subprocess
.Popen(['./make-release', '-k', 'Testing'], stdin
= subprocess
.PIPE
, stderr
= subprocess
.PIPE
)
61 unused
, stderr
= child
.communicate()
62 assert child
.returncode
!= 0
63 assert "Uncommitted changes!" in stderr
65 def testActions(self
):
66 support
.check_call(['tar', 'xzf', test_repo_actions
])
68 support
.check_call(['git', 'commit', '-a', '-m', 'Added release instructions'])
72 assert "version = '0.2'\n" not in file('../hello/hello.py').read()
74 child
= subprocess
.Popen(['./make-release', '-k', 'Testing'], stdin
= subprocess
.PIPE
)
75 unused
, unused
= child
.communicate('\nP\n\n')
76 assert child
.returncode
== 0
78 assert "version = '0.2'\n" in file('../hello/hello.py').read()
80 suite
= unittest
.makeSuite(TestRelease
)
81 if __name__
== '__main__':