learn-test 1.2.26 → 2.0.0.pre
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 +37 -63
- data/lib/learn_test.rb +12 -18
- data/lib/learn_test/runner.rb +71 -0
- data/lib/learn_test/strategies/jasmine.rb +153 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/boot.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/console.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/formatters/jasmine2-junit.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/helpers/ConsoleHelper.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/helpers/ConsoleHelperNoColor.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/initializer.rb +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jasmine-html.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jasmine-jquery.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jasmine.css +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jasmine.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jasmine_favicon.png +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jquery-1.8.0.min.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/jquery-ui-1.8.23.custom.min.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/phantom_checker.rb +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/runners/SpecRunner.html +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/runners/run-jasmine.js +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/templates/SpecRunnerTemplate.html.erb +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/templates/SpecRunnerTemplateNoColor.html.erb +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/templates/requires.yml.example +0 -0
- data/lib/learn_test/{jasmine → strategies/jasmine}/vendor/require.js +0 -0
- data/lib/learn_test/strategies/python_unittest.rb +67 -0
- data/lib/learn_test/{python_unittest → strategies/python_unittest}/nose_installer.rb +1 -1
- data/lib/learn_test/{python_unittest → strategies/python_unittest}/requirements_checker.rb +0 -0
- data/lib/learn_test/strategies/rspec.rb +89 -0
- data/lib/learn_test/strategy.rb +51 -0
- data/lib/learn_test/version.rb +1 -1
- data/spec/repo_parser_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +32 -31
- data/lib/learn_test/jasmine/runner.rb +0 -130
- data/lib/learn_test/python_unittest/runner.rb +0 -94
- data/lib/learn_test/rspec/runner.rb +0 -127
- data/lib/learn_test/spec_type_parser.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ae3752afc279ded7a92162c8b13be7698ee389
|
4
|
+
data.tar.gz: 15838447f7a5a92fea7d5357bfa27825c106f0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28390cd306ac2969375021e59c41438d4d47bcabf9fec9c44ac00ea15412ac9b8108f34a610ef63bd50d84b8493161c07333e50fcbe6299b776da17442821fd2
|
7
|
+
data.tar.gz: 380ba0400f08644d9be52f2118e79d2b13b24726b56d578db06a0c829c3baf9f5600af034c408de0c0a09a2108eaa8e899a8465d368325aa51320fa9d0c53c32
|
data/bin/learn-test
CHANGED
@@ -1,82 +1,56 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
-
|
4
|
+
require_relative '../lib/learn_test'
|
5
5
|
|
6
|
-
|
6
|
+
options = {}
|
7
7
|
|
8
|
-
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: learn [options]"
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
repo = ARGV.include?("--test") ? "git@github.com:flatiron-school/a-sample-repo.git" : LearnTest::RepoParser.get_repo
|
16
|
-
|
17
|
-
if spec_type == "jasmine"
|
18
|
-
SERVICE_ENDPOINT = '/e/flatiron_jasmine/build/ironboard'
|
11
|
+
opts.on("-n", "--[no-]color", "Turn off color output") do |c|
|
12
|
+
options[:color] = c
|
13
|
+
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
opts.on("-f", "--format") do |f|
|
16
|
+
options[:format] = f
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
opts.on("-l", "--local", "Don't push results to Flatiron LMS") do |l|
|
20
|
+
options[:local] = l
|
21
|
+
end
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
opts.on("-b", "--browser", "Run tests in browser") do |b|
|
24
|
+
options[:browser] = b
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
opts.on("-o", "--out FILE") do |o|
|
28
|
+
options[:out] = o
|
29
|
+
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
opts.on("-s", "--skip") do |s|
|
32
|
+
options[:skip] = s
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
opts.on("-t", "--test") do |t|
|
36
|
+
options[:test] = t
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
opts.on("-v", "--version") do |v|
|
40
|
+
puts LearnTest::VERSION
|
41
|
+
exit
|
42
|
+
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end.parse!
|
44
|
+
opts.on('--keep', "Don't delete test output files") do |k|
|
45
|
+
options[:keep] = true
|
46
|
+
end
|
52
47
|
|
53
48
|
if ARGV.any? { |arg| arg == "init" }
|
54
|
-
|
55
|
-
else
|
56
|
-
if !options[:skip]
|
57
|
-
LearnTest::Jasmine::PhantomChecker.check_installation
|
58
|
-
username = LearnTest::UsernameParser.get_username
|
59
|
-
user_id = LearnTest::UserIdParser.get_user_id
|
60
|
-
else
|
61
|
-
username = "jasmine-flatiron"
|
62
|
-
user_id = "none"
|
63
|
-
end
|
64
|
-
|
65
|
-
LearnTest::Jasmine::Runner.run(username, user_id, repo, options)
|
49
|
+
options[:init] = true
|
66
50
|
end
|
67
|
-
elsif spec_type == "rspec"
|
68
|
-
SERVICE_ENDPOINT = '/e/flatiron_rspec/build/ironboard'
|
69
|
-
|
70
|
-
runner = LearnTest::RSpec::Runner.new(username, user_id, repo, ARGV)
|
71
|
-
runner.run
|
72
|
-
elsif spec_type == 'python_unittest'
|
73
|
-
SERVICE_ENDPOINT = '/e/flatiron_unittest/build/ironboard'
|
74
51
|
|
75
|
-
|
76
|
-
|
52
|
+
options[:argv] = ARGV
|
53
|
+
end.parse!
|
77
54
|
|
78
|
-
|
79
|
-
|
80
|
-
else
|
81
|
-
puts "This directory doesn't appear to have any specs in it."
|
82
|
-
end
|
55
|
+
repo = options[:test] ? "git@github.com:flatiron-school/a-sample-repo.git" : LearnTest::RepoParser.get_repo
|
56
|
+
LearnTest::Runner.new(repo, options).run
|
data/lib/learn_test.rb
CHANGED
@@ -2,25 +2,19 @@ require 'fileutils'
|
|
2
2
|
require 'faraday'
|
3
3
|
require 'oj'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
require_relative 'learn_test/version'
|
6
|
+
require_relative 'learn_test/netrc_interactor'
|
7
|
+
require_relative 'learn_test/github_interactor'
|
8
|
+
require_relative 'learn_test/user_id_parser'
|
9
|
+
require_relative 'learn_test/username_parser'
|
10
|
+
require_relative 'learn_test/repo_parser'
|
11
|
+
require_relative 'learn_test/file_finder'
|
12
|
+
require_relative 'learn_test/runner'
|
13
|
+
require_relative 'learn_test/strategy'
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require 'learn_test/jasmine/initializer'
|
18
|
-
require 'learn_test/jasmine/runner'
|
19
|
-
|
20
|
-
require 'learn_test/python_unittest/requirements_checker'
|
21
|
-
require 'learn_test/python_unittest/nose_installer'
|
22
|
-
require 'learn_test/python_unittest/runner'
|
15
|
+
require_relative 'learn_test/strategies/jasmine'
|
16
|
+
require_relative 'learn_test/strategies/python_unittest'
|
17
|
+
require_relative 'learn_test/strategies/rspec'
|
23
18
|
|
24
19
|
module LearnTest
|
25
20
|
end
|
26
|
-
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module LearnTest
|
2
|
+
class Runner
|
3
|
+
attr_reader :repo, :options
|
4
|
+
SERVICE_URL = 'http://ironbroker07.fe.flatironschool.com'
|
5
|
+
|
6
|
+
def initialize(repo, options = {})
|
7
|
+
@repo = repo
|
8
|
+
@options = options
|
9
|
+
die if !strategy
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
strategy.check_dependencies
|
14
|
+
strategy.configure
|
15
|
+
strategy.run
|
16
|
+
if !help_option_present? && strategy.push_results?
|
17
|
+
push_results(strategy)
|
18
|
+
strategy.cleanup unless keep_results?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def files
|
23
|
+
@files ||= Dir.entries('.')
|
24
|
+
end
|
25
|
+
|
26
|
+
def keep_results?
|
27
|
+
@keep_results ||= options[:keep] || !!options.delete('--keep')
|
28
|
+
end
|
29
|
+
|
30
|
+
def strategy
|
31
|
+
@strategy ||= strategies.map{ |s| s.new(self) }.detect(&:detect)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def connection
|
37
|
+
@connection ||= Faraday.new(url: SERVICE_URL) do |faraday|
|
38
|
+
faraday.adapter Faraday.default_adapter
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def strategies
|
43
|
+
[
|
44
|
+
LearnTest::Strategies::Rspec,
|
45
|
+
LearnTest::Strategies::Jasmine,
|
46
|
+
LearnTest::Strategies::PythonUnittest
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
def push_results(strategy)
|
51
|
+
begin
|
52
|
+
connection.post do |req|
|
53
|
+
req.url(strategy.service_endpoint)
|
54
|
+
req.headers['Content-Type'] = 'application/json'
|
55
|
+
req.body = Oj.dump(strategy.results, mode: :compat)
|
56
|
+
end
|
57
|
+
rescue Faraday::ConnectionFailed
|
58
|
+
puts 'There was a problem connecting to Learn. Not pushing test results.'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def help_option_present?
|
63
|
+
options.include?('-h') || options.include?('--help')
|
64
|
+
end
|
65
|
+
|
66
|
+
def die
|
67
|
+
puts "This directory doesn't appear to have any specs in it."
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'crack'
|
2
|
+
require 'erb'
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require_relative 'jasmine/phantom_checker'
|
7
|
+
require_relative 'jasmine/initializer'
|
8
|
+
|
9
|
+
module LearnTest
|
10
|
+
module Strategies
|
11
|
+
class Jasmine < LearnTest::Strategy
|
12
|
+
def service_endpoint
|
13
|
+
'/e/flatiron_jasmine'
|
14
|
+
end
|
15
|
+
|
16
|
+
def detect
|
17
|
+
runner.files.include?('requires.yml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_dependencies
|
21
|
+
LearnTest::Jasmine::PhantomChecker.check_installation unless options[:skip]
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
if options[:init]
|
26
|
+
LearnTest::Jasmine::Initializer.run
|
27
|
+
else
|
28
|
+
set_up_runner
|
29
|
+
run_jasmine
|
30
|
+
make_json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def results
|
35
|
+
@results ||= {
|
36
|
+
username: username,
|
37
|
+
github_user_id: user_id,
|
38
|
+
repo_name: runner.repo,
|
39
|
+
build: {
|
40
|
+
test_suite: [{
|
41
|
+
framework: 'jasmine',
|
42
|
+
formatted_output: [],
|
43
|
+
duration: 0.0
|
44
|
+
}]
|
45
|
+
},
|
46
|
+
tests: 0,
|
47
|
+
errors: 0,
|
48
|
+
failures: 0
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def push_results?
|
53
|
+
!local? && !browser?
|
54
|
+
end
|
55
|
+
|
56
|
+
def cleanup
|
57
|
+
test_xml_files.each do |file|
|
58
|
+
FileUtils.rm(file)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def username
|
63
|
+
options[:skip] ? "jasmine-flatiron" : super
|
64
|
+
end
|
65
|
+
|
66
|
+
def user_id
|
67
|
+
options[:skip] ? "none" : super
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def set_up_runner
|
73
|
+
template = ERB.new(File.read("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/templates')}/SpecRunnerTemplate#{color_option}.html.erb"))
|
74
|
+
|
75
|
+
yaml = YAML.load(File.read('requires.yml'))["javascripts"]
|
76
|
+
|
77
|
+
required_files = yaml["files"]
|
78
|
+
required_specs = yaml["specs"]
|
79
|
+
|
80
|
+
@javascripts = []
|
81
|
+
@javascripts << (required_files && required_files.map {|f| "#{test_path}/#{f}"})
|
82
|
+
@javascripts << (required_specs && required_specs.map {|f| "#{test_path}/#{f}"} )
|
83
|
+
@javascripts.flatten!.compact!
|
84
|
+
|
85
|
+
File.open("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/runners')}/SpecRunner#{color_option}.html",
|
86
|
+
'w+') do |f|
|
87
|
+
f << template.result(binding)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def run_jasmine
|
92
|
+
if browser?
|
93
|
+
# system("open #{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/SpecRunner#{color_option}.html --args allow-file-access-from-files")
|
94
|
+
chrome_with_file_access_command = "\"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome\" \"#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/runners')}/SpecRunner#{color_option}.html\" --allow-file-access-from-files"
|
95
|
+
# This should give me back to the prompt - u can use & but a flag to send it to the background would be better.
|
96
|
+
system(chrome_with_file_access_command)
|
97
|
+
else
|
98
|
+
system("phantomjs #{LearnTest::FileFinder.location_to_dir('strategies/jasmine/runners')}/run-jasmine.js #{LearnTest::FileFinder.location_to_dir('strategies/jasmine/runners')}/SpecRunner#{color_option}.html")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_xml_files
|
103
|
+
Dir.entries(test_path).keep_if { |f| f.match(/TEST/) }
|
104
|
+
end
|
105
|
+
|
106
|
+
def make_json
|
107
|
+
if local? || !browser?
|
108
|
+
test_xml_files.each do |f|
|
109
|
+
parsed = JSON.parse(Crack::XML.parse(File.read(f)).to_json)["testsuites"]["testsuite"]
|
110
|
+
results[:build][:test_suite][0][:formatted_output] << parsed["testcase"]
|
111
|
+
results[:build][:test_suite][0][:formatted_output].flatten!
|
112
|
+
results[:tests] += parsed["tests"].to_i
|
113
|
+
results[:errors] += parsed["errors"].to_i
|
114
|
+
results[:failures] += parsed["failures"].to_i
|
115
|
+
results[:build][:test_suite][0][:duration] += parsed["time"].to_f
|
116
|
+
end
|
117
|
+
results[:passing_count] = results[:tests] - results[:failures] - results[:errors]
|
118
|
+
end
|
119
|
+
|
120
|
+
if out || runner.keep_results?
|
121
|
+
output_file = out ? out : '.results.json'
|
122
|
+
write_json_output(output_file: output_file)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def write_json_output(output_file:)
|
127
|
+
File.open(output_file, 'w+') do |f|
|
128
|
+
f.write(results.to_json)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def color_option
|
133
|
+
!options[:color] ? '' : 'NoColor'
|
134
|
+
end
|
135
|
+
|
136
|
+
def local?
|
137
|
+
!!options[:local]
|
138
|
+
end
|
139
|
+
|
140
|
+
def browser?
|
141
|
+
!!options[:browser]
|
142
|
+
end
|
143
|
+
|
144
|
+
def out
|
145
|
+
options[:out]
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_path
|
149
|
+
@test_path ||= FileUtils.pwd
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/learn_test/{jasmine → strategies/jasmine}/templates/SpecRunnerTemplateNoColor.html.erb
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative 'python_unittest/requirements_checker'
|
2
|
+
require_relative 'python_unittest/nose_installer'
|
3
|
+
|
4
|
+
module LearnTest
|
5
|
+
module Strategies
|
6
|
+
class PythonUnittest < LearnTest::Strategy
|
7
|
+
def service_endpoint
|
8
|
+
'/e/flatiron_unittest'
|
9
|
+
end
|
10
|
+
|
11
|
+
def detect
|
12
|
+
runner.files.any? {|f| f.match(/.*.py$/) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_dependencies
|
16
|
+
LearnTest::PythonUnittest::RequirementsChecker.check_installation
|
17
|
+
LearnTest::PythonUnittest::NoseInstaller.install
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
system("nosetests #{options[:argv].join(' ')} --verbose --with-json --json-file='./.results.json'")
|
22
|
+
end
|
23
|
+
|
24
|
+
def output
|
25
|
+
@output ||= Oj.load(File.read('.results.json'), symbol_keys: true)
|
26
|
+
end
|
27
|
+
|
28
|
+
def results
|
29
|
+
{
|
30
|
+
username: username,
|
31
|
+
github_user_id: user_id,
|
32
|
+
repo_name: runner.repo,
|
33
|
+
build: {
|
34
|
+
test_suite: [{
|
35
|
+
framework: 'unittest',
|
36
|
+
formatted_output: output,
|
37
|
+
duration: calculate_duration
|
38
|
+
}]
|
39
|
+
},
|
40
|
+
examples: output[:stats][:total],
|
41
|
+
passing_count: output[:stats][:passes],
|
42
|
+
pending_count: output[:stats][:skipped],
|
43
|
+
failure_count: output[:stats][:errors],
|
44
|
+
failure_descriptions: concat_failure_descriptions
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def cleanup
|
49
|
+
FileUtils.rm('.results.json')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def calculate_duration
|
55
|
+
output[:results].map do |example|
|
56
|
+
example[:time]
|
57
|
+
end.inject(:+)
|
58
|
+
end
|
59
|
+
|
60
|
+
def concat_failure_descriptions
|
61
|
+
output[:results].select do |example|
|
62
|
+
example[:type] == 'failure'
|
63
|
+
end.map { |ex| ex[:tb] }.join(';')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
File without changes
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module LearnTest
|
2
|
+
module Strategies
|
3
|
+
class Rspec < LearnTest::Strategy
|
4
|
+
def service_endpoint
|
5
|
+
'/e/flatiron_rspec'
|
6
|
+
end
|
7
|
+
|
8
|
+
def detect
|
9
|
+
runner.files.include?('spec') && (spec_files.include?('spec_helper.rb') || spec_files.include?('rails_helper.rb'))
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure
|
13
|
+
if format_option_present?
|
14
|
+
if dot_rspec.any? {|dot_opt| dot_opt.match(/--format|-f/)}
|
15
|
+
argv << dot_rspec.reject {|dot_opt| dot_opt.match(/--format|-f/)}
|
16
|
+
else
|
17
|
+
argv << dot_rspec
|
18
|
+
end
|
19
|
+
argv.flatten!
|
20
|
+
else
|
21
|
+
argv.unshift('--format documentation')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Don't pass the test/local flag from learn binary to rspec runner.
|
25
|
+
argv.delete("--test")
|
26
|
+
argv.delete("-t")
|
27
|
+
argv.delete("-l")
|
28
|
+
argv.delete("--local")
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
system("rspec #{argv.join(' ')} --format j --out .results.json")
|
33
|
+
end
|
34
|
+
|
35
|
+
def output
|
36
|
+
File.exists?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def results
|
40
|
+
{
|
41
|
+
username: username,
|
42
|
+
github_user_id: user_id,
|
43
|
+
repo_name: runner.repo,
|
44
|
+
build: {
|
45
|
+
test_suite: [{
|
46
|
+
framework: 'rspec',
|
47
|
+
formatted_output: output,
|
48
|
+
duration: output ? output[:summary][:duration] : nil
|
49
|
+
}]
|
50
|
+
},
|
51
|
+
examples: output ? output[:summary][:example_count] : 1,
|
52
|
+
passing_count: output ? output[:summary][:example_count] - output[:summary][:failure_count] - output[:summary][:pending_count] : 0,
|
53
|
+
pending_count: output ? output[:summary][:pending_count] : 0,
|
54
|
+
failure_count: output ? output[:summary][:failure_count] : 1,
|
55
|
+
failure_descriptions: failures
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def cleanup
|
60
|
+
FileUtils.rm('.results.json') unless !File.exist?('.results.json')
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def spec_files
|
66
|
+
@spec_files ||= Dir.entries('./spec')
|
67
|
+
end
|
68
|
+
|
69
|
+
def format_option_present?
|
70
|
+
options[:format]
|
71
|
+
end
|
72
|
+
|
73
|
+
def dot_rspec
|
74
|
+
@dot_rspec ||= File.readlines('.rspec').map(&:strip) if File.exist?('.rspec')
|
75
|
+
end
|
76
|
+
|
77
|
+
def failures
|
78
|
+
if output
|
79
|
+
output[:examples].select do |example|
|
80
|
+
example[:status] == "failed"
|
81
|
+
end.map { |ex| ex[:full_description] }.join(";")
|
82
|
+
else
|
83
|
+
'A syntax error prevented RSpec from running.'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module LearnTest
|
2
|
+
class Strategy
|
3
|
+
attr_reader :runner, :options
|
4
|
+
|
5
|
+
def initialize(runner)
|
6
|
+
@runner = runner
|
7
|
+
@options = runner.options
|
8
|
+
end
|
9
|
+
|
10
|
+
def service_endpoint
|
11
|
+
raise NotImplementedError, 'you must add the service endpoint to the test strategy'
|
12
|
+
end
|
13
|
+
|
14
|
+
def check_dependencies
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
raise NotImplementedError, 'you must implement how this strategy runs its tests'
|
22
|
+
end
|
23
|
+
|
24
|
+
def output
|
25
|
+
raise NotImplementedError, 'you must implement how the test gets its raw output'
|
26
|
+
end
|
27
|
+
|
28
|
+
def results
|
29
|
+
output
|
30
|
+
end
|
31
|
+
|
32
|
+
def push_results?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def cleanup
|
37
|
+
end
|
38
|
+
|
39
|
+
def username
|
40
|
+
@username ||= LearnTest::UsernameParser.get_username
|
41
|
+
end
|
42
|
+
|
43
|
+
def user_id
|
44
|
+
@user_id ||= LearnTest::UserIdParser.get_user_id
|
45
|
+
end
|
46
|
+
|
47
|
+
def argv
|
48
|
+
options[:argv]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/learn_test/version.rb
CHANGED
data/spec/repo_parser_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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:
|
4
|
+
version: 2.0.0.pre
|
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-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -155,34 +155,35 @@ files:
|
|
155
155
|
- lib/learn_test.rb
|
156
156
|
- lib/learn_test/file_finder.rb
|
157
157
|
- lib/learn_test/github_interactor.rb
|
158
|
-
- lib/learn_test/jasmine/boot.js
|
159
|
-
- lib/learn_test/jasmine/console.js
|
160
|
-
- lib/learn_test/jasmine/formatters/jasmine2-junit.js
|
161
|
-
- lib/learn_test/jasmine/helpers/ConsoleHelper.js
|
162
|
-
- lib/learn_test/jasmine/helpers/ConsoleHelperNoColor.js
|
163
|
-
- lib/learn_test/jasmine/initializer.rb
|
164
|
-
- lib/learn_test/jasmine/jasmine-html.js
|
165
|
-
- lib/learn_test/jasmine/jasmine-jquery.js
|
166
|
-
- lib/learn_test/jasmine/jasmine.css
|
167
|
-
- lib/learn_test/jasmine/jasmine.js
|
168
|
-
- lib/learn_test/jasmine/jasmine_favicon.png
|
169
|
-
- lib/learn_test/jasmine/jquery-1.8.0.min.js
|
170
|
-
- lib/learn_test/jasmine/jquery-ui-1.8.23.custom.min.js
|
171
|
-
- lib/learn_test/jasmine/phantom_checker.rb
|
172
|
-
- lib/learn_test/jasmine/runner.rb
|
173
|
-
- lib/learn_test/jasmine/runners/SpecRunner.html
|
174
|
-
- lib/learn_test/jasmine/runners/run-jasmine.js
|
175
|
-
- lib/learn_test/jasmine/templates/SpecRunnerTemplate.html.erb
|
176
|
-
- lib/learn_test/jasmine/templates/SpecRunnerTemplateNoColor.html.erb
|
177
|
-
- lib/learn_test/jasmine/templates/requires.yml.example
|
178
|
-
- lib/learn_test/jasmine/vendor/require.js
|
179
158
|
- lib/learn_test/netrc_interactor.rb
|
180
|
-
- lib/learn_test/python_unittest/nose_installer.rb
|
181
|
-
- lib/learn_test/python_unittest/requirements_checker.rb
|
182
|
-
- lib/learn_test/python_unittest/runner.rb
|
183
159
|
- lib/learn_test/repo_parser.rb
|
184
|
-
- lib/learn_test/
|
185
|
-
- lib/learn_test/
|
160
|
+
- lib/learn_test/runner.rb
|
161
|
+
- lib/learn_test/strategies/jasmine.rb
|
162
|
+
- lib/learn_test/strategies/jasmine/boot.js
|
163
|
+
- lib/learn_test/strategies/jasmine/console.js
|
164
|
+
- lib/learn_test/strategies/jasmine/formatters/jasmine2-junit.js
|
165
|
+
- lib/learn_test/strategies/jasmine/helpers/ConsoleHelper.js
|
166
|
+
- lib/learn_test/strategies/jasmine/helpers/ConsoleHelperNoColor.js
|
167
|
+
- lib/learn_test/strategies/jasmine/initializer.rb
|
168
|
+
- lib/learn_test/strategies/jasmine/jasmine-html.js
|
169
|
+
- lib/learn_test/strategies/jasmine/jasmine-jquery.js
|
170
|
+
- lib/learn_test/strategies/jasmine/jasmine.css
|
171
|
+
- lib/learn_test/strategies/jasmine/jasmine.js
|
172
|
+
- lib/learn_test/strategies/jasmine/jasmine_favicon.png
|
173
|
+
- lib/learn_test/strategies/jasmine/jquery-1.8.0.min.js
|
174
|
+
- lib/learn_test/strategies/jasmine/jquery-ui-1.8.23.custom.min.js
|
175
|
+
- lib/learn_test/strategies/jasmine/phantom_checker.rb
|
176
|
+
- lib/learn_test/strategies/jasmine/runners/SpecRunner.html
|
177
|
+
- lib/learn_test/strategies/jasmine/runners/run-jasmine.js
|
178
|
+
- lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplate.html.erb
|
179
|
+
- lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplateNoColor.html.erb
|
180
|
+
- lib/learn_test/strategies/jasmine/templates/requires.yml.example
|
181
|
+
- lib/learn_test/strategies/jasmine/vendor/require.js
|
182
|
+
- lib/learn_test/strategies/python_unittest.rb
|
183
|
+
- lib/learn_test/strategies/python_unittest/nose_installer.rb
|
184
|
+
- lib/learn_test/strategies/python_unittest/requirements_checker.rb
|
185
|
+
- lib/learn_test/strategies/rspec.rb
|
186
|
+
- lib/learn_test/strategy.rb
|
186
187
|
- lib/learn_test/user_id_parser.rb
|
187
188
|
- lib/learn_test/username_parser.rb
|
188
189
|
- lib/learn_test/version.rb
|
@@ -213,12 +214,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
214
|
version: '0'
|
214
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
216
|
requirements:
|
216
|
-
- - "
|
217
|
+
- - ">"
|
217
218
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
219
|
+
version: 1.3.1
|
219
220
|
requirements: []
|
220
221
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.5
|
222
|
+
rubygems_version: 2.4.5
|
222
223
|
signing_key:
|
223
224
|
specification_version: 4
|
224
225
|
summary: Runs RSpec, Jasmine, and Python Unit Test builds and pushes JSON output to
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'crack'
|
2
|
-
require 'erb'
|
3
|
-
require 'yaml'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module LearnTest
|
7
|
-
module Jasmine
|
8
|
-
class Runner
|
9
|
-
attr_reader :no_color, :local, :browser, :conn, :color_opt, :out, :keep_results
|
10
|
-
attr_accessor :json_results
|
11
|
-
|
12
|
-
def self.run(username, user_id, repo_name, options)
|
13
|
-
new(username, user_id, repo_name, options).run
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(username, user_id, repo_name, options)
|
17
|
-
@current_test_path = FileUtils.pwd
|
18
|
-
@no_color = !!options[:color]
|
19
|
-
@color_opt = !no_color ? "" : "NoColor"
|
20
|
-
@local = !!options[:local]
|
21
|
-
@browser = !!options[:browser]
|
22
|
-
@out = options[:out]
|
23
|
-
@keep_results = options[:keep]
|
24
|
-
@json_results = {
|
25
|
-
username: username,
|
26
|
-
github_user_id:user_id,
|
27
|
-
repo_name: repo_name,
|
28
|
-
build: {
|
29
|
-
test_suite: [{
|
30
|
-
framework: 'jasmine',
|
31
|
-
formatted_output: [],
|
32
|
-
duration: 0.0
|
33
|
-
}]
|
34
|
-
},
|
35
|
-
tests: 0,
|
36
|
-
errors: 0,
|
37
|
-
failures: 0
|
38
|
-
}
|
39
|
-
@conn = Faraday.new(url: SERVICE_URL) do |faraday|
|
40
|
-
faraday.adapter Faraday.default_adapter
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def run
|
45
|
-
make_runner_html
|
46
|
-
run_jasmine
|
47
|
-
make_json
|
48
|
-
push_to_flatiron unless local || browser
|
49
|
-
clean_up
|
50
|
-
end
|
51
|
-
|
52
|
-
def run_jasmine
|
53
|
-
if browser
|
54
|
-
# system("open #{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/SpecRunner#{color_opt}.html --args allow-file-access-from-files")
|
55
|
-
chrome_with_file_access_command = "\"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome\" \"#{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/SpecRunner#{color_opt}.html\" --allow-file-access-from-files"
|
56
|
-
# This should give me back to the prompt - u can use & but a flag to send it to the background would be better.
|
57
|
-
system(chrome_with_file_access_command)
|
58
|
-
else
|
59
|
-
system("phantomjs #{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/run-jasmine.js #{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/SpecRunner#{color_opt}.html")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def make_json
|
64
|
-
if local || !browser
|
65
|
-
test_xml_files.each do |f|
|
66
|
-
parsed = JSON.parse(Crack::XML.parse(File.read(f)).to_json)["testsuites"]["testsuite"]
|
67
|
-
json_results[:build][:test_suite][0][:formatted_output] << parsed["testcase"]
|
68
|
-
json_results[:build][:test_suite][0][:formatted_output].flatten!
|
69
|
-
json_results[:tests] += parsed["tests"].to_i
|
70
|
-
json_results[:errors] += parsed["errors"].to_i
|
71
|
-
json_results[:failures] += parsed["failures"].to_i
|
72
|
-
json_results[:build][:test_suite][0][:duration] += parsed["time"].to_f
|
73
|
-
end
|
74
|
-
set_passing_test_count
|
75
|
-
end
|
76
|
-
|
77
|
-
if out || keep_results
|
78
|
-
output_file = out ? out : '.results.json'
|
79
|
-
write_json_output(output_file: output_file)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def set_passing_test_count
|
84
|
-
json_results[:passing_count] = json_results[:tests] - json_results[:failures] - json_results[:errors]
|
85
|
-
end
|
86
|
-
|
87
|
-
def write_json_output(output_file:)
|
88
|
-
File.open(output_file, 'w+') do |f|
|
89
|
-
f.write(json_results.to_json)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def push_to_flatiron
|
94
|
-
conn.post do |req|
|
95
|
-
req.url SERVICE_ENDPOINT
|
96
|
-
req.headers['Content-Type'] = 'application/json'
|
97
|
-
req.body = json_results.to_json
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def make_runner_html
|
102
|
-
template = ERB.new(File.read("#{LearnTest::FileFinder.location_to_dir('jasmine/templates')}/SpecRunnerTemplate#{color_opt}.html.erb"))
|
103
|
-
|
104
|
-
yaml = YAML.load(File.read('requires.yml'))["javascripts"]
|
105
|
-
|
106
|
-
required_files = yaml["files"]
|
107
|
-
required_specs = yaml["specs"]
|
108
|
-
|
109
|
-
@javascripts = []
|
110
|
-
@javascripts << (required_files && required_files.map {|f| "#{@current_test_path}/#{f}"})
|
111
|
-
@javascripts << (required_specs && required_specs.map {|f| "#{@current_test_path}/#{f}"} )
|
112
|
-
@javascripts.flatten!.compact!
|
113
|
-
|
114
|
-
File.open("#{LearnTest::FileFinder.location_to_dir('jasmine/runners')}/SpecRunner#{color_opt}.html", 'w+') do |f|
|
115
|
-
f << template.result(binding)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_xml_files
|
120
|
-
Dir.entries(@current_test_path).keep_if { |f| f.match(/TEST/) }
|
121
|
-
end
|
122
|
-
|
123
|
-
def clean_up
|
124
|
-
test_xml_files.each do |file|
|
125
|
-
FileUtils.rm(file)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
module LearnTest
|
2
|
-
module PythonUnittest
|
3
|
-
class Runner
|
4
|
-
attr_accessor :parsed_output, :json_output, :formatted_results
|
5
|
-
attr_reader :username, :user_id, :repo_name, :options, :connection, :keep_results
|
6
|
-
|
7
|
-
def initialize(username, user_id, repo_name, options)
|
8
|
-
@username = username
|
9
|
-
@user_id = user_id
|
10
|
-
@repo_name = repo_name
|
11
|
-
@options = options
|
12
|
-
@json_output = ""
|
13
|
-
@parsed_output = nil
|
14
|
-
@formatted_results = {}
|
15
|
-
@keep_results = !!options.delete('--keep')
|
16
|
-
@connection = Faraday.new(url: SERVICE_URL) do |faraday|
|
17
|
-
faraday.adapter Faraday.default_adapter
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def run
|
22
|
-
run_nose
|
23
|
-
if !options.include?('-h') && !options.include?('--help')
|
24
|
-
set_json_output
|
25
|
-
jsonify
|
26
|
-
format_results
|
27
|
-
push_results
|
28
|
-
cleanup
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def keep_results?
|
33
|
-
keep_results
|
34
|
-
end
|
35
|
-
|
36
|
-
def run_nose
|
37
|
-
system("nosetests #{options.join(' ')} --verbose --with-json --json-file='./.results.json'")
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_json_output
|
41
|
-
self.json_output = File.read('.results.json')
|
42
|
-
end
|
43
|
-
|
44
|
-
def jsonify
|
45
|
-
self.parsed_output = Oj.load(json_output, symbol_keys: true)
|
46
|
-
end
|
47
|
-
|
48
|
-
def format_results
|
49
|
-
self.formatted_results.merge!({
|
50
|
-
username: username,
|
51
|
-
github_user_id: user_id,
|
52
|
-
repo_name: repo_name,
|
53
|
-
build: {
|
54
|
-
test_suite: [{
|
55
|
-
framework: 'unittest',
|
56
|
-
formatted_output: parsed_output,
|
57
|
-
duration: calculate_duration
|
58
|
-
}]
|
59
|
-
},
|
60
|
-
examples: parsed_output[:stats][:total],
|
61
|
-
passing_count: parsed_output[:stats][:passes],
|
62
|
-
pending_count: parsed_output[:stats][:skipped],
|
63
|
-
failure_count: parsed_output[:stats][:errors],
|
64
|
-
failure_descriptions: concat_failure_descriptions
|
65
|
-
})
|
66
|
-
end
|
67
|
-
|
68
|
-
def calculate_duration
|
69
|
-
parsed_output[:results].map do |example|
|
70
|
-
example[:time]
|
71
|
-
end.inject(:+)
|
72
|
-
end
|
73
|
-
|
74
|
-
def concat_failure_descriptions
|
75
|
-
parsed_output[:results].select do |example|
|
76
|
-
example[:type] == 'failure'
|
77
|
-
end.map { |ex| ex[:tb] }.join(';')
|
78
|
-
end
|
79
|
-
|
80
|
-
def push_results
|
81
|
-
connection.post do |req|
|
82
|
-
req.url SERVICE_ENDPOINT
|
83
|
-
req.headers['Content-Type'] = 'application/json'
|
84
|
-
req.body = Oj.dump(formatted_results, mode: :compat)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def cleanup
|
89
|
-
FileUtils.rm('.results.json') unless keep_results?
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
@@ -1,127 +0,0 @@
|
|
1
|
-
module LearnTest
|
2
|
-
module RSpec
|
3
|
-
class Runner
|
4
|
-
attr_accessor :parsed_output, :json_output, :formatted_results, :keep_results
|
5
|
-
attr_reader :username, :user_id, :repo_name, :options, :connection
|
6
|
-
|
7
|
-
def initialize(username, user_id, repo_name, options)
|
8
|
-
@username = username
|
9
|
-
@user_id = user_id
|
10
|
-
@repo_name = repo_name
|
11
|
-
@options = options
|
12
|
-
@json_output = ""
|
13
|
-
@parsed_output = nil
|
14
|
-
@formatted_results = {}
|
15
|
-
@connection = Faraday.new(url: SERVICE_URL) do |faraday|
|
16
|
-
faraday.adapter Faraday.default_adapter
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
check_options
|
22
|
-
run_rspec
|
23
|
-
if !options.include?('-h') && !options.include?('--help')
|
24
|
-
set_json_output
|
25
|
-
jsonify
|
26
|
-
format_results
|
27
|
-
push_results
|
28
|
-
cleanup
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def check_options
|
33
|
-
options_has_format = options.include?('--format') || options.include?('-f')
|
34
|
-
if dot_rspec = read_dot_rspec
|
35
|
-
if options_has_format
|
36
|
-
if dot_rspec.any? {|dot_opt| dot_opt.match(/--format|-f/)}
|
37
|
-
options << dot_rspec.reject {|dot_opt| dot_opt.match(/--format|-f/)}
|
38
|
-
else
|
39
|
-
options << dot_rspec
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if options_has_format
|
45
|
-
self.options.flatten!
|
46
|
-
else
|
47
|
-
options.unshift('--format documentation')
|
48
|
-
end
|
49
|
-
|
50
|
-
# Don't pass the test/local flag from learn binary to rspec runner.
|
51
|
-
options.delete("--test")
|
52
|
-
options.delete("-t")
|
53
|
-
options.delete("-l")
|
54
|
-
options.delete("--local")
|
55
|
-
|
56
|
-
self.keep_results = !!options.delete('--keep')
|
57
|
-
end
|
58
|
-
|
59
|
-
def read_dot_rspec
|
60
|
-
if File.exist?('.rspec')
|
61
|
-
File.readlines('.rspec').map(&:strip)
|
62
|
-
else
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def run_rspec
|
68
|
-
system("rspec #{options.join(' ')} --format j --out .results.json")
|
69
|
-
end
|
70
|
-
|
71
|
-
def set_json_output
|
72
|
-
self.json_output = File.exists?('.results.json') ? File.read('.results.json') : nil
|
73
|
-
end
|
74
|
-
|
75
|
-
def jsonify
|
76
|
-
self.parsed_output = json_output ? Oj.load(json_output, symbol_keys: true) : nil
|
77
|
-
end
|
78
|
-
|
79
|
-
def format_results
|
80
|
-
self.formatted_results.merge!({
|
81
|
-
username: username,
|
82
|
-
github_user_id: user_id,
|
83
|
-
repo_name: repo_name,
|
84
|
-
build: {
|
85
|
-
test_suite: [{
|
86
|
-
framework: 'rspec',
|
87
|
-
formatted_output: parsed_output,
|
88
|
-
duration: parsed_output ? parsed_output[:summary][:duration] : nil
|
89
|
-
}]
|
90
|
-
},
|
91
|
-
examples: parsed_output ? parsed_output[:summary][:example_count] : 1,
|
92
|
-
passing_count: parsed_output ? parsed_output[:summary][:example_count] - parsed_output[:summary][:failure_count] - parsed_output[:summary][:pending_count] : 0,
|
93
|
-
pending_count: parsed_output ? parsed_output[:summary][:pending_count] : 0,
|
94
|
-
failure_count: parsed_output ? parsed_output[:summary][:failure_count] : 1,
|
95
|
-
failure_descriptions: if parsed_output
|
96
|
-
parsed_output[:examples].select do |example|
|
97
|
-
example[:status] == "failed"
|
98
|
-
end.map { |ex| ex[:full_description] }.join(";")
|
99
|
-
else
|
100
|
-
'A syntax error prevented RSpec from running.'
|
101
|
-
end
|
102
|
-
})
|
103
|
-
end
|
104
|
-
|
105
|
-
def push_results
|
106
|
-
begin
|
107
|
-
connection.post do |req|
|
108
|
-
req.url SERVICE_ENDPOINT
|
109
|
-
req.headers['Content-Type'] = 'application/json'
|
110
|
-
req.body = Oj.dump(formatted_results, mode: :compat)
|
111
|
-
end
|
112
|
-
rescue Faraday::ConnectionFailed
|
113
|
-
puts 'There was a problem connecting to Learn. Not pushing test results.'
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def cleanup
|
118
|
-
FileUtils.rm('.results.json') unless keep_results? || !File.exist?('.results.json')
|
119
|
-
end
|
120
|
-
|
121
|
-
def keep_results?
|
122
|
-
keep_results
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module LearnTest
|
2
|
-
class SpecTypeParser
|
3
|
-
attr_reader :spec_type
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@spec_type = parse_spec_type
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def parse_spec_type
|
12
|
-
files = Dir.entries('.')
|
13
|
-
|
14
|
-
if files.include?('requires.yml')
|
15
|
-
'jasmine'
|
16
|
-
elsif files.any? {|f| f.match(/.*.py$/) }
|
17
|
-
'python_unittest'
|
18
|
-
elsif files.include?('spec')
|
19
|
-
spec_files = Dir.entries('./spec')
|
20
|
-
if spec_files.include?('spec_helper.rb') || spec_files.include?('rails_helper.rb')
|
21
|
-
'rspec'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|