js/src/jit-test/tests/basic/testPaths.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // load() and snarf() (aka read()) should resolve paths relative to the current
michael@0 2 // working directory. This is a little hard to test because the shell doesn't
michael@0 3 // really have any (portable) notion of the current directory (and it can't
michael@0 4 // create files to enforce an expected layout.) loadRelativeToScript() and
michael@0 5 // readRelativeToScript() do what their names say, which is much easier to
michael@0 6 // test.
michael@0 7
michael@0 8 loaded = {}
michael@0 9 snarfed = {}
michael@0 10 loadRel = {}
michael@0 11 snarfRel = {}
michael@0 12 for (let f of ['local.js', '../basic/local.js', 'Y.js']) {
michael@0 13 try {
michael@0 14 load(f);
michael@0 15 loaded[f] = true;
michael@0 16 } catch(e) {
michael@0 17 loaded[f] = !/can't open/.test(e);
michael@0 18 }
michael@0 19
michael@0 20 try {
michael@0 21 snarf(f);
michael@0 22 snarfed[f] = true;
michael@0 23 } catch(e) {
michael@0 24 snarfed[f] = !/can't open/.test(e);
michael@0 25 }
michael@0 26
michael@0 27 try {
michael@0 28 readRelativeToScript(f);
michael@0 29 snarfRel[f] = true;
michael@0 30 } catch(e) {
michael@0 31 snarfRel[f] = !/can't open/.test(e);
michael@0 32 }
michael@0 33
michael@0 34 try {
michael@0 35 loadRelativeToScript(f);
michael@0 36 loadRel[f] = true;
michael@0 37 } catch(e) {
michael@0 38 loadRel[f] = !/can't open/.test(e);
michael@0 39 }
michael@0 40 }
michael@0 41
michael@0 42 // local.js in the same dir as this script, so should be found by the
michael@0 43 // script-relative calls but not the cwd-relative ones -- unless you happen to
michael@0 44 // be in that directory
michael@0 45 assertEq(loadRel['local.js'], true);
michael@0 46 assertEq(loadRel['../basic/local.js'], true);
michael@0 47 assertEq(snarfRel['local.js'], true);
michael@0 48 assertEq(snarfRel['../basic/local.js'], true);
michael@0 49 if (('PWD' in environment) && !(/test.*[\/\\]basic[\/\\]/.test(environment['PWD']))) {
michael@0 50 assertEq(loaded['local.js'], false);
michael@0 51 assertEq(loaded['../basic/local.js'], false);
michael@0 52 assertEq(snarfed['local.js'], false);
michael@0 53 assertEq(snarfed['../basic/local.js'], false);
michael@0 54 }
michael@0 55
michael@0 56 // Y.js is in the root of the objdir, where |make check| is normally
michael@0 57 // run from.
michael@0 58 assertEq(loadRel['Y.js'], false);
michael@0 59 assertEq(snarfRel['Y.js'], false);
michael@0 60 if (!snarfed['Y.js']) {
michael@0 61 print("WARNING: expected to be able to find Y.js in current directory\n");
michael@0 62 print("(not failing because it depends on where this test was run from)\n");
michael@0 63 }
michael@0 64 if (!loaded['Y.js']) {
michael@0 65 print("WARNING: expected to be able to find Y.js in current directory\n");
michael@0 66 print("(not failing because it depends on where this test was run from)\n");
michael@0 67 }

mercurial