Reputation: 6204
I'm trying to pass images to UI Tests. To do this I use launch arguments.
let bundle = NSBundle (forClass: self.dynamicType)
let images = ["img1", "img2"]
.map {
bundle.URLForResource($0, withExtension: "jpg")!
}
.map {
NSData(contentsOfURL: $0)!
}
.map {
$0.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: .allZeros))
}
XCUIApplication().launchArguments= ["IMAGES", images.joinWithSeparator("_")]
I unpack them the same way. A one or two small images work as expected, but if I use large pictures I get:
The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.)
Is there some arbitrary number of characters I can pass as the launch arguments?
Upvotes: 2
Views: 769
Reputation: 81868
The terminal can tell you the maximum length of the command line:
$ sysctl kern.argmax
kern.argmax: 262144
This value includes space needed for the environment. It's probably a bad idea to pass blobs directly in the arguments.
You should pass the URLs and read the contents of the files in the process.
Upvotes: 3