Kaynağa Gözat

Add reset option to automatic recorder

Daniel Gempesaw 11 yıl önce
ebeveyn
işleme
49af82c378
1 değiştirilmiş dosya ile 13 ekleme ve 5 silme
  1. 13 5
      t/bin/record.pl

+ 13 - 5
t/bin/record.pl

@@ -12,15 +12,19 @@ my $repo_root = abs_path($this_folder) . '/';
 reset_env();
 start_server();
 
-print 'Cleaning...and building...
-';
-print `cd $repo_root && dzil build`;
+my $built_lib = glob('Selenium-Remote-Driver-*/lib');
+if (not defined $built_lib) {
+    print ' Building a dist.';
+    print `cd $repo_root && dzil build`;
+}
+# If built_lib wasn't around in the first place, we'll have to glob
+# for it again.
+$built_lib = $repo_root . ($built_lib || glob('Selenium-Remote-Driver-*/lib'));
 
 if ($^O eq 'linux') {
     print "Headless and need a webdriver server started? Try\n\n\tDISPLAY=:1 xvfb-run --auto-servernum java -jar /usr/lib/node_modules/protractor/selenium/selenium-server-standalone-2.42.2.jar\n\n";
 }
 
-my $built_lib = $repo_root . glob('Selenium-Remote-Driver-*/lib');
 my $export = $^O eq 'MSWin32' ? 'set' : 'export';
 my $wait = $^O eq 'MSWin32' ? 'START /WAIT' : '';
 print `$export WD_MOCKING_RECORD=1 && cd $repo_root && prove -I$built_lib -rv t/`;
@@ -46,6 +50,10 @@ sub kill_server {
 
 
 sub reset_env {
-    `cd $repo_root && dzil clean`;
+    if (@ARGV && $ARGV[0] eq 'reset') {
+        print 'Cleaning. ';
+        `cd $repo_root && dzil clean`;
+    }
+    print 'Taking out any existing servers. ';
     kill_server();
 }