2 import sys
, tempfile
, os
, subprocess
5 zeroinstall_dir
= os
.environ
.get('0EXPORT_ZEROINSTALL', None)
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 TestCompile(unittest
.TestCase
):
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'
28 'help_with_testing = False\n'
29 'network_use = off-line\n')
33 ro_rmtree(self
.tmpdir
)
36 setup_sh
= os
.path
.join(self
.tmpdir
, 'setup.sh')
38 subprocess
.check_call([export_bin
, setup_sh
, PUBLISH_URI
])
42 'http_proxy' : 'localhost:1111' # Detect accidental network access
45 child
= subprocess
.Popen([setup_sh
, '--help'], env
= env
, stdout
= subprocess
.PIPE
)
46 cout
, unused
= child
.communicate()
47 assert child
.wait() == 0
48 assert 'Run self-extracting installer' in cout
50 child
= subprocess
.Popen([setup_sh
, '--', '--help'], env
= env
, stdout
= subprocess
.PIPE
)
51 cout
, unused
= child
.communicate()
52 assert child
.wait() == 0
53 assert '--xmlsign' in cout
55 suite
= unittest
.makeSuite(TestCompile
)
56 if __name__
== '__main__':