Fixed --arch
[0export.git] / test.py
blobee779cd4abe0e6b2f25a6b6e38bb315093f4d4d0
1 #!/usr/bin/env python
2 import sys, tempfile, os, subprocess
3 import unittest
5 zeroinstall_dir = os.environ.get('0EXPORT_ZEROINSTALL', None)
6 if zeroinstall_dir:
7 sys.path.insert(1, zeroinstall_dir)
9 from zeroinstall.support import ro_rmtree
11 my_dir = os.path.dirname(os.path.abspath(__file__))
13 export_bin = os.path.join(my_dir, '0export')
15 PUBLISH_URI = 'http://0install.net/2006/interfaces/0publish'
17 class TestExport(unittest.TestCase):
18 def setUp(self):
19 os.chdir('/')
20 self.tmpdir = tempfile.mkdtemp(prefix = '0export-test-')
22 # tmpdir is used as $HOME when running the bundle...
23 config_dir = os.path.join(self.tmpdir, '.config', '0install.net', 'injector')
24 os.makedirs(config_dir)
25 stream = open(os.path.join(config_dir, 'global'), 'w')
26 stream.write('[global]\n'
27 'freshness = -1\n'
28 'help_with_testing = False\n'
29 'network_use = off-line\n')
30 stream.close()
32 def tearDown(self):
33 ro_rmtree(self.tmpdir)
35 def testSimple(self):
36 setup_sh = os.path.join(self.tmpdir, 'setup.sh')
37 subprocess.check_call([sys.executable, export_bin, setup_sh, PUBLISH_URI])
39 env = {
40 'HOME': self.tmpdir,
41 'http_proxy' : 'localhost:1111', # Detect accidental network access
42 'PATH': '/bin:/usr/bin:' + os.path.dirname(sys.executable),
43 #'LANG': 'en_GB.utf-8', # Hack for 0install < 2.2 on ArchLinux
46 child = subprocess.Popen([setup_sh, '--help'], env = env, stdout = subprocess.PIPE)
47 cout, unused = child.communicate()
48 assert child.wait() == 0
49 assert 'Run self-extracting installer' in cout
51 child = subprocess.Popen([setup_sh, '--', '--help'], env = env, stdout = subprocess.PIPE)
52 cout, unused = child.communicate()
53 assert child.wait() == 0, cout
54 assert '--xmlsign' in cout, cout
56 suite = unittest.makeSuite(TestExport)
57 if __name__ == '__main__':
58 unittest.main()