aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-31 14:00:44 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-31 14:09:27 -0700
commite4ec9607364da091419c1b909e585e59da27e9d7 (patch)
tree2a86a08a39ad6ff020d2f940f535d2828347f677 /tests/runner.py
parentb786b5ed8a1d709b67d7dc80e8ba41bbaf6e58ae (diff)
absolutize and verify paths in the file packager
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 5eaf13dd..55d666e9 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -12165,6 +12165,36 @@ seeked= file.
self.assertNotContained('emcc: warning: treating -s as linker option', output[1])
assert os.path.exists('conftest')
+ def test_file_packager(self):
+ try:
+ os.mkdir('subdir')
+ except:
+ pass
+ open('data1.txt', 'w').write('data1')
+ os.chdir('subdir')
+ open('data2.txt', 'w').write('data2')
+ # relative path to below the current dir is invalid
+ out, err = Popen([PYTHON, FILE_PACKAGER, 'test.data', '--preload', '../data1.txt'], stdout=PIPE, stderr=PIPE).communicate()
+ assert len(out) == 0
+ assert 'below the current directory' in err
+ # relative path that ends up under us is cool
+ out, err = Popen([PYTHON, FILE_PACKAGER, 'test.data', '--preload', '../subdir/data2.txt'], stdout=PIPE, stderr=PIPE).communicate()
+ assert len(out) > 0
+ assert 'below the current directory' not in err
+ # direct path leads to the same code being generated - relative path does not make us do anything different
+ out2, err2 = Popen([PYTHON, FILE_PACKAGER, 'test.data', '--preload', 'data2.txt'], stdout=PIPE, stderr=PIPE).communicate()
+ assert len(out2) > 0
+ assert 'below the current directory' not in err2
+ def clean(txt):
+ return filter(lambda line: 'PACKAGE_UUID' not in line, txt.split('\n'))
+ out = clean(out)
+ out2 = clean(out2)
+ assert out == out2
+ # sanity check that we do generate different code for different inputs
+ out3, err3 = Popen([PYTHON, FILE_PACKAGER, 'test.data', '--preload', 'data2.txt', 'data2.txt@waka.txt'], stdout=PIPE, stderr=PIPE).communicate()
+ out3 = clean(out3)
+ assert out != out3
+
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')