learn-test 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abd382c4de1233fe1c72ba3933f59ddc361a07a6
4
- data.tar.gz: d90c0b51e75a8ed6c84ee36c4588834712d2d191
3
+ metadata.gz: 4d8e6eb7a48f5fe1b9c4506cd41db28f23ca8a09
4
+ data.tar.gz: 8b43a51699975858494ef64ef0a282e4422ccb31
5
5
  SHA512:
6
- metadata.gz: c825c369af9290b56616a58d327ad8876ad6357d60bcb2986a0120d69957c257acabb7d2202ef3db2c55975f10f0694891ec5a8b07e4881cdfafeff6367815e1
7
- data.tar.gz: d58792529831e1361c4307be560bd9c31cb6048cc33447c5ca5c7bf90c04590eed5d0fafcf3d8b36afed3d45f03cd44df53ede12ed04945a81ee512d801de01d
6
+ metadata.gz: 180f0bf382c18299922e7797e6b63c27d0a919619ad8da028ae481dc2bec04aeb9cea14677fd85b22eb2d9fdab42da225fd5b9821c7b816d587a4423c1b1d610
7
+ data.tar.gz: f5874d0523b0a31bfdf2326ed5972e4d675b6e833bbef53213f5d523225e59b825edc135214c65caaf45d6a69dde8e478988c66cd56f27d4ef30a3694ae59841
@@ -2,15 +2,23 @@ module LearnTest
2
2
  module Dependencies
3
3
  class Ant < LearnTest::Dependency
4
4
  def missing?
5
- `which ant`.empty?
5
+ if win?
6
+ `where ant`.empty?
7
+ else
8
+ `which ant`.empty?
9
+ end
6
10
  end
7
11
 
8
12
  def install
9
- puts('Checking for homebrew...'.green)
10
- die('You must have Homebrew installed') unless brew_installed?
11
- puts('Updating brew...'.green)
12
- print_installing('ant')
13
- run_install('brew install ant')
13
+ if win? || !mac?
14
+ die('Please install Ant.')
15
+ else
16
+ puts('Checking for homebrew...'.green)
17
+ die('You must have Homebrew installed') unless brew_installed?
18
+ puts('Updating brew...'.green)
19
+ print_installing('ant')
20
+ run_install('brew install ant')
21
+ end
14
22
  end
15
23
 
16
24
  private
@@ -2,7 +2,11 @@ module LearnTest
2
2
  module Dependencies
3
3
  class Java < LearnTest::Dependency
4
4
  def missing?
5
- `which java`.empty?
5
+ if win?
6
+ `where java`.empty?
7
+ else
8
+ `which java`.empty?
9
+ end
6
10
  end
7
11
 
8
12
  def install
@@ -24,6 +24,10 @@ module LearnTest
24
24
  !!RUBY_PLATFORM.match(/darwin/)
25
25
  end
26
26
 
27
+ def win?
28
+ !!RUBY_PLATFORM.match(/mswin|mingw|cygwin/)
29
+ end
30
+
27
31
  def print_installing(name)
28
32
  puts "Installing missing dependency #{name}...".green
29
33
  end
@@ -1,7 +1,7 @@
1
1
  module LearnTest
2
2
  class Runner
3
3
  attr_reader :repo, :options
4
- SERVICE_URL = 'http://ironbroker07.fe.flatironschool.com'
4
+ SERVICE_URL = 'http://ironbroker-v2.flatironschool.com'
5
5
 
6
6
  def initialize(repo, options = {})
7
7
  @repo = repo
@@ -41,8 +41,8 @@ module LearnTest
41
41
 
42
42
  def strategies
