diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 861277e6..d840465d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7183,6 +7183,25 @@ fscanfed: 10 - hello code = open('a.out.js').read() assert 'SAFE_HEAP' in code, 'valid -s option had an effect' + def test_crunch(self): + # crunch should not be run if a .crn exists that is more recent than the .dds + shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds') + time.sleep(0.1) + Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate() + assert os.stat('test.data').st_size < 0.25*os.stat('ship.dds').st_size, 'Compressed should be much smaller than dds' + crunch_time = os.stat('ship.crn').st_mtime + dds_time = os.stat('ship.dds').st_mtime + assert crunch_time > dds_time, 'Crunch is more recent' + # run again, should not recrunch! + time.sleep(0.1) + Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate() + assert crunch_time == os.stat('ship.crn').st_mtime, 'Crunch is unchanged' + # update dds, so should recrunch + time.sleep(0.1) + os.utime('ship.dds', None) + Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate() + assert crunch_time < os.stat('ship.crn').st_mtime, 'Crunch was changed' + elif 'browser' in str(sys.argv): # Browser tests. |