Skip to content

Commit

Permalink
8342930: New tests from JDK-8335912 are failing
Browse files Browse the repository at this point in the history
  • Loading branch information
slowhog committed Oct 25, 2024
1 parent d1540e2 commit f94f308
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
11 changes: 11 additions & 0 deletions src/jdk.jartool/share/man/jar.1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ Updates an existing JAR file.
.TP
\f[V]-x\f[R] or \f[V]--extract\f[R]
Extracts the named (or all) files from the archive.
If a file with the same name appears more than once in the archive, each
copy will be extracted, with later copies overwriting (replacing)
earlier copies unless -k is specified.
.TP
\f[V]-d\f[R] or \f[V]--describe-module\f[R]
Prints the module descriptor or automatic module name.
Expand Down Expand Up @@ -212,6 +215,14 @@ time-zone format, to use for the timestamp of the entries, e.g.
.TP
\f[V]--dir\f[R] \f[I]DIR\f[R]
Directory into which the JAR file will be extracted.
.TP
\f[V]-k\f[R] or \f[V]--keep-old-files\f[R]
Do not overwrite existing files.
If a Jar file entry with the same name exists in the target directory,
the existing file will not be overwritten.
As a result, if a file appears more than once in an archive, later
copies will not overwrite earlier copies.
Also note that some file system can be case insensitive.
.SH OTHER OPTIONS
.PP
The following options are recognized by the \f[V]jar\f[R] command and
Expand Down
3 changes: 0 additions & 3 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,6 @@ javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.ja

# core_tools

tools/jar/ExtractFilesTest.java 8342930 generic-all
tools/jar/MultipleManifestTest.java 8342930 generic-all


############################################################################

Expand Down
16 changes: 10 additions & 6 deletions test/jdk/tools/jar/ExtractFilesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testExtract() throws IOException {
" inflated: testfile1" + nl +
" inflated: testfile2" + nl;
rm("META-INF testfile1 testfile2");
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -105,7 +105,7 @@ public void testOverwrite() throws IOException {
" inflated: testfile2" + nl;
Assertions.assertEquals("testfile1", cat("testfile1"));
rm("META-INF testfile1 testfile2");
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -123,7 +123,7 @@ public void testKeptOldFile() throws IOException {
Assertions.assertEquals("", cat("testfile1"));
Assertions.assertEquals("testfile2", cat("testfile2"));
rm("META-INF testfile1 testfile2");
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -141,7 +141,7 @@ public void testGnuOptionsKeptOldFile() throws IOException {
Assertions.assertEquals("", cat("testfile1"));
Assertions.assertEquals("", cat("testfile2"));
rm("META-INF testfile1 testfile2");
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -159,7 +159,7 @@ public void testGnuLongOptionsKeptOldFile() throws IOException {
Assertions.assertEquals("testfile1", cat("testfile1"));
Assertions.assertEquals("", cat("testfile2"));
rm("META-INF testfile1 testfile2");
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -175,10 +175,14 @@ public void testWarningOnInvalidKeepOption() throws IOException {
"testfile1" + nl +
"testfile2" + nl;

Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
Assertions.assertEquals("Warning: The --keep-old-files/-k/k option is not valid with current usage, will be ignored." + nl, err);
}

private void assertOutputContains(String expected) {
Assertions.assertTrue(baos.toString().contains(expected));
}

private Stream<Path> mkpath(String... args) {
return Arrays.stream(args).map(d -> Path.of(".", d.split("/")));
}
Expand Down
8 changes: 6 additions & 2 deletions test/jdk/tools/jar/MultipleManifestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void testOverwrite() throws IOException {
" inflated: entry1.txt" + nl +
" inflated: META-INF/MANIFEST.MF" + nl +
" inflated: entry2.txt" + nl;
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

/**
Expand All @@ -170,7 +170,7 @@ public void testKeptOldFile() throws IOException {
" inflated: entry1.txt" + nl +
" skipped: META-INF/MANIFEST.MF exists" + nl +
" inflated: entry2.txt" + nl;
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
assertOutputContains(output);
}

private String getManifestVersion() throws IOException {
Expand Down Expand Up @@ -199,6 +199,10 @@ private void jar(String cmdline) throws IOException {
}
}

private void assertOutputContains(String expected) {
Assertions.assertTrue(baos.toString().contains(expected));
}

private void println() throws IOException {
System.out.println(new String(baos.toByteArray()));
}
Expand Down

0 comments on commit f94f308

Please sign in to comment.