aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-09-03 16:35:31 +0300
committerJukka Jylänki <jujjyl@gmail.com>2013-09-04 10:42:07 +0300
commitaeb5e85518e6fa3ee5e3e692fc9915d36cfb65f9 (patch)
tree5060e32632d4210557677a4a169c0691c1255cfa
parente07788b030cc6d3621a450c12944b7ffa78acd41 (diff)
Have test_cmake also test that running 'emconfigure cmake' works, in addition to running cmake directly.
-rw-r--r--tests/test_other.py84
1 files changed, 45 insertions, 39 deletions
diff --git a/tests/test_other.py b/tests/test_other.py
index c3efb051..0fc24ea7 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -282,53 +282,59 @@ f.close()
if os.name == 'nt':
make_command = 'mingw32-make'
generator = 'MinGW Makefiles'
+ emconfigure = path_from_root('emconfigure.bat')
else:
make_command = 'make'
generator = 'Unix Makefiles'
+ emconfigure = path_from_root('emconfigure')
cmake_cases = ['target_js', 'target_html']
cmake_outputs = ['hello_world.js', 'hello_world_gles.html']
for i in range(0, 2):
for configuration in ['Debug', 'Release']:
-
- # Create a temp workspace folder
- cmakelistsdir = path_from_root('tests', 'cmake', cmake_cases[i])
- tempdirname = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=TEMP_DIR)
- try:
- os.chdir(tempdirname)
-
- verbose = os.getenv('EM_BUILD_VERBOSE') != None and int(os.getenv('EM_BUILD_VERBOSE')) != 0
- # Run Cmake
- cmd = ['cmake', '-DCMAKE_TOOLCHAIN_FILE='+path_from_root('cmake', 'Platform', 'Emscripten.cmake'),
- '-DCMAKE_BUILD_TYPE=' + configuration,
- '-G', generator, cmakelistsdir]
- ret = Popen(cmd, stdout=None if verbose else PIPE, stderr=None if verbose else PIPE).communicate()
- if len(ret) > 1 and ret[1] != None and len(ret[1].strip()) > 0:
- print >> sys.stderr, ret[1] # If there were any errors, print them directly to console for diagnostics.
- if len(ret) > 1 and ret[1] != None and 'error' in ret[1].lower():
- print >> sys.stderr, 'Failed command: ' + ' '.join(cmd)
- print >> sys.stderr, 'Result:\n' + ret[1]
- raise Exception('cmake call failed!')
- assert os.path.exists(tempdirname + '/Makefile'), 'CMake call did not produce a Makefile!'
-
- # Build
- cmd = [make_command] + (['VERBOSE=1'] if verbose else [])
- ret = Popen(cmd, stdout=None if verbose else PIPE).communicate()
- if len(ret) > 1 and ret[1] != None and len(ret[1].strip()) > 0:
- print >> sys.stderr, ret[1] # If there were any errors, print them directly to console for diagnostics.
- if len(ret) > 0 and ret[0] != None and 'error' in ret[0].lower() and not '0 error(s)' in ret[0].lower():
- print >> sys.stderr, 'Failed command: ' + ' '.join(cmd)
- print >> sys.stderr, 'Result:\n' + ret[0]
- raise Exception('make failed!')
- assert os.path.exists(tempdirname + '/' + cmake_outputs[i]), 'Building a cmake-generated Makefile failed to produce an output file %s!' % tempdirname + '/' + cmake_outputs[i]
-
- # Run through node, if CMake produced a .js file.
- if cmake_outputs[i].endswith('.js'):
- ret = Popen(listify(NODE_JS) + [tempdirname + '/' + cmake_outputs[i]], stdout=PIPE).communicate()[0]
- assert 'hello, world!' in ret, 'Running cmake-based .js application failed!'
- finally:
- os.chdir(path_from_root('tests')) # Move away from the directory we are about to remove.
- shutil.rmtree(tempdirname)
+ for invoke_method in ['cmake', 'emconfigure']:
+
+ # Create a temp workspace folder
+ cmakelistsdir = path_from_root('tests', 'cmake', cmake_cases[i])
+ tempdirname = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=TEMP_DIR)
+ try:
+ os.chdir(tempdirname)
+
+ verbose = os.getenv('EM_BUILD_VERBOSE') != None and int(os.getenv('EM_BUILD_VERBOSE')) != 0
+ # Run Cmake
+ if invoke_method == 'cmake':
+ cmd = ['cmake', '-DCMAKE_TOOLCHAIN_FILE='+path_from_root('cmake', 'Platform', 'Emscripten.cmake'),
+ '-DCMAKE_BUILD_TYPE=' + configuration,
+ '-G', generator, cmakelistsdir]
+ else:
+ cmd = [emconfigure, 'cmake', '-DCMAKE_BUILD_TYPE=' + configuration, '-G', generator, cmakelistsdir]
+ ret = Popen(cmd, stdout=None if verbose else PIPE, stderr=None if verbose else PIPE).communicate()
+ if len(ret) > 1 and ret[1] != None and len(ret[1].strip()) > 0:
+ print >> sys.stderr, ret[1] # If there were any errors, print them directly to console for diagnostics.
+ if len(ret) > 1 and ret[1] != None and 'error' in ret[1].lower():
+ print >> sys.stderr, 'Failed command: ' + ' '.join(cmd)
+ print >> sys.stderr, 'Result:\n' + ret[1]
+ raise Exception('cmake call failed!')
+ assert os.path.exists(tempdirname + '/Makefile'), 'CMake call did not produce a Makefile!'
+
+ # Build
+ cmd = [make_command] + (['VERBOSE=1'] if verbose else [])
+ ret = Popen(cmd, stdout=None if verbose else PIPE).communicate()
+ if len(ret) > 1 and ret[1] != None and len(ret[1].strip()) > 0:
+ print >> sys.stderr, ret[1] # If there were any errors, print them directly to console for diagnostics.
+ if len(ret) > 0 and ret[0] != None and 'error' in ret[0].lower() and not '0 error(s)' in ret[0].lower():
+ print >> sys.stderr, 'Failed command: ' + ' '.join(cmd)
+ print >> sys.stderr, 'Result:\n' + ret[0]
+ raise Exception('make failed!')
+ assert os.path.exists(tempdirname + '/' + cmake_outputs[i]), 'Building a cmake-generated Makefile failed to produce an output file %s!' % tempdirname + '/' + cmake_outputs[i]
+
+ # Run through node, if CMake produced a .js file.
+ if cmake_outputs[i].endswith('.js'):
+ ret = Popen(listify(NODE_JS) + [tempdirname + '/' + cmake_outputs[i]], stdout=PIPE).communicate()[0]
+ assert 'hello, world!' in ret, 'Running cmake-based .js application failed!'
+ finally:
+ os.chdir(path_from_root('tests')) # Move away from the directory we are about to remove.
+ shutil.rmtree(tempdirname)
def test_failure_error_code(self):
for compiler in [EMCC, EMXX]: