learn-test 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25c5bde7cfc34f3b0a9f3001786b835a649065c9
4
- data.tar.gz: 57f5fc7fa37b7ef4b6fd9344a37b970e0a332fb7
3
+ metadata.gz: d7a9b83439ba2bcc56e12b97b75f4b70a14ce9f0
4
+ data.tar.gz: f2d82adedacd4eda7ddb905eb37c08b568cbc44d
5
5
  SHA512:
6
- metadata.gz: 7223234c5351485d9cbc2c4692d707f0f58bec9730f5d0b9838b1919fd8003d722026fe08c2bd77e378042898ee9ca9b0498191e34bdd79f9deb2424368fa871
7
- data.tar.gz: 518c57425c6573cae03eb22d54058ed67235aaba3da5f6aac68b7aab7bb040235448735829ffeeb62a81cc341384fb176eaaa5ea70dd2789a33e8bb0318a7d85
6
+ metadata.gz: c0b30f556c64e9032a497bba4010b36024d58576777acf3f6383cf9398187f0beee0d450cd11ca1b4626bee085b022dab7744b6baf2eb5cd23d3506d2cb086af
7
+ data.tar.gz: d6ea1db7591ad07dce13e4a0db2124d346c9b49b3ad72a3e255ac0bfb8ab327bfdc971fbbde222643529c9c206843d2deaa821c6ed9239dbadf77f9a2ccfde97
@@ -15,8 +15,8 @@ module LearnTest
15
15
  strategy.run
16
16
  if !help_option_present? && strategy.push_results?
17
17
  push_results(strategy)
18
- strategy.cleanup unless keep_results?
19
18
  end
19
+ strategy.cleanup unless keep_results?
20
20
  end
21
21
 
22
22
  def files
@@ -15,25 +15,11 @@ module LearnTest
15
15
  end
16
16
 
17
17
  def run
18
- karma_config = LearnTest::FileFinder.location_to_dir('strategies/karma/karma.conf.js')
19
-
20
- Open3.popen3("karma start #{karma_config}") do |stdin, stdout, stderr, wait_thr|
21
- while out = stdout.gets do
22
- puts out
23
- end
24
-
25
- while err = stderr.gets do
26
- if err.include?('Cannot find local Karma!')
27
- @missing_karma = true
28
- end
29
- puts err
30
- end
31
-
32
- if wait_thr.value.exitstatus != 0
33
- if @missing_karma
34
- die("You appear to be missing karma in your local node modules. Try running `npm install`.\nIf the issue persists, check if karma is specified as a dependency in the package.json.")
35
- end
36
- end
18
+ run_karma
19
+ if @missing_karma
20
+ puts "Installing local karma dependencies...".green
21
+ run_install('npm install')
22
+ run_karma
37
23
  end
38
24
  end
39
25
 
@@ -62,6 +48,29 @@ module LearnTest
62
48
  def cleanup
63
49
  FileUtils.rm('.results.json') if File.exist?('.results.json')
64
50
  end
51
+
52
+ private
53
+
54
+ def run_karma
55
+ karma_config = LearnTest::FileFinder.location_to_dir('strategies/karma/karma.conf.js')
56
+ Open3.popen3("karma start #{karma_config}") do |stdin, stdout, stderr, wait_thr|
57
+ while out = stdout.gets do
58
+ puts out
59
+ end
60
+
61
+ while err = stderr.gets do
62
+ if err.include?('Cannot find local Karma!')
63
+ die_missing_local_karma if @missing_karma
64
+ @missing_karma = true
65
+ end
66
+ puts err
67
+ end
68
+ end
69
+ end
70
+
71
+ def die_missing_local_karma
72
+ die("You appear to be missing karma in your local node modules. Try running `npm install`.\nIf the issue persists, make sure karma is specified as a dependency in the package.json")
73
+ end
65
74
  end
66
75
  end
67
76
  end
@@ -17,6 +17,23 @@ module LearnTest
17
17
  end
18
18
 
19
19
  def run
20
+ if !selenium_running?
21
+ stdin, stdout, stderr, wait_thr = Open3.popen3('webdriver-manager start')
22
+ @pid = wait_thr.pid
23
+
24
+ @server_started = false
25
+
26
+ while !@server_started && line = stderr.gets do
27
+ puts line
28
+ if line.include?('Selenium Server is up and running')
29
+ @server_started = true
30
+ stdin.close
31
+ stdout.close
32
+ stderr.close
33
+ end
34
+ end
35
+ end
36
+
20
37
  Open3.popen3('protractor conf.js --resultJsonOutputFile .results.json') do |stdin, stdout, stderr, wait_thr|
21
38
  while line = stdout.gets do
22
39
  if line.include?('Error: Cannot find module')
@@ -26,22 +43,18 @@ module LearnTest
26
43
  end
27
44
 
28
45
  while stderr_line = stderr.gets do
29
- if stderr_line.include?('ECONNREFUSED')
30
- @webdriver_not_running = true
31
- end
32
46
  puts stderr_line
33
47
  end
34
48
 
35
49
  if wait_thr.value.exitstatus != 0
36
- if @webdriver_not_running
37
- die('Webdriver manager does not appear to be running. Run `webdriver-manager start` to start it.')
38
- end
39
-
40
50
  if @modules_missing
41
51
  die("You appear to be missing npm dependencies. Try running `npm install`\nIf the issue persists, check the package.json")
42
52
  end
43
53
  end
44
54
  end
55
+
56
+ safe_kill(@pid)
57
+ safe_kill(@selenium_pid) if selenium_running?
45
58
  end
46
59
 
47
60
  def output
@@ -91,6 +104,23 @@ module LearnTest
91
104
  count += test[:duration]
92
105
  end
93
106
  end
107
+
108
+ def safe_kill(pid)
109
+ begin
110
+ Process.kill('HUP', pid)
111
+ rescue
112
+ end
113
+ end
114
+
115
+ def selenium_running?
116
+ process = `ps aux | grep selenium`.split("\n").detect{ |p| p.include?('chromedriver') }
117
+ if process
118
+ @selenium_pid = process.split[1].to_i
119
+ return true
120
+ end
121
+ return false
122
+ end
123
+
94
124
  end
95
125
  end
96
126
  end
@@ -52,5 +52,21 @@ module LearnTest
52
52
  puts message.red
53
53
  exit
54
54
  end
55
+
56
+ def run_install(command)
57
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
58
+ while out = stdout.gets do
59
+ puts out
60
+ end
61
+
62
+ while err = stderr.gets do
63
+ puts err
64
+ end
65
+
66
+ if wait_thr.value.exitstatus != 0
67
+ die("There was an error running #{command}")
68
+ end
69
+ end
70
+ end
55
71
  end
56
72
  end
@@ -1,3 +1,3 @@
1
1
  module LearnTest
2
- VERSION = '2.0.0.rc1'
2
+ VERSION = '2.0.0.rc2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler