mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-12 09:17:53 +00:00
The WIN32 CreateProcess() function does not require an .exe or .com suffix in order to spawn an executable. Now that we have Cosmo bash we're no longer so dependent on the cmd.exe prompt.
22 lines
606 B
Python
22 lines
606 B
Python
import os
|
|
import shutil
|
|
import tempfile
|
|
import unittest
|
|
import subprocess
|
|
|
|
|
|
class SubprocessTest(unittest.TestCase):
|
|
def test_execve(self):
|
|
tmp_dir = tempfile.mkdtemp()
|
|
self.addCleanup(shutil.rmtree, tmp_dir)
|
|
exe = os.path.join(tmp_dir, 'hello')
|
|
shutil.copyfile('/zip/.python/test/hello', exe)
|
|
os.chmod(exe, 0755)
|
|
proc = subprocess.Popen([exe], stdout=subprocess.PIPE)
|
|
stdout, stderr = proc.communicate()
|
|
self.assertEqual(b'hello world\n', stdout)
|
|
self.assertEqual(0, proc.wait())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|