diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-06-13 21:54:11 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-06-13 21:54:34 +0300 |
commit | 15b236a68796330670aa7795e3907a1f956f127e (patch) | |
tree | 1d06ddbdeb0f81efcdbcd0372217ec4443584cd5 /tests | |
parent | 886e3158cf5d95a2c2721e5eb9a1c3ac4461f805 (diff) |
Report debug diagnostics in file packager if EMCC_DEBUG=1. Make file packager skip all path components that have a path starting with '.', like ('.git/xxx/yyy/'), or the filename starts with '.', or the file is a Win32 hidden file. Explicitly specified files on the command line are always packaged, even if they start with '.' or are hidden. Add unit tests to check that it works.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/tests/runner.py b/tests/runner.py index 5e101024..7f8c2d87 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11804,6 +11804,9 @@ elif 'browser' in str(sys.argv): def test_preload_file(self): absolute_src_path = os.path.join(self.get_dir(), 'somefile.txt').replace('\\', '/') open(absolute_src_path, 'w').write('''load me right before running the code please''') + + absolute_src_path2 = os.path.join(self.get_dir(), '.somefile.txt').replace('\\', '/') + open(absolute_src_path2, 'w').write('''load me right before running the code please''') def make_main(path): print path @@ -11828,6 +11831,7 @@ elif 'browser' in str(sys.argv): test_cases = [ # (source preload-file string, file on target FS to load) ("somefile.txt", "somefile.txt"), + (".somefile.txt@somefile.txt", "somefile.txt"), ("./somefile.txt", "somefile.txt"), ("somefile.txt@file.txt", "file.txt"), ("./somefile.txt@file.txt", "file.txt"), @@ -11856,11 +11860,13 @@ elif 'browser' in str(sys.argv): # Test subdirectory handling with asset packaging. os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/').replace('\\', '/')) + os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/.git').replace('\\', '/')) # Test adding directory that shouldn't exist. os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset2/').replace('\\', '/')) open(os.path.join(self.get_dir(), 'assets/sub/asset1/file1.txt'), 'w').write('''load me right before running the code please''') + open(os.path.join(self.get_dir(), 'assets/sub/asset1/.git/shouldnt_be_embedded.txt'), 'w').write('''this file should not get embedded''') open(os.path.join(self.get_dir(), 'assets/sub/asset2/file2.txt'), 'w').write('''load me right before running the code please''') absolute_assets_src_path = os.path.join(self.get_dir(), 'assets').replace('\\', '/') - def make_main_two_files(path1, path2): + def make_main_two_files(path1, path2, nonexistingpath): open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r''' #include <stdio.h> #include <string.h> @@ -11879,24 +11885,29 @@ elif 'browser' in str(sys.argv): if (f == NULL) result = 0; fclose(f); + + f = fopen("%s", "r"); + if (f != NULL) + result = 0; + REPORT_RESULT(); return 0; } - ''' % (path1, path2))) + ''' % (path1, path2, nonexistingpath))) test_cases = [ - # (source directory to embed, file1 on target FS to load, file2 on target FS to load) - ("assets", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt"), - ("assets/", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt"), - ("assets@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - ("assets/@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - ("assets@./", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - (absolute_assets_src_path + "@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - (absolute_assets_src_path + "@/assets", "/assets/sub/asset1/file1.txt", "/assets/sub/asset2/file2.txt")] + # (source directory to embed, file1 on target FS to load, file2 on target FS to load, name of a file that *shouldn't* exist on VFS) + ("assets", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets/", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets/@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets@./", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + (absolute_assets_src_path + "@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + (absolute_assets_src_path + "@/assets", "/assets/sub/asset1/file1.txt", "/assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt")] for test in test_cases: - (srcpath, dstpath1, dstpath2) = test - make_main_two_files(dstpath1, dstpath2) + (srcpath, dstpath1, dstpath2, nonexistingpath) = test + make_main_two_files(dstpath1, dstpath2, nonexistingpath) print srcpath Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') |