43
43
  [
44
- LearnTest::Strategies::Rspec,
45
44
  LearnTest::Strategies::Jasmine,
45
+ LearnTest::Strategies::Rspec,
46
46
  LearnTest::Strategies::Karma,
47
47
  LearnTest::Strategies::Protractor,
48
48
  LearnTest::Strategies::JavaJunit,
@@ -18,6 +18,7 @@ module LearnTest
18
18
  end
19
19
 
20
20
  def run
21
+ clean_old_results
21
22
  run_ant
22
23
  make_json
23
24
  end
@@ -46,8 +47,16 @@ module LearnTest
46
47
 
47
48
  private
48
49
 
50
+ def clean_old_results
51
+ if Dir.entries(lab_dir).any? { |f| f == 'junit' }
52
+ system("rm -rf #{lab_dir}/junit")
53
+ end
54
+ end
55
+
49
56
  def run_ant
50
- system('ant test -buildfile javacs*/build.xml')
57
+ javacs_dir = Dir.entries('.').detect { |f| !!f.match(/javacs/) }
58
+
59
+ system("ant clean -buildfile #{javacs_dir}/build.xml && ant build -buildfile #{javacs_dir}/build.xml && ant test -buildfile #{javacs_dir}/build.xml")
51
60
  end
52
61
 
53
62
  def test_path
@@ -55,28 +64,36 @@ module LearnTest
55
64
  end
56
65
 
57
66
  def lab_dir
58
- @lab_dir ||= Dir.entries('.').detect {|f| f.match(/^javacs\-lab\d+$/)}
67
+ @lab_dir ||= Dir.entries('.').detect { |f| f.match(/^javacs\-lab\d+$/) }
59
68
  end
60
69
 
61
70
  def make_json
62
- test_xml_files.each do |f|
63
- parsed = JSON.parse(Crack::XML.parse(File.read(f)).to_json)['testsuite']
64
- next if !parsed
65
-
66
- parsed['testcase'].each do |test_case|
67
- results[:build][:test_suite][0][:formatted_output] << test_case
71
+ if File.exists?(test_path)
72
+ test_xml_files.each do |f|
73
+ parsed = JSON.parse(Crack::XML.parse(File.read(f)).to_json)['testsuite']
74
+ next if !parsed
75
+
76
+ if parsed['testcase']
77
+ parsed['testcase'].each do |test_case|
78
+ results[:build][:test_suite][0][:formatted_output] << test_case
79
+ end
80
+ end
81
+
82
+ test_count = parsed['tests'].to_i
83
+ skipped_count = parsed['skipped'].to_i
84
+ error_count = parsed['errors'].to_i
85
+ failure_count = parsed['failures'].to_i
86
+ duration = parsed['time'].to_f
87
+
88
+ results[:examples] += test_count
89
+ results[:passing_count] += (test_count - skipped_count - error_count - failure_count)
90
+ results[:failure_count] += (error_count + failure_count)
91
+ results[:build][:test_suite][0][:duration] = duration
68
92
  end
69
-
70
- test_count = parsed['tests'].to_i
71
- skipped_count = parsed['skipped'].to_i
72
- error_count = parsed['errors'].to_i
73
- failure_count = parsed['failures'].to_i
74
- duration = parsed['time'].to_f
75
-
76
- results[:examples] += test_count
77
- results[:passing_count] += (test_count - skipped_count - error_count - failure_count)
78
- results[:failure_count] += (error_count + failure_count)
79
- results[:build][:test_suite][0][:duration] = duration
93
+ else
94
+ results[:examples] = 1
95
+ results[:failure_count] = 1
96
+ results[:passing_count] = 0
80
97
  end
81
98
 
82
99
  if runner.keep_results?
@@ -29,8 +29,7 @@ module LearnTest
29
29
  end
30
30
 
31
31
  def run
32
- run_install('npm install')
33
- run_install('npm install mocha-multi')
32
+ install_mocha_multi
34
33
  run_mocha
35
34
  end
36
35
 
@@ -65,6 +64,12 @@ module LearnTest
65
64
  def run_mocha
66
65
  system("multi='json=.results.json spec=-' node_modules/mocha/bin/mocha test -R mocha-multi")
67
66
  end
67
+
68
+ def install_mocha_multi
69
+ if !File.exists?('node_modules/mocha-multi')
70
+ run_install('npm install mocha-multi')
71
+ end
72
+ end
68
73
  end
69
74
  end
70
75
  end
@@ -1,3 +1,3 @@
1
1
  module LearnTest
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School