WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
133663
old-run-webkit-tests: Create CoreSimulator device on demand and find it by name
https://bugs.webkit.org/show_bug.cgi?id=133663
Summary
old-run-webkit-tests: Create CoreSimulator device on demand and find it by name
David Farler
Reported
2014-06-09 16:26:05 PDT
As a short-term solution, since CoreSimulator requires a device UDID (a UUID) to specified for nearly all device actions, we need a simple (but not full-fledged PerlObjC) wrapper around CoreSimulator to: - create an iOS sim device of a particular type and runtime (SDK) - delete an iOS sim device - launch an app on a particular sim device - return a list of currently installed device (read plists in the current user's simulator device directory) and then pass the UDID to the distributed session/install notification. sub createiOSSimulatorDevice(name, typeId, runtimeId) -> void sub deleteiOSSimulatorDevice(udid) -> void sub iOSSimulatorDevices() -> [ { udid: device dict } ]
Attachments
Patch
(5.59 KB, patch)
2014-06-10 12:08 PDT
,
David Farler
ddkilzer
: review+
Details
Formatted Diff
Diff
Patch
(5.62 KB, patch)
2014-06-10 13:47 PDT
,
David Farler
ddkilzer
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
David Farler
Comment 1
2014-06-10 12:08:37 PDT
Created
attachment 232802
[details]
Patch
David Farler
Comment 2
2014-06-10 12:08:56 PDT
OK, one more time.
David Kilzer (:ddkilzer)
Comment 3
2014-06-10 12:57:31 PDT
Comment on
attachment 232802
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
r=me
> Tools/Scripts/old-run-webkit-tests:1390 > - my $deviceName = architecture() eq 'i386' ? "iPhone 5" : "iPhone 5s"; > + my $deviceName = architecture() eq 'i386' ? "iPhone 5 WebKit Tester" : "iPhone 5s WebKit Tester"; > + > + my $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; > + $deviceType .= "s" if architecture() eq "x86_64";
Nit: It might be clearer to just make this an if/else statement: my $deviceName = "iPhone 5 WebKit Tester"; my $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; if (architecture() eq 'x86_64') { $deviceName = "iPhone 5s WebKit Tester"; $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"; }
> Tools/Scripts/webkitdirs.pm:1122 > + return "$ENV{HOME}/Library/Developer/CoreSimulator/Devices";
Should this be $ENV{CFFIXED_USER_HOME} instead?
> Tools/Scripts/webkitdirs.pm:1127 > + use Foundation;
I'm hoping this won't be evaluated until the method is called, since this could break non-Mac users of the script.
> Tools/Scripts/webkitdirs.pm:1166 > + my $tries = 5; > + while (1) { > + my @devices = iOSSimulatorDevices(); > + foreach my $device (@devices) { > + return $device if $device->{name} eq $name and $device->{deviceType} eq $deviceTypeId and $device->{runtime} eq $runtimeId; > + } > + sleep 5; > + $tries -= 1; > + if ($tries <= 0) { > + die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath(); > + } > + }
This would be simpler with a for() loop that just falls through: for (my $tries = 5; $tries > 0; $tries--) { [...] sleep 5; } die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath();
David Kilzer (:ddkilzer)
Comment 4
2014-06-10 13:11:08 PDT
(In reply to
comment #3
)
> (From update of
attachment 232802
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
> > > Tools/Scripts/webkitdirs.pm:1127 > > + use Foundation; > > I'm hoping this won't be evaluated until the method is called, since this could break non-Mac users of the script.
Windows and EFL bots are failing because "use Foundation;" is evaluated at parse time, not run time:
https://webkit-queues.appspot.com/patch/232802
Failed to run "['Tools/Scripts/build-webkit', '--release', '--efl', '--update-efl', '--no-webkit1', '--makeargs="-j8"']" exit_code: 2 Can't locate Foundation.pm in @INC (@INC contains: /mnt/eflews/git/webkit/Tools/Scripts /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /mnt/eflews/git/webkit/Tools/Scripts/webkitdirs.pm line 1127. BEGIN failed--compilation aborted at /mnt/eflews/git/webkit/Tools/Scripts/webkitdirs.pm line 1127. You'll have to use a Perl trick so that you only load Foundation at runtime; I think you either have to use an eval{} block and/or change it to a "require" statement. I think "man perlmod" has the details.
David Farler
Comment 5
2014-06-10 13:31:32 PDT
(In reply to
comment #4
)
> (In reply to
comment #3
) > > (From update of
attachment 232802
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
> > > > > Tools/Scripts/webkitdirs.pm:1127 > > > + use Foundation; > > > > I'm hoping this won't be evaluated until the method is called, since this could break non-Mac users of the script. > > Windows and EFL bots are failing because "use Foundation;" is evaluated at parse time, not run time: > >
https://webkit-queues.appspot.com/patch/232802
> > Failed to run "['Tools/Scripts/build-webkit', '--release', '--efl', '--update-efl', '--no-webkit1', '--makeargs="-j8"']" exit_code: 2 > Can't locate Foundation.pm in @INC (@INC contains: /mnt/eflews/git/webkit/Tools/Scripts /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /mnt/eflews/git/webkit/Tools/Scripts/webkitdirs.pm line 1127. > BEGIN failed--compilation aborted at /mnt/eflews/git/webkit/Tools/Scripts/webkitdirs.pm line 1127. > > You'll have to use a Perl trick so that you only load Foundation at runtime; I think you either have to use an eval{} block and/or change it to a "require" statement. I think "man perlmod" has the details.
Ah, I forgot that `use` is implicitly in the BEGIN block. The documentation recommends eval "require Foundation".
David Farler
Comment 6
2014-06-10 13:34:46 PDT
(In reply to
comment #3
)
> (From update of
attachment 232802
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
> > r=me > > > Tools/Scripts/old-run-webkit-tests:1390 > > - my $deviceName = architecture() eq 'i386' ? "iPhone 5" : "iPhone 5s"; > > + my $deviceName = architecture() eq 'i386' ? "iPhone 5 WebKit Tester" : "iPhone 5s WebKit Tester"; > > + > > + my $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; > > + $deviceType .= "s" if architecture() eq "x86_64"; > > Nit: It might be clearer to just make this an if/else statement: > > my $deviceName = "iPhone 5 WebKit Tester"; > my $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5"; > if (architecture() eq 'x86_64') { > $deviceName = "iPhone 5s WebKit Tester"; > $deviceType = "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"; > }
Yep, that's much clearer.
> > > Tools/Scripts/webkitdirs.pm:1122 > > + return "$ENV{HOME}/Library/Developer/CoreSimulator/Devices"; > > Should this be $ENV{CFFIXED_USER_HOME} instead?
I'm not familiar with CFFIXED_USER_HOME - where is that defined?
> > > Tools/Scripts/webkitdirs.pm:1127 > > + use Foundation; > > I'm hoping this won't be evaluated until the method is called, since this could break non-Mac users of the script.
You were right about this :) . I'll fix it in a subsequent patch.
> > > Tools/Scripts/webkitdirs.pm:1166 > > + my $tries = 5; > > + while (1) { > > + my @devices = iOSSimulatorDevices(); > > + foreach my $device (@devices) { > > + return $device if $device->{name} eq $name and $device->{deviceType} eq $deviceTypeId and $device->{runtime} eq $runtimeId; > > + } > > + sleep 5; > > + $tries -= 1; > > + if ($tries <= 0) { > > + die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath(); > > + } > > + } > > This would be simpler with a for() loop that just falls through: > > for (my $tries = 5; $tries > 0; $tries--) { > [...] > sleep 5; > } > > die "Device $name $deviceTypeId $runtimeId wasn't found in " . iOSSimulatorDevicesPath();
Good call. I'll switch it over.
David Farler
Comment 7
2014-06-10 13:47:57 PDT
Created
attachment 232811
[details]
Patch
David Kilzer (:ddkilzer)
Comment 8
2014-06-10 14:17:59 PDT
(In reply to
comment #6
)
> (In reply to
comment #3
) > > (From update of
attachment 232802
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
> > > > > Tools/Scripts/webkitdirs.pm:1122 > > > + return "$ENV{HOME}/Library/Developer/CoreSimulator/Devices"; > > > > Should this be $ENV{CFFIXED_USER_HOME} instead? > > I'm not familiar with CFFIXED_USER_HOME - where is that defined?
It's a path that the iOS Simulator uses.
David Farler
Comment 9
2014-06-10 14:19:17 PDT
(In reply to
comment #8
)
> (In reply to
comment #6
) > > (In reply to
comment #3
) > > > (From update of
attachment 232802
[details]
[details] [details]) > > > View in context:
https://bugs.webkit.org/attachment.cgi?id=232802&action=review
> > > > > > > Tools/Scripts/webkitdirs.pm:1122 > > > > + return "$ENV{HOME}/Library/Developer/CoreSimulator/Devices"; > > > > > > Should this be $ENV{CFFIXED_USER_HOME} instead? > > > > I'm not familiar with CFFIXED_USER_HOME - where is that defined? > > It's a path that the iOS Simulator uses.
Ah, no, the simulator device set are always drawn from the host user's home directory unless manually specified.
David Kilzer (:ddkilzer)
Comment 10
2014-06-10 14:23:19 PDT
Comment on
attachment 232811
[details]
Patch r=me
David Farler
Comment 11
2014-06-10 17:06:46 PDT
Committed
r169783
: <
http://trac.webkit.org/changeset/169783
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug