Skip to content
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

Add --script-file-path to run a user script #290

Merged

Conversation

loufranco
Copy link
Contributor

This adds a way to run a script after a simulator is booted, but before tests are run. One reason to use this is to install certificates to integrate with mitmproxy (per #194)

@@ -141,6 +141,8 @@ typedef NS_OPTIONS(NSUInteger, BPOptionType) {
"Directory where simulator screenshots for failed ui tests will be stored"},
{362, "simulator-preferences-file", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_VALUE | BP_PATH, "simulatorPreferencesFile",
"A .GlobalPreferences.plist simulator preferences file to be copied to any newly created simulators before booting"},
{363, "script-file-path", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_VALUE | BP_PATH, "scriptFilePath",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just script-file

@@ -0,0 +1,5 @@
#!/bin/sh

# This is a script to test --script-file-path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to test-script.sh

XCTAssert(exitCode2 == BPExitStatusSimulatorDeleted);
XCTAssertEqualObjects(self.config.deleteSimUDID, bp2.test_simulatorUDID);

XCTAssertFalse([[NSFileManager defaultManager] fileExistsAtPath:testFile]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also delete the testfile after this test finishes

@@ -718,6 +720,18 @@ - (BOOL)validateConfigWithError:(NSError *__autoreleasing *)err {
}
}

if (self.scriptFilePath) {
if ([[NSFileManager defaultManager] fileExistsAtPath:self.scriptFilePath isDirectory:&isdir]) {
if (isdir) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make sure this file is executable

- rename script-file-path option to script-file
- rename script.sh file to test-script.sh
- if test file is not removed by sim delete, remove in test
- check to see if the script is executable
@loufranco
Copy link
Contributor Author

@oliverhu all comments addressed in latest commit

@oliverhu oliverhu merged commit d449fa1 into MobileNativeFoundation:master Oct 25, 2018
@oliverhu
Copy link
Member

LGTM, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants