diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_benchmark.py | 2 | ||||
-rw-r--r-- | tests/test_core.py | 7 | ||||
-rw-r--r-- | tests/test_other.py | 69 |
3 files changed, 69 insertions, 9 deletions
diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index 21a47178..729512f3 100644 --- a/tests/test_benchmark.py +++ b/tests/test_benchmark.py @@ -472,7 +472,7 @@ class benchmark(RunnerCore): def lua(self, benchmark, expected, output_parser=None, args_processor=None): shutil.copyfile(path_from_root('tests', 'lua', benchmark + '.lua'), benchmark + '.lua') def lib_builder(name, native, env_init): - ret = self.get_library('lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=native, cache_name_extra=name, env_init=env_init) + ret = self.get_library('lua_native' if native else 'lua', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=native, cache_name_extra=name, env_init=env_init) if native: return ret shutil.copyfile(ret[0], ret[0] + '.bc') ret[0] += '.bc' diff --git a/tests/test_core.py b/tests/test_core.py index 5aab48f5..f5d18e45 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3706,6 +3706,7 @@ ok self.do_run_from_file(src, output) def test_fnmatch(self): + if self.emcc_args is None: return self.skip('requires linking in libc++') test_path = path_from_root('tests', 'core', 'fnmatch') src, output = (test_path + s for s in ('.c', '.out')) self.do_run_from_file(src, output) @@ -4627,6 +4628,7 @@ return malloc(size); assert 'asm1' in test_modes if self.run_name == 'asm1': generated = open('src.cpp.o.js').read() + generated = re.sub(r'\n+[ \n]*\n+', '\n', generated) main = generated[generated.find('function runPostSets'):] main = main[:main.find('\n}')] assert main.count('\n') == 7, 'must not emit too many postSets: %d' % main.count('\n') @@ -5008,7 +5010,9 @@ def process(filename): def clean(text): text = text.replace('\n\n', '\n').replace('\n\n', '\n').replace('\n\n', '\n').replace('\n\n', '\n').replace('\n\n', '\n').replace('{\n}', '{}') return '\n'.join(sorted(text.split('\n'))) - self.assertIdentical(clean(open('release.js').read()), clean(open('debug%d.js' % debug).read())) # EMCC_DEBUG=1 mode must not generate different code! + sizes = len(open('release.js').read()), len(open('debug%d.js' % debug).read()) + print >> sys.stderr, debug, 'sizes', sizes + assert abs(sizes[0] - sizes[1]) < 0.0001*sizes[0] # we can't check on identical output, compilation is not 100% deterministic (order of switch elements, etc.), but size should be ~identical print >> sys.stderr, 'debug check %d passed too' % debug try: @@ -6055,6 +6059,7 @@ def process(filename): # optimizer can deal with both types. out_file = re.sub(' *//@.*$', '', out_file, flags=re.MULTILINE) def clean(code): + code = re.sub(r'\n+[ \n]*\n+', '\n', code) code = code.replace('{\n}', '{}') return '\n'.join(sorted(code.split('\n'))) self.assertIdentical(clean(no_maps_file), clean(out_file)) diff --git a/tests/test_other.py b/tests/test_other.py index b2fc4cf6..f69eced2 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -284,9 +284,33 @@ f.close() if WINDOWS: generators = ['MinGW Makefiles', 'NMake Makefiles'] else: - generators = ['Unix Makefiles'] - - make_commands = { 'MinGW Makefiles': ['mingw32-make'], 'NMake Makefiles': ['nmake', '/NOLOGO'], 'Unix Makefiles': ['make'] } + generators = ['Unix Makefiles', 'Ninja', 'Eclipse CDT4 - Ninja'] + + def nmake_detect_error(configuration): + if Building.which(configuration['build'][0]): + return None + else: + return 'Skipping NMake test for CMake support, since nmake was not found in PATH. Run this test in Visual Studio command prompt to easily access nmake.' + + def check_makefile(configuration, dirname): + assert os.path.exists(dirname + '/Makefile'), 'CMake call did not produce a Makefile!' + + configurations = { 'MinGW Makefiles' : { 'prebuild': check_makefile, + 'build' : ['mingw32-make'], + + }, + 'NMake Makefiles' : { 'detect' : nmake_detect_error, + 'prebuild': check_makefile, + 'build' : ['nmake', '/NOLOGO'], + }, + 'Unix Makefiles' : { 'prebuild': check_makefile, + 'build' : ['make'], + }, + 'Ninja' : { 'build' : ['ninja'], + }, + 'Eclipse CDT4 - Ninja': { 'build' : ['ninja'], + } + } if os.name == 'nt': emconfigure = path_from_root('emconfigure.bat') @@ -294,11 +318,37 @@ f.close() emconfigure = path_from_root('emconfigure') for generator in generators: - if generator == 'NMake Makefiles' and not Building.which('nmake'): - print >> sys.stderr, 'Skipping NMake test for CMake support, since nmake was not found in PATH. Run this test in Visual Studio command prompt to easily access nmake.' + conf = configurations[generator] + + make = conf['build'] + + try: + detector = conf['detect'] + except KeyError: + detector = None + + if detector: + error = detector(conf) + elif len(make) == 1 and not Building.which(make[0]): + # Use simple test if applicable + error = 'Skipping %s test for CMake support, since it could not be detected.' % generator + else: + error = None + + if error: + logging.warning(error) continue - make = make_commands[generator] + try: + prebuild = conf['prebuild'] + except KeyError: + prebuild = None + + try: + postbuild = conf['postbuild'] + except KeyError: + postbuild = None + cmake_cases = ['target_js', 'target_html'] cmake_outputs = ['test_cmake.js', 'hello_world_gles.html'] for i in range(0, 2): @@ -331,7 +381,9 @@ f.close() logging.error('Failed command: ' + ' '.join(cmd)) logging.error('Result:\n' + ret[1]) raise Exception('cmake call failed!') - assert os.path.exists(tempdirname + '/Makefile'), 'CMake call did not produce a Makefile!' + + if prebuild: + prebuild(configuration, tempdirname) # Build cmd = make + (['VERBOSE=1'] if verbose_level >= 3 else []) @@ -344,6 +396,9 @@ f.close() 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] + if postbuild: + postbuild(configuration, tempdirname) + # 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] |