-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8362598: [macos] Add tests for custom info plist files #27509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back almatvee! A progress list of the required criteria for merging this PR into |
@alexeysemenyukoracle Please review. |
❗ This change is not yet ready to be integrated. |
@sashamatveev The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
public static void writePList(XMLStreamWriter xml, XmlConsumer content) | ||
throws XMLStreamException, IOException { | ||
xml.writeDTD("plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"https://www.apple.com/DTDs/PropertyList-1.0.dtd\""); | ||
xml.writeStartDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need writeStartDocument()/writeEndDocument()
calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To write XML declaration to Info.plist file. Without it reading PList file fails.
return (cmd.hasArgument("--mac-signing-key-user-name") || cmd.hasArgument("--mac-app-image-sign-identity")); | ||
} | ||
|
||
public static Path createInputRuntimeImage() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not mac-specific helper function. You'd rather move it to JPackageCommand class.
BTW, there is a bunch of createInputRuntimeImage()
functions already:
private static Path createInputRuntimeImage() throws IOException { private static Path createInputRuntimeImage() throws IOException { if (JPackageCommand.DEFAULT_RUNTIME_IMAGE == null) {
Instead of adding another one, let's consolidate them in one.
private static final String BUNDLE_NAME_RUNTIME = "CustomRuntimeName"; | ||
|
||
// We do not need full Info.plist for testing | ||
private static String getInfoPListXML(String bundleName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use jdk.jpackage.internal.util.XmlUtils.createXml() helper to create xml file. It will format the output xml and will also eliminate the need for the patch in PListWriter class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using PListWriter
is more convenient then jdk.jpackage.internal.util.XmlUtils.createXml()
. I will prefer to use PListWriter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not suggesting replacing PListWriter
with XmlUtils.createXml()
. I'm suggesting replacing XMLOutputFactory.newInstance().createXMLStreamWriter(buf)
with XmlUtils.createXml()
:
private static void savePList(String bundleName, Path plistFile) throws XMLStreamException, IOException {
XmlUtils.createXml(plistFile, xml -> {
writePList(xml, toXmlConsumer(() -> {
writeDict(xml, toXmlConsumer(() -> {
writeString(xml, "CFBundleName", bundleName);
writeString(xml, "CFBundleIdentifier", "CustomInfoPListTest");
writeString(xml, "CFBundleVersion", "1.0");
}));
}));
});
}
cmd.execute(); | ||
|
||
MacHelper.withExplodedDmg(cmd, dmgImage -> { | ||
if (dmgImage.endsWith(cmd.name() + ".jdk")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this test redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This function is called for all files in DMG such as /Volumes/foo/.background
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. I see this sort of check in 5 locations.
I guess if you replace dmgImage.endsWith(cmd.name() + ".jdk")
with dmgImage.endsWith(cmd.appInstallationDirectory().getFileName())
it will become self-explanatory.
In the case of an app bundle, there is a single test case that replaces both the main and the runtime plist files. We need three test cases for better coverage:
The tests don't cover pattern matching in custom plist files. E.g., jpackage will replace |
8362598: [macos] Add tests for custom info plist files [v3]
|
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
import base.SigningBase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should result in the following error:
open\test\jdk\tools\jpackage\macosx\SigningRuntimeImagePackageTest.java:29: error: package base does not exist
import base.SigningBase;
^
1 error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. Not sure why it was added.
8362598: [macos] Add tests for custom info plist files [v5]
|
I took the liberty of using your patch as a baseline to improve testing of plist properties, including file associations. Here - #27658. Would you consider pulling it into your PR? |
writePList
. It was missingwriteStartDocument()/writeEndDocument()
andDOCTYPE
should be full xml string.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27509/head:pull/27509
$ git checkout pull/27509
Update a local copy of the PR:
$ git checkout pull/27509
$ git pull https://git.openjdk.org/jdk.git pull/27509/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27509
View PR using the GUI difftool:
$ git pr show -t 27509
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27509.diff
Using Webrev
Link to Webrev Comment