learn-test 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/learn-test +1 -1
- data/lib/learn_test.rb +2 -0
- data/lib/learn_test/dependencies/csharp.rb +22 -0
- data/lib/learn_test/repo_parser.rb +1 -1
- data/lib/learn_test/runner.rb +6 -1
- data/lib/learn_test/strategies/csharp_nunit.rb +53 -0
- data/lib/learn_test/strategies/mocha.rb +12 -6
- data/lib/learn_test/strategy.rb +19 -12
- data/lib/learn_test/version.rb +1 -1
- data/spec/lib/learn_test/strategies/mocha_spec.rb +60 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45c494858f664acb5872e93ee1b961b5bf11338
|
4
|
+
data.tar.gz: 0e9baa5e5ae7cbeeddca89f031d8e2bf44d361ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea657a5625131a18b24a6a5a602926f650b14198428b46630ae2d371cdca8c245d7c81e9cd35bde271caff13adc716ffd78b4a3472bc0f35442b774e6810fe25
|
7
|
+
data.tar.gz: 9af6b3551aa357358c360861f66990e50710df8c7f620700144b41368525faf54df50e1caba592acd325849f44ea6bb59c6687f8410771b7027ea23ff72a3384
|
data/bin/learn-test
CHANGED
data/lib/learn_test.rb
CHANGED
@@ -19,6 +19,7 @@ require_relative 'learn_test/dependencies/phantomjs'
|
|
19
19
|
require_relative 'learn_test/dependencies/karma'
|
20
20
|
require_relative 'learn_test/dependencies/protractor'
|
21
21
|
require_relative 'learn_test/dependencies/java'
|
22
|
+
require_relative 'learn_test/dependencies/csharp'
|
22
23
|
require_relative 'learn_test/dependencies/ant'
|
23
24
|
require_relative 'learn_test/dependencies/imagemagick'
|
24
25
|
require_relative 'learn_test/dependencies/selenium_server'
|
@@ -32,6 +33,7 @@ require_relative 'learn_test/strategies/rspec'
|
|
32
33
|
require_relative 'learn_test/strategies/karma'
|
33
34
|
require_relative 'learn_test/strategies/protractor'
|
34
35
|
require_relative 'learn_test/strategies/java_junit'
|
36
|
+
require_relative 'learn_test/strategies/csharp_nunit'
|
35
37
|
require_relative 'learn_test/strategies/mocha'
|
36
38
|
require_relative 'learn_test/strategies/green_onion'
|
37
39
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module LearnTest
|
2
|
+
module Dependencies
|
3
|
+
class CSharp < LearnTest::Dependency
|
4
|
+
def missing?
|
5
|
+
if win?
|
6
|
+
`where dotnet`.empty?
|
7
|
+
else
|
8
|
+
`which dotnet`.empty?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def install
|
13
|
+
die("Please install the .NET core from https://www.microsoft.com/net/core")
|
14
|
+
end
|
15
|
+
|
16
|
+
def die(message)
|
17
|
+
puts message
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -11,7 +11,7 @@ module LearnTest
|
|
11
11
|
end
|
12
12
|
|
13
13
|
if url = repo.remote.url
|
14
|
-
url.match(/(?:https
|
14
|
+
url.match(/(?:https?:\/\/|git@).*\/(.+?)(?:\.git)?$/)[1]
|
15
15
|
else
|
16
16
|
puts "You don't appear to be in a Learn lesson's directory. Please cd to an appropriate directory and try again."
|
17
17
|
die
|
data/lib/learn_test/runner.rb
CHANGED
@@ -15,7 +15,7 @@ module LearnTest
|
|
15
15
|
strategy.check_dependencies
|
16
16
|
strategy.configure
|
17
17
|
strategy.run
|
18
|
-
if !help_option_present? && strategy.push_results?
|
18
|
+
if !help_option_present? && strategy.push_results? && !local_test_run?
|
19
19
|
push_results(strategy)
|
20
20
|
end
|
21
21
|
strategy.cleanup unless keep_results?
|
@@ -53,6 +53,7 @@ module LearnTest
|
|
53
53
|
|
54
54
|
def strategies
|
55
55
|
[
|
56
|
+
LearnTest::Strategies::CSharpNunit,
|
56
57
|
LearnTest::Strategies::Jasmine,
|
57
58
|
LearnTest::Strategies::GreenOnion,
|
58
59
|
LearnTest::Strategies::Rspec,
|
@@ -83,6 +84,10 @@ module LearnTest
|
|
83
84
|
options.include?('-h') || options.include?('--help')
|
84
85
|
end
|
85
86
|
|
87
|
+
def local_test_run?
|
88
|
+
options.include?('-h') || options.include?('--local')
|
89
|
+
end
|
90
|
+
|
86
91
|
def die
|
87
92
|
puts "This directory doesn't appear to have any specs in it."
|
88
93
|
exit
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'crack'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module LearnTest
|
5
|
+
module Strategies
|
6
|
+
class CSharpNunit < LearnTest::Strategy
|
7
|
+
def service_endpoint
|
8
|
+
'/e/flatiron_csharp_nunit'
|
9
|
+
end
|
10
|
+
|
11
|
+
def detect
|
12
|
+
runner.files.any? {|f| f.match(/project.json/)}
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_dependencies
|
16
|
+
Dependencies::CSharp.new.execute
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
system("dotnet test")
|
21
|
+
output
|
22
|
+
cleanup
|
23
|
+
end
|
24
|
+
|
25
|
+
def output
|
26
|
+
@output ||= Crack::XML.parse(File.read('TestResult.xml'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def results
|
30
|
+
{
|
31
|
+
username: username,
|
32
|
+
github_user_id: user_id,
|
33
|
+
repo_name: runner.repo,
|
34
|
+
build: {
|
35
|
+
test_suite: [{
|
36
|
+
framework: 'nunit',
|
37
|
+
formatted_output: output.to_json,
|
38
|
+
duration: output['test_run']['duration']
|
39
|
+
}]
|
40
|
+
},
|
41
|
+
examples: output['test_run']['total'],
|
42
|
+
passing_count: output['test_run']['passed'],
|
43
|
+
pending_count: output['test_run']['skipped'],
|
44
|
+
failure_count: output['test_run']['failed'],
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def cleanup
|
49
|
+
FileUtils.rm("TestResult.xml") if File.exist?("TestResult.xml")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -59,12 +59,20 @@ module LearnTest
|
|
59
59
|
FileUtils.rm('.results.json') if File.exist?('.results.json')
|
60
60
|
end
|
61
61
|
|
62
|
+
def missing_dependencies?(package)
|
63
|
+
return true if !File.exists?("node_modules")
|
64
|
+
|
65
|
+
[:dependencies, :devDependencies, :peerDependencies].any? do |d|
|
66
|
+
(package[d] || {}).any? { |p, v| !File.exists?("node_modules/#{p}") }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
62
70
|
private
|
63
71
|
|
64
72
|
def run_mocha
|
65
73
|
package = Oj.load(File.read('package.json'), symbol_keys: true)
|
66
74
|
|
67
|
-
npm_install
|
75
|
+
npm_install(package)
|
68
76
|
|
69
77
|
command = if (package[:scripts] && package[:scripts][:test] || "").include?(".results.json")
|
70
78
|
"npm test"
|
@@ -78,14 +86,12 @@ module LearnTest
|
|
78
86
|
|
79
87
|
def install_mocha_multi
|
80
88
|
if !File.exists?('node_modules/mocha-multi')
|
81
|
-
run_install('npm install mocha-multi')
|
89
|
+
run_install('npm install mocha-multi', npm_install: true)
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
85
|
-
def npm_install
|
86
|
-
if
|
87
|
-
run_install('npm install')
|
88
|
-
end
|
93
|
+
def npm_install(package)
|
94
|
+
run_install('npm install', npm_install: true) if missing_dependencies?(package)
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
data/lib/learn_test/strategy.rb
CHANGED
@@ -57,18 +57,25 @@ module LearnTest
|
|
57
57
|
exit
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
60
|
+
##
|
61
|
+
# npm_install option added to fix the proxying of the npm install progress
|
62
|
+
# bar output.
|
63
|
+
def run_install(command, npm_install: false)
|
64
|
+
if npm_install
|
65
|
+
system(command)
|
66
|
+
else
|
67
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
68
|
+
while out = stdout.gets do
|
69
|
+
puts out
|
70
|
+
end
|
71
|
+
|
72
|
+
while err = stderr.gets do
|
73
|
+
puts err
|
74
|
+
end
|
75
|
+
|
76
|
+
if wait_thr.value.exitstatus != 0
|
77
|
+
die("There was an error running #{command}")
|
78
|
+
end
|
72
79
|
end
|
73
80
|
end
|
74
81
|
end
|
data/lib/learn_test/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
describe LearnTest::Strategies::Mocha do
|
2
|
+
describe '#missing_dependencies?' do
|
3
|
+
let(:package) do
|
4
|
+
{
|
5
|
+
dependencies: {
|
6
|
+
dep1: "",
|
7
|
+
dep2: ""
|
8
|
+
},
|
9
|
+
devDependencies: {
|
10
|
+
devDep1: "",
|
11
|
+
devDep2: ""
|
12
|
+
},
|
13
|
+
peerDependencies: {
|
14
|
+
peerDep1: "",
|
15
|
+
peerDep2: ""
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
let(:runner) { double("Runner", options: {}) }
|
20
|
+
let(:strategy) { LearnTest::Strategies::Mocha.new(runner) }
|
21
|
+
|
22
|
+
it "returns true if no node_modules directory" do
|
23
|
+
expect(File).to receive(:exists?).with("node_modules") { false }
|
24
|
+
|
25
|
+
expect(strategy.missing_dependencies?(package)).to eq(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "node_modules exists" do
|
29
|
+
before(:each) do
|
30
|
+
allow(File).to receive(:exists?) { true }
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns true if missing a dependency" do
|
34
|
+
expect(File).to receive(:exists?).with("node_modules/dep1") { true }
|
35
|
+
expect(File).to receive(:exists?).with("node_modules/dep2") { false }
|
36
|
+
expect(strategy.missing_dependencies?(package)).to eq(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns true if missing a devDependency" do
|
40
|
+
expect(File).to receive(:exists?).with("node_modules/devDep1") { true }
|
41
|
+
expect(File).to receive(:exists?).with("node_modules/devDep2") { false }
|
42
|
+
expect(strategy.missing_dependencies?(package)).to eq(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns true if missing a peerDependency" do
|
46
|
+
expect(File).to receive(:exists?).with("node_modules/peerDep1") { true }
|
47
|
+
expect(File).to receive(:exists?).with("node_modules/peerDep2") { false }
|
48
|
+
expect(strategy.missing_dependencies?(package)).to eq(true)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns false if missing no dependencies" do
|
52
|
+
expect(strategy.missing_dependencies?(package)).to eq(false)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns false if there are no dependencies" do
|
56
|
+
expect(strategy.missing_dependencies?({})).to eq(false)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- learn-test.gemspec
|
211
211
|
- lib/learn_test.rb
|
212
212
|
- lib/learn_test/dependencies/ant.rb
|
213
|
+
- lib/learn_test/dependencies/csharp.rb
|
213
214
|
- lib/learn_test/dependencies/firefox.rb
|
214
215
|
- lib/learn_test/dependencies/green_onion.rb
|
215
216
|
- lib/learn_test/dependencies/imagemagick.rb
|
@@ -226,6 +227,7 @@ files:
|
|
226
227
|
- lib/learn_test/netrc_interactor.rb
|
227
228
|
- lib/learn_test/repo_parser.rb
|
228
229
|
- lib/learn_test/runner.rb
|
230
|
+
- lib/learn_test/strategies/csharp_nunit.rb
|
229
231
|
- lib/learn_test/strategies/green_onion.rb
|
230
232
|
- lib/learn_test/strategies/jasmine.rb
|
231
233
|
- lib/learn_test/strategies/jasmine/boot.js
|
@@ -274,6 +276,7 @@ files:
|
|
274
276
|
- spec/fixtures/rspec-unit-spec/lib/dog.rb
|
275
277
|
- spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
|
276
278
|
- spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
|
279
|
+
- spec/lib/learn_test/strategies/mocha_spec.rb
|
277
280
|
- spec/repo_parser_spec.rb
|
278
281
|
- spec/spec_helper.rb
|
279
282
|
homepage: https://github.com/learn-co/learn-test
|
@@ -297,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
300
|
version: '0'
|
298
301
|
requirements: []
|
299
302
|
rubyforge_project:
|
300
|
-
rubygems_version: 2.
|
303
|
+
rubygems_version: 2.6.6
|
301
304
|
signing_key:
|
302
305
|
specification_version: 4
|
303
306
|
summary: Runs RSpec, Jasmine, and Python Unit Test builds and pushes JSON output to
|
@@ -312,5 +315,6 @@ test_files:
|
|
312
315
|
- spec/fixtures/rspec-unit-spec/lib/dog.rb
|
313
316
|
- spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
|
314
317
|
- spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
|
318
|
+
- spec/lib/learn_test/strategies/mocha_spec.rb
|
315
319
|
- spec/repo_parser_spec.rb
|
316
320
|
- spec/spec_helper.rb
|