Error on downloading a 64-bit package on a non-64-bit OS (#265)
Also fix the can_be_installed which was always broken it seems - it returns True for success or a string for error, but didn't check if the output is True. Includes a test, which hacks up emsdk to make it think it's on 32-bit, and verifies the error and message.
This commit is contained in:
20
test.py
20
test.py
@@ -1,11 +1,26 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Utilities
|
||||
|
||||
def check_call(cmd):
|
||||
subprocess.check_call(cmd.split(' '))
|
||||
|
||||
def failing_call_with_output(cmd, expected):
|
||||
proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
assert proc.returncode, 'call must have failed'
|
||||
assert expected in stdout, 'call did not have the right output'
|
||||
|
||||
def hack_emsdk(marker, replacement):
|
||||
src = open('emsdk').read()
|
||||
assert marker in src
|
||||
src = src.replace(marker, replacement)
|
||||
name = '__test_emsdk'
|
||||
open(name, 'w').write(src)
|
||||
return name
|
||||
|
||||
# Set up
|
||||
|
||||
open('hello_world.cpp', 'w').write('int main() {}')
|
||||
@@ -57,3 +72,8 @@ check_call('./emsdk activate sdk-tag-1.38.33-64bit')
|
||||
|
||||
print('test binaryen source build')
|
||||
check_call('./emsdk install --build=Release binaryen-master-64bit')
|
||||
|
||||
print('test 32-bit error')
|
||||
|
||||
failing_call_with_output('python %s install latest' % hack_emsdk('not is_os_64bit()', 'True'), 'this tool is only provided for 64-bit OSes')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user