7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
27 * 6894719 6968053 7151434 7146424 8007333
28 * @summary Argument parsing validation.
29 * @compile -XDignore.symbol.file Arrrghs.java
30 * @run main/othervm Arrrghs
31 */
32
33
34 import java.io.File;
35 import java.io.FileNotFoundException;
36 import java.io.IOException;
37 import java.util.ArrayList;
38 import java.util.Arrays;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42 import java.util.regex.Matcher;
43 import java.util.regex.Pattern;
44
45 public class Arrrghs extends TestHelper {
46 private Arrrghs(){}
47 /**
286 }
287
288 /*
289 * These tests are not expected to work on *nixes, and are ignored.
290 */
291 @Test
292 void testWildCardArgumentProcessing() throws IOException {
293 if (!isWindows)
294 return;
295 File cwd = new File(".");
296 File libDir = new File(cwd, "lib");
297 initDirWithJavaFiles(libDir);
298 initEmptyDir(new File(cwd, "empty"));
299
300 // test if javac (the command) can compile *.java
301 TestResult tr = doExec(javacCmd, libDir.getName() + File.separator + "*.java");
302 if (!tr.isOK()) {
303 System.out.println(tr);
304 throw new RuntimeException("Error: compiling java wildcards");
305 }
306
307 // use the jar cmd to create jars using the ? wildcard
308 File jarFoo = new File(libDir, "Foo.jar");
309 tr = doExec(jarCmd, "cvf", jarFoo.getAbsolutePath(), "lib" + File.separator + "F?o.class");
310 if (!tr.isOK()) {
311 System.out.println(tr);
312 throw new RuntimeException("Error: creating jar with wildcards");
313 }
314
315 // now the litmus test!, this should work
316 checkArgumentWildcard("a", "a");
317
318 // test for basic expansion
319 checkArgumentWildcard("lib\\F*java", "lib\\Fbo.java", "lib\\Foo.java");
320
321 // basic expansion in quotes
322 checkArgumentWildcard("\"lib\\F*java\"", "lib\\F*java");
323
324 checkArgumentWildcard("lib\\**", "lib\\Fbo.class", "lib\\Fbo.java",
325 "lib\\Foo.class", "lib\\Foo.jar", "lib\\Foo.java");
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
27 * 6894719 6968053 7151434 7146424 8007333 8077822
28 * @summary Argument parsing validation.
29 * @compile -XDignore.symbol.file Arrrghs.java
30 * @run main/othervm Arrrghs
31 */
32
33
34 import java.io.File;
35 import java.io.FileNotFoundException;
36 import java.io.IOException;
37 import java.util.ArrayList;
38 import java.util.Arrays;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42 import java.util.regex.Matcher;
43 import java.util.regex.Pattern;
44
45 public class Arrrghs extends TestHelper {
46 private Arrrghs(){}
47 /**
286 }
287
288 /*
289 * These tests are not expected to work on *nixes, and are ignored.
290 */
291 @Test
292 void testWildCardArgumentProcessing() throws IOException {
293 if (!isWindows)
294 return;
295 File cwd = new File(".");
296 File libDir = new File(cwd, "lib");
297 initDirWithJavaFiles(libDir);
298 initEmptyDir(new File(cwd, "empty"));
299
300 // test if javac (the command) can compile *.java
301 TestResult tr = doExec(javacCmd, libDir.getName() + File.separator + "*.java");
302 if (!tr.isOK()) {
303 System.out.println(tr);
304 throw new RuntimeException("Error: compiling java wildcards");
305 }
306
307 // test if javac (the command) can compile *.java with a vmoption
308 tr = doExec(javacCmd, "-cp", ".",
309 "-J-showversion", "-J-Dsomeproperty=foo",
310 libDir.getName() + File.separator + "*.java");
311 if (!tr.isOK()) {
312 System.out.println(tr);
313 throw new RuntimeException("Error: compiling java wildcards with vmoptions");
314 }
315
316
317 // use the jar cmd to create jars using the ? wildcard
318 File jarFoo = new File(libDir, "Foo.jar");
319 tr = doExec(jarCmd, "cvf", jarFoo.getAbsolutePath(), "lib" + File.separator + "F?o.class");
320 if (!tr.isOK()) {
321 System.out.println(tr);
322 throw new RuntimeException("Error: creating jar with wildcards");
323 }
324
325 // now the litmus test!, this should work
326 checkArgumentWildcard("a", "a");
327
328 // test for basic expansion
329 checkArgumentWildcard("lib\\F*java", "lib\\Fbo.java", "lib\\Foo.java");
330
331 // basic expansion in quotes
332 checkArgumentWildcard("\"lib\\F*java\"", "lib\\F*java");
333
334 checkArgumentWildcard("lib\\**", "lib\\Fbo.class", "lib\\Fbo.java",
335 "lib\\Foo.class", "lib\\Foo.jar", "lib\\Foo.java");
|