Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: test/mjsunit/d8-os.js

Issue 9348051: Fix d8-os unit test to work with isolates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (this.os && os.system) { 56 if (this.os && os.system) {
57 // Ensure that we have a valid working directory. 57 // Ensure that we have a valid working directory.
58 os.chdir("/tmp"); 58 os.chdir("/tmp");
59 try { 59 try {
60 // Delete the dir if it is lying around from last time. 60 // Delete the dir if it is lying around from last time.
61 os.system("ls", [TEST_DIR]); 61 os.system("ls", [TEST_DIR]);
62 os.system("rm", ["-r", TEST_DIR]); 62 os.system("rm", ["-r", TEST_DIR]);
63 } catch (e) { 63 } catch (e) {
64 } 64 }
65 os.mkdirp(TEST_DIR); 65 os.mkdirp(TEST_DIR);
66 os.chdir(TEST_DIR);
67 try { 66 try {
68 // Check the chdir worked. 67 // Check the chdir worked.
69 os.system('ls', [TEST_DIR]); 68 os.system('ls', [TEST_DIR]);
70 // Simple create dir. 69 // Simple create dir.
71 os.mkdirp("dir"); 70 os.mkdirp(TEST_DIR + "/dir");
72 // Create dir in dir. 71 // Create dir in dir.
73 os.mkdirp("dir/foo"); 72 os.mkdirp(TEST_DIR + "/dir/foo");
74 // Check that they are there. 73 // Check that they are there.
75 os.system('ls', ['dir/foo']); 74 os.system('ls', [TEST_DIR + '/dir/foo']);
76 // Check that we can detect when something is not there. 75 // Check that we can detect when something is not there.
77 assertThrows("os.system('ls', ['dir/bar']);", "dir not there"); 76 assertThrows("os.system('ls', [TEST_DIR + '/dir/bar']);", "dir not there");
78 // Check that mkdirp makes intermediate directories. 77 // Check that mkdirp makes intermediate directories.
79 os.mkdirp("dir2/foo"); 78 os.mkdirp(TEST_DIR + "/dir2/foo");
80 os.system("ls", ["dir2/foo"]); 79 os.system("ls", [TEST_DIR + "/dir2/foo"]);
81 // Check that mkdirp doesn't mind if the dir is already there. 80 // Check that mkdirp doesn't mind if the dir is already there.
82 os.mkdirp("dir2/foo"); 81 os.mkdirp(TEST_DIR + "/dir2/foo");
83 os.mkdirp("dir2/foo/"); 82 os.mkdirp(TEST_DIR + "/dir2/foo/");
84 // Check that mkdirp can cope with trailing / 83 // Check that mkdirp can cope with trailing /
85 os.mkdirp("dir3/"); 84 os.mkdirp(TEST_DIR + "/dir3/");
86 os.system("ls", ["dir3"]); 85 os.system("ls", [TEST_DIR + "/dir3"]);
87 // Check that we get an error if the name is taken by a file. 86 // Check that we get an error if the name is taken by a file.
88 os.system("sh", ["-c", "echo foo > file1"]); 87 os.system("sh", ["-c", "echo foo > " + TEST_DIR + "/file1"]);
89 os.system("ls", ["file1"]); 88 os.system("ls", [TEST_DIR + "/file1"]);
90 assertThrows("os.mkdirp('file1');", "mkdir over file1"); 89 assertThrows("os.mkdirp(TEST_DIR + '/file1');", "mkdir over file1");
91 assertThrows("os.mkdirp('file1/foo');", "mkdir over file2"); 90 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo');", "mkdir over file2");
92 assertThrows("os.mkdirp('file1/');", "mkdir over file3"); 91 assertThrows("os.mkdirp(TEST_DIR + '/file1/');", "mkdir over file3");
93 assertThrows("os.mkdirp('file1/foo/');", "mkdir over file4"); 92 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo/');", "mkdir over file4");
94 // Create a dir we cannot read. 93 // Create a dir we cannot read.
95 os.mkdirp("dir4", 0); 94 os.mkdirp(TEST_DIR + "/dir4", 0);
96 // This test fails if you are root since root can read any dir. 95 // This test fails if you are root since root can read any dir.
97 assertThrows("os.chdir('dir4');", "chdir dir4 I"); 96 assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 I");
98 os.rmdir("dir4"); 97 os.rmdir(TEST_DIR + "/dir4");
99 assertThrows("os.chdir('dir4');", "chdir dir4 II"); 98 assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 II");
100 // Set umask. 99 // Set umask.
101 var old_umask = os.umask(0777); 100 var old_umask = os.umask(0777);
102 // Create a dir we cannot read. 101 // Create a dir we cannot read.
103 os.mkdirp("dir5"); 102 os.mkdirp(TEST_DIR + "/dir5");
104 // This test fails if you are root since root can read any dir. 103 // This test fails if you are root since root can read any dir.
105 assertThrows("os.chdir('dir5');", "cd dir5 I"); 104 assertThrows("os.chdir(TEST_DIR + '/dir5');", "cd dir5 I");
106 os.rmdir("dir5"); 105 os.rmdir(TEST_DIR + "/dir5");
107 assertThrows("os.chdir('dir5');", "chdir dir5 II"); 106 assertThrows("os.chdir(TEST_DIR + '/dir5');", "chdir dir5 II");
108 os.umask(old_umask); 107 os.umask(old_umask);
109 108
110 os.mkdirp("hest/fisk/../fisk/ged"); 109 os.mkdirp(TEST_DIR + "/hest/fisk/../fisk/ged");
111 os.system("ls", ["hest/fisk/ged"]); 110 os.system("ls", [TEST_DIR + "/hest/fisk/ged"]);
112 111
113 os.setenv("FOO", "bar"); 112 os.setenv("FOO", "bar");
114 var environment = os.system("printenv"); 113 var environment = os.system("printenv");
115 assertTrue(/FOO=bar/.test(environment)); 114 assertTrue(/FOO=bar/.test(environment));
116 115
117 // Check we time out. 116 // Check we time out.
118 var have_sleep = true; 117 var have_sleep = true;
119 var have_echo = true; 118 var have_echo = true;
120 try { 119 try {
121 os.system("ls", ["/bin/sleep"]); 120 os.system("ls", ["/bin/sleep"]);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 str_error("os.mkdirp(e);"); 177 str_error("os.mkdirp(e);");
179 str_error("os.setenv(e, 'goo');"); 178 str_error("os.setenv(e, 'goo');");
180 str_error("os.setenv('goo', e);"); 179 str_error("os.setenv('goo', e);");
181 str_error("os.chdir(e);"); 180 str_error("os.chdir(e);");
182 str_error("os.rmdir(e);"); 181 str_error("os.rmdir(e);");
183 182
184 } finally { 183 } finally {
185 os.system("rm", ["-r", TEST_DIR]); 184 os.system("rm", ["-r", TEST_DIR]);
186 } 185 }
187 } 186 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698