Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: testing/iossim/iossim.mm

Issue 10831050: Add support for setting environment variables that are used when the simulated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/iossim/iossim.mm
===================================================================
--- testing/iossim/iossim.mm (revision 148941)
+++ testing/iossim/iossim.mm (working copy)
@@ -279,6 +279,7 @@
NSString* stdoutPath,
NSString* stderrPath,
NSArray* appArgs,
+ NSDictionary* appEnv,
NSNumber* deviceFamily) {
DTiPhoneSimulatorSessionConfig* sessionConfig =
[[[DTiPhoneSimulatorSessionConfig alloc] init] autorelease];
@@ -288,10 +289,7 @@
sessionConfig.simulatedApplicationStdErrPath = stderrPath;
sessionConfig.simulatedApplicationStdOutPath = stdoutPath;
sessionConfig.simulatedApplicationLaunchArgs = appArgs;
- // TODO(lliabraa): Add support for providing environment variables/values
- // for the simulated app's environment. The environment can be set using:
- // sessionConfig.simulatedApplicationLaunchEnvironment =
- // [NSDictionary dictionary];
+ sessionConfig.simulatedApplicationLaunchEnvironment = appEnv;
sessionConfig.simulatedDeviceFamily = deviceFamily;
return sessionConfig;
}
@@ -374,7 +372,7 @@
// Prints the usage information to stderr.
void PrintUsage() {
fprintf(stderr, "Usage: iossim [-d device] [-s sdkVersion] [-u homeDir] "
- "<appPath> [<appArgs>]\n"
+ "[-e envKey=value]* <appPath> [<appArgs>]\n"
" where <appPath> is the path to the .app directory and appArgs are any"
" arguments to send the simulated app.\n"
"\n"
@@ -384,7 +382,9 @@
" -s Specifies the SDK version to use (e.g '4.3')."
" Will use system default if not specified.\n"
" -u Specifies a user home directory for the simulator."
- " Will create a new directory if not specified.\n");
+ " Will create a new directory if not specified.\n"
+ " -e Specifies an environment key=value pair that will be"
+ " set in the simulated application's environment.\n");
}
} // namespace
@@ -402,10 +402,11 @@
NSString* deviceName = @"iPhone";
NSString* simHomePath = nil;
NSMutableArray* appArgs = [NSMutableArray array];
+ NSMutableDictionary* appEnv = [NSMutableDictionary dictionary];
// Parse the optional arguments
int c;
- while ((c = getopt(argc, argv, "hs:d:u:")) != -1) {
+ while ((c = getopt(argc, argv, "hs:d:u:e:")) != -1) {
switch (c) {
case 's':
sdkVersion = [NSString stringWithUTF8String:optarg];
@@ -417,6 +418,19 @@
simHomePath = [[NSFileManager defaultManager]
stringWithFileSystemRepresentation:optarg length:strlen(optarg)];
break;
+ case 'e': {
+ NSString* envLine = [NSString stringWithUTF8String:optarg];
+ NSRange range = [envLine rangeOfString:@"="];
+ if (range.location == NSNotFound) {
+ LogError(@"Invalid key=value argument for -e.");
+ PrintUsage();
+ exit(EXIT_FAILURE);
+ }
+ NSString* key = [envLine substringToIndex:range.location];
+ NSString* value = [envLine substringFromIndex:(range.location + 1)];
+ [appEnv setObject:value forKey:key];
+ }
+ break;
case 'h':
PrintUsage();
exit(EXIT_SUCCESS);
@@ -496,6 +510,7 @@
stdioPath,
stdioPath,
appArgs,
+ appEnv,
deviceFamily);
SimulatorDelegate* delegate =
[[[SimulatorDelegate alloc] initWithStdioPath:stdioPath] autorelease];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698