-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRoboFile.php
587 lines (502 loc) · 18.8 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
use Robo\Common\TaskIO;
use Robo\Output;
class RoboFile extends \Robo\Tasks
{
/**
* Displays the introduction, more information and welcome ascii art
*/
function info()
{
//Cat run/saucey.txt
$this->taskExec('cat ./bin/saucey.txt')
->run();
}
/**
* Starts apps/get.saucey.io in foreground at http://127.0.0.1:9987, kill with 'Control + C'
*/
public function serve()
{
//Serve .
$this->taskServer(8000)
->host('127.0.0.1')
->dir(".")
->run();
}
/**
* Initializes saucey project via Composer install/update, npm global installs, and copying over behat.yml from vendor/saucey/framework
*/
public function init()
{
//Install the dependancies/requirements through composer
$this->taskComposerInstall('./composer.phar')
->run();
//Update the dependancies/requirements through composer
$this->taskComposerUpdate('./composer.phar')
->run();
//Install Wienre globally via npm
$this->taskExec('sudo npm -g install weinre')
->run();
//Install PhantomJS globally via npm
$this->taskExec('sudo npm -g install phantomjs')
->run();
//Copy over behat.yml.master.dist to root as behat.yml
$this->taskExec('cp -r ./vendor/saucey/framework/ymls/behat.yml.master.dist ./behat.yml.master.dist')
->run();
//Copy over bin from vendor/saucey/framework
$this->taskExec('cp -R ./vendor/saucey/framework/bin/* ./bin/')
->run();
//Pull develop and master
$this->taskGitStack()
->pull('origin', 'master')
->pull('origin', 'develop')
->run();
//Make directory for reports
$this->taskFileSystemStack()
->mkdir('reports')
->mkdir('screenshots')
->mkdir('var/tasks')
->run();
//View saucey introduction
$this->taskExec('cat ./bin/saucey.txt')
->run();
}
/**
* Runs Composer update, refreshes bin/ and vendor/
*/
public function update()
{
//Update the dependancies/requirements through composer
$this->taskComposerUpdate('./composer.phar')
->run();
}
/**
* Starts Winery (Weinre) in foreground, at $host $port
*/
public function winery()
{
$host = $this->ask('What host?');
$port = $this->ask('What port?');
//Starts winery (weinre) in foreground, at $host $port
$this->taskExec("weinre --verbose true --debug true --boundHost {$host} --httpPort {$port}")
->run();
}
/**
* Starts Selenium for mac in foreground, at default http://localhost:4444/wd/hub/static/resource/hub.html
*/
public function seleniumStart()
{
//Starts Selenium
$this->taskExec('sh ./bin/start_selenium.sh')
->arg('mac')
->run();
}
/**
* Kills Selenium at default http://localhost:4444/wd/hub/static/resource/hub.html
*/
public function seleniumKill()
{
//Kills Selenium
$this->taskExec("open http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer")
->background()
->run();
}
/**
* Starts PhantomJS for mac in foreground, at default http://localhost:4444/wd/hub/static/resource/hub.html
*
* * @param int $port Port for PhantomJS
*/
public function phantomjs($port)
{
//Starts PhantomJS for mac
$this->taskExec("/usr/local/bin/phantomjs --webdriver={$port}")
->run();
}
/**
* Asks for and obtains $folder, $project, $feature, and $shortName. Makes directories, copies and touches files.
*
* @internal param string $folder
* @internal param string $project
* @internal param string $feature
* @internal param string $robo
*/
public function sauceyBundle()
{
/**
* @var string $folder
*/
$folder = $this->ask("Which folder will this test(s) reside in? [string]");
/**
* @var string $project
*/
$project = $this->ask("What is the name of the project? [string]");
/**
* @var string $feature
*/
$feature = $this->ask("What is the name of the feature file? [string]");
/**
* @var string $shortName
*/
$shortName = $this->ask("What is the short name for your robo function? [string]");
//Makes directories in feature/ and touches feature file
$this->taskFileSystemStack()
->mkdir("./features/{$folder}")
->mkdir("./features/{$folder}/{$project}")
->mkdir("./reports/{$folder}/{$project}")
->touch("./features/{$folder}/{$project}/{$feature}.feature")
->run();
//Copies over Reporting/Run scripts
$this->taskExec("sleep 10 && cp -R ./config/ ./features/{$folder}/{$project}/")
->run();
//Removes Services
$this->taskExec("rm -rf ./features/{$folder}/{$project}/service.json")
->run();
//Replaces items in Reporting.php
$this->taskReplaceInFile("./features/{$folder}/{$project}/Reporting.php")
->from('project')
->to($project)
->from('feature')
->to($feature)
->run();
//Replaces items in Run.sh
$this->taskReplaceInFile("./features/{$folder}/{$project}/Run.sh")
->from('function')
->to($shortName)
->run();
}
/**
* Asks for and obtains $project, $feature, and $number to update the Run.sh in feature directory. INIT, initializes script. RUN, runs script.
*
* @internal param string $folder
* @internal param string $project
* @internal param string $feature
* @internal param string $number
*/
public function sauceyOverdose()
{
$action = $this->ask("Would you like to init or run overdose? You have to init before running! [init | run]");
$folder = $this->ask("Which folder does the test live in? [string]");
$project = $this->ask("Which project? [string]");
$number = $this->ask("How many times do you want to run this test? [int]");
if ($action == 'init') {
//Replaces number value in Run.sh
$this->taskReplaceInFile("./features/{$folder}/{$project}/Run.sh")
->from('((n=0;n<1;n++))')
->to("((n=0;n<{$number};n++))")
->run();
}
if ($action == 'run') {
$confirm = $this->ask("Are you sure you want to run your suite {$number} times? [y | n]");
if ($confirm == 'y') {
//Confirm then run
$this->taskExec("sh ./features/{$folder}/{$project}/Run.sh")
->run();
}
if ($confirm == 'n') {
//Confirm
$this->taskExec("exit")
->run();
}
}
}
/**
* Asks and obtains $project, $feature, $browser and $isMetrics status to run Behat, Reporting, Weinre, Selenium and PhantomJS
*
* @internal param string $folder
* @internal param string $project
* @internal param string $feature
* @internal param string $isMetrics
*/
public function tipsyTest()
{
$project = $this->ask("What is the name of the parent folder in which this test resides? [string]");
$feature = $this->ask("What is the '@tag' for feature? [string -- without '@']");
$browser = $this->ask("Which browser is this to be test this in? [string]");
$isMetrics = $this->ask("Is metrics testing involved? [y | n]");
//Starts PhantomJS
$this->taskExec("/usr/local/bin/phantomjs --webdriver=8643")
->background()
->run();
//Starts Selenium
$this->taskExec("sh ./run/start_selenium.sh mac")
->background()
->run();
//Starts drivers, tests in parallel
if ($isMetrics == 'y') {
$metrics = $this->ask("What is the '@tag' for metrics? [string]");
$host = $this->ask("What host? [string]");
$port = $this->ask("What port? [string]");
//Starts Winery
$this->taskExec("weinre --verbose true --debug true --boundHost {$host} --httpPort {$port}")
->background()
->run();
//Starts tests in parallel
$this->taskParallelExec()
->process("sh ./run/saucey.sh tipsy '{$metrics} chrome'")
->process("sh ./run/saucey.sh tipsy '{$feature} {$browser}'")
->idleTimeout(10)
->run();
$this->taskExec("open http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer")
->background()
->run();
$this->taskExec("mv ./reports/saucey_report.html ./reports/{$project}/{$feature}.html")
->background()
->idleTimeout(10)
->run();
$this->taskExec("php ./feature/{$project}/{$feature}/Reporting.php")
->background()
->idleTimeout(10)
->run();
}
if ($isMetrics == 'n') {
$this->taskParallelExec()
//->process('sh ./run/start_selenium.sh mac')
->process("sh ./run/saucey.sh tipsy '{$feature} {$browser}'")
->idleTimeout(10)
->run();
$this->taskExec("open http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer")
->background()
->run();
$this->taskExec("mv ./reports/saucey_report.html ./reports/{$project}/{$feature}.html")
->background()
->idleTimeout(10)
->run();
$this->taskExec("php ./feature/{$project}/{$feature}/Reporting.php")
->background()
->idleTimeout(10)
->run();
}
}
/**
* Asks and obtains $project, $feature, $env and $browser to run Behat, Reporting and SauceLabs
*
* @internal param string $folder
* @internal param string $project
* @internal param string $env
* @internal param string $browser
*/
public function drunkTest()
{
$project = $this->ask("What is the name of the parent folder in which this test resides? [string]");
$feature = $this->ask("What is the '@tag' for feature? [string -- without '@']");
$env = $this->ask("What environment is this to be test this on? [string]");
$browser = $this->ask("Which browser is this to be test this in? [string]");
//Starts tests in parallel
$this->taskParallelExec()
->process("sh ./run/saucey.sh drunk '{$feature} {$env} {$browser}'")
->idleTimeout(10)
->run();
$this->taskExec("mv ./reports/saucey_report.html ./reports/{$project}/{$feature}.html")
->background()
->idleTimeout(10)
->run();
$this->taskExec("php ./feature/{$project}/{$feature}/Reporting.php")
->background()
->idleTimeout(10)
->run();
}
/**
* Connects instance of sauce_connect to SauceLabs API, requires api_key and username
*
* @internal param string $un
* @internal param string $key
*/
public function sauceyConnect()
{
$un = $this->ask("What is your username?");
$key = $this->ask("What is your api-key?");
$unkey = "{$un}:{$key}";
$un_key = "{$un} {$key}";
$this->taskReplaceInFile('./vendor/saucey/framework/ymls/behat.yml.master.dist')
->from('username:api-key')
->to($unkey)
->run();
$this->taskReplaceInFile('./behat.yml')
->from('username:api-key')
->to($unkey)
->run();
$this->taskExec('./bin/sauce_config')
->arg($un_key)
->run();
}
/**
* Starts a Sauce Tunnel, allowing testing on the local host against hosted selenium, with all SauceLabs functions
*
* @internal param string $un
* @internal param string $key
*/
public function sauceyTunnel()
{
$un = $this->ask("What is your username?");
$key = $this->ask("What is your api-key?");
$un_key = "{$un} {$key}";
$this->taskExec('./vendor/sauce/connect/bin/sauce_connect')
->arg($un_key)
->run();
}
/**
* For saucey developers, push and pull from framework GitHub with this task command
*
* @internal param string $un
* @internal param string $key
*/
public function sauceyShove($msg)
{
//Copy over development yaml
$this->taskExec('cp -r ./behat.yml vendor/saucey/framework/ymls/behat.yml.master.dist')
->run();
//Pull from remotes for saucey
$this->taskGitStack()
->dir('.')
->pull('origin', 'master')
->pull('origin', 'develop')
->run();
//Push to remotes for saucey
$this->taskGitStack()
->dir('.')
->add('-A')
->commit($msg)
->push('origin', 'develop')
->run();
}
# ADCADE TASKS
/**
* Tests against campaign: tor_fragrance_2015
*/
public function adcadeCampaign()
{
// Tests Metrics by testing the app locally and verifying metrics locally
$this->taskParallelExec()
->process('./bin/behat --tags "@Regression_TOR_Fragrance_APR15"')
->process('./bin/behat --tags "@Regression_TOR_Fragrance_APR15_Metrics" -p local_chrome')
->printed(true)
->run();
// Tests against ie8 for Backup image
$this->taskExec('./bin/behat --tags "@IE_Backup_TOR_Fragrance_APR15" -p sauce_windows_ie8')
->printed(true)
->run();
// Tests against Windows Chrome
$this->taskExec('./bin/behat --tags "@Compatibility_TOR_Fragrance_APR15" -p sauce_windows_chrome')
->printed(true)
->run();
// Tests against i
$this->taskExec('./bin/behat --tags "@IE_Backup_TOR_Fragrance_APR15" -p sauce_windows_ie8')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@Compatibility_TOR_Fragrance_APR15" -p sauce_windows_chrome')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@Compatibility_TOR_Fragrance_APR15" -p sauce_windows_firefox')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@Compatibility_TOR_Fragrance_APR15" -p sauce_mac_safari')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@Compatibility_TOR_Fragrance_APR15" -p sauce_mac_chrome')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@TOR_Fragrance_1032x1100_Tablet" -p sauce_ios_tablet_landscape')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@TOR_Fragrance_1032x1100_Tablet" -p sauce_android_tablet_landscape')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@TOR_Fragrance_1032x1100_Tablet" -p sauce_ios_tablet')
->printed(true)
->run();
$this->taskExec('./bin/behat --tags "@TOR_Fragrance_1032x1100_Tablet" -p sauce_android_tablet')
->printed(true)
->run();
}
/**
* Tests against ADSCR-726, tnbr_pushdown_marquee
*/
public function adcadeADSCR726()
{
// Tests Metrics by testing the app locally and verifying metrics locally
$this->taskParallelExec()
->process('./bin/behat --tags "@ADSCR_726_Desktop" -p local_chrome && sleep 3')
->process('./bin/behat --tags "@ADSCR_726_Desktop_Metrics" -p local_chrome')
->printed(true)
->run();
// Moves file over and renames with timestamp
$this->taskExec('php ./features/adcade/ADSCR_726/Reporting.php')
->run();
}
/**
* Runs ADSCR-726 suite +10,000 times
*/
public function adcadeADSCR726Overdose()
{
// Runs overdose.sh for ADSCR_726
$this->taskExec('sh ./features/adcade/ADSCR_726/Run.sh')
->printed(true)
->run();
}
/**
* Tests HelpCenter against local browsers
*/
public function adcadeHelpCenterLocal()
{
// Tests HelpCenter Locally
$this->taskExec('./bin/behat --suite=help_center')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
}
/**
* Tests HelpCenter against SauceLabs browsers and environments
*/
public function adcadeHelpCenterCloud()
{
// Tests HelpCenter against Mac, Chrome
$this->taskExec('./bin/behat --suite=help_center -p sauce_mac_chrome')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
// Tests HelpCenter against Mac, Safari
$this->taskExec('./bin/behat --suite=help_center -p sauce_mac_safari')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
// Tests HelpCenter against Windows, IE9
$this->taskExec('./bin/behat --suite=help_center -p sauce_windows_ie9')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
// Tests HelpCenter against Windows, Firefox
$this->taskExec('./bin/behat --suite=help_center -p sauce_windows_firefox')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
// Tests HelpCenter against iOS, Safari, Landscape
$this->taskExec('./bin/behat --suite=help_center -p sauce_ios_tablet_landscape')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
// Tests HelpCenter against Android, Native, Landscape
$this->taskExec('./bin/behat --suite=help_center -p sauce_android_tablet_landscape')
->printed(true)
->run();
// Moves Report
$this->taskExec('php ./features/adcade/Help_Center/Reporting.php')
->run();
}
}