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

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

Issue 1544793002: [tests] Fix bogus uses of assertThrows. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 11 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
« no previous file with comments | « test/mjsunit/asm/infinite-loops-taken.js ('k') | test/mjsunit/es6/array-tostring.js » ('j') | 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 try { 66 try {
67 // Check the chdir worked. 67 // Check the chdir worked.
68 os.system('ls', [TEST_DIR]); 68 os.system('ls', [TEST_DIR]);
69 // Simple create dir. 69 // Simple create dir.
70 os.mkdirp(TEST_DIR + "/dir"); 70 os.mkdirp(TEST_DIR + "/dir");
71 // Create dir in dir. 71 // Create dir in dir.
72 os.mkdirp(TEST_DIR + "/dir/foo"); 72 os.mkdirp(TEST_DIR + "/dir/foo");
73 // Check that they are there. 73 // Check that they are there.
74 os.system('ls', [TEST_DIR + '/dir/foo']); 74 os.system('ls', [TEST_DIR + '/dir/foo']);
75 // Check that we can detect when something is not there. 75 // Check that we can detect when something is not there.
76 assertThrows("os.system('ls', [TEST_DIR + '/dir/bar']);", "dir not there"); 76 assertThrows("os.system('ls', [TEST_DIR + '/dir/bar']);");
77 // Check that mkdirp makes intermediate directories. 77 // Check that mkdirp makes intermediate directories.
78 os.mkdirp(TEST_DIR + "/dir2/foo"); 78 os.mkdirp(TEST_DIR + "/dir2/foo");
79 os.system("ls", [TEST_DIR + "/dir2/foo"]); 79 os.system("ls", [TEST_DIR + "/dir2/foo"]);
80 // 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.
81 os.mkdirp(TEST_DIR + "/dir2/foo"); 81 os.mkdirp(TEST_DIR + "/dir2/foo");
82 os.mkdirp(TEST_DIR + "/dir2/foo/"); 82 os.mkdirp(TEST_DIR + "/dir2/foo/");
83 // Check that mkdirp can cope with trailing / 83 // Check that mkdirp can cope with trailing /
84 os.mkdirp(TEST_DIR + "/dir3/"); 84 os.mkdirp(TEST_DIR + "/dir3/");
85 os.system("ls", [TEST_DIR + "/dir3"]); 85 os.system("ls", [TEST_DIR + "/dir3"]);
86 // 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.
87 os.system("sh", ["-c", "echo foo > " + TEST_DIR + "/file1"]); 87 os.system("sh", ["-c", "echo foo > " + TEST_DIR + "/file1"]);
88 os.system("ls", [TEST_DIR + "/file1"]); 88 os.system("ls", [TEST_DIR + "/file1"]);
89 assertThrows("os.mkdirp(TEST_DIR + '/file1');", "mkdir over file1"); 89 assertThrows("os.mkdirp(TEST_DIR + '/file1');");
90 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo');", "mkdir over file2"); 90 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo');");
91 assertThrows("os.mkdirp(TEST_DIR + '/file1/');", "mkdir over file3"); 91 assertThrows("os.mkdirp(TEST_DIR + '/file1/');");
92 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo/');", "mkdir over file4"); 92 assertThrows("os.mkdirp(TEST_DIR + '/file1/foo/');");
93 // Create a dir we cannot read. 93 // Create a dir we cannot read.
94 os.mkdirp(TEST_DIR + "/dir4", 0); 94 os.mkdirp(TEST_DIR + "/dir4", 0);
95 // 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.
96 assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 I"); 96 assertThrows("os.chdir(TEST_DIR + '/dir4');");
97 os.rmdir(TEST_DIR + "/dir4"); 97 os.rmdir(TEST_DIR + "/dir4");
98 assertThrows("os.chdir(TEST_DIR + '/dir4');", "chdir dir4 II"); 98 assertThrows("os.chdir(TEST_DIR + '/dir4');");
99 99
100 // Set umask. This changes the umask for the whole process and is 100 // Set umask. This changes the umask for the whole process and is
101 // the reason why the test cannot be run multi-threaded. 101 // the reason why the test cannot be run multi-threaded.
102 var old_umask = os.umask(0777); 102 var old_umask = os.umask(0777);
103 // Create a dir we cannot read. 103 // Create a dir we cannot read.
104 os.mkdirp(TEST_DIR + "/dir5"); 104 os.mkdirp(TEST_DIR + "/dir5");
105 // This test fails if you are root since root can read any dir. 105 // This test fails if you are root since root can read any dir.
106 assertThrows("os.chdir(TEST_DIR + '/dir5');", "cd dir5 I"); 106 assertThrows("os.chdir(TEST_DIR + '/dir5');");
107 os.rmdir(TEST_DIR + "/dir5"); 107 os.rmdir(TEST_DIR + "/dir5");
108 assertThrows("os.chdir(TEST_DIR + '/dir5');", "chdir dir5 II"); 108 assertThrows("os.chdir(TEST_DIR + '/dir5');");
109 os.umask(old_umask); 109 os.umask(old_umask);
110 110
111 os.mkdirp(TEST_DIR + "/hest/fisk/../fisk/ged"); 111 os.mkdirp(TEST_DIR + "/hest/fisk/../fisk/ged");
112 os.system("ls", [TEST_DIR + "/hest/fisk/ged"]); 112 os.system("ls", [TEST_DIR + "/hest/fisk/ged"]);
113 113
114 os.setenv("FOO", "bar"); 114 os.setenv("FOO", "bar");
115 var environment = os.system("printenv"); 115 var environment = os.system("printenv");
116 assertTrue(/FOO=bar/.test(environment)); 116 assertTrue(/FOO=bar/.test(environment));
117 117
118 // Check we time out. 118 // Check we time out.
119 var have_sleep = true; 119 var have_sleep = true;
120 var have_echo = true; 120 var have_echo = true;
121 try { 121 try {
122 os.system("ls", ["/bin/sleep"]); 122 os.system("ls", ["/bin/sleep"]);
123 } catch (e) { 123 } catch (e) {
124 have_sleep = false; 124 have_sleep = false;
125 } 125 }
126 try { 126 try {
127 os.system("ls", ["/bin/echo"]); 127 os.system("ls", ["/bin/echo"]);
128 } catch (e) { 128 } catch (e) {
129 have_echo = false; 129 have_echo = false;
130 } 130 }
131 if (have_sleep) { 131 if (have_sleep) {
132 assertThrows("os.system('sleep', ['2000'], 20);", "sleep 1"); 132 assertThrows("os.system('sleep', ['2000'], 20);");
133 133
134 // Check we time out with total time. 134 // Check we time out with total time.
135 assertThrows("os.system('sleep', ['2000'], -1, 20);", "sleep 2"); 135 assertThrows("os.system('sleep', ['2000'], -1, 20);");
136 136
137 // Check that -1 means no timeout. 137 // Check that -1 means no timeout.
138 os.system('sleep', ['1'], -1, -1); 138 os.system('sleep', ['1'], -1, -1);
139 139
140 } 140 }
141 141
142 // Check that we don't fill up the process table with zombies. 142 // Check that we don't fill up the process table with zombies.
143 // Disabled because it's too slow. 143 // Disabled because it's too slow.
144 if (have_echo) { 144 if (have_echo) {
145 //for (var i = 0; i < 65536; i++) { 145 //for (var i = 0; i < 65536; i++) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 str_error("os.mkdirp(e);"); 179 str_error("os.mkdirp(e);");
180 str_error("os.setenv(e, 'goo');"); 180 str_error("os.setenv(e, 'goo');");
181 str_error("os.setenv('goo', e);"); 181 str_error("os.setenv('goo', e);");
182 str_error("os.chdir(e);"); 182 str_error("os.chdir(e);");
183 str_error("os.rmdir(e);"); 183 str_error("os.rmdir(e);");
184 184
185 } finally { 185 } finally {
186 os.system("rm", ["-r", TEST_DIR]); 186 os.system("rm", ["-r", TEST_DIR]);
187 } 187 }
188 } 188 }
OLDNEW
« no previous file with comments | « test/mjsunit/asm/infinite-loops-taken.js ('k') | test/mjsunit/es6/array-tostring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698