learn-test 3.2.1.pre.6 → 3.2.4
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-wip +1 -1
- data/lib/learn_test.rb +1 -0
- data/lib/learn_test/git_wip.rb +10 -11
- data/lib/learn_test/runner.rb +5 -7
- data/lib/learn_test/strategies/none.rb +36 -0
- data/lib/learn_test/version.rb +1 -1
- data/spec/learn_test/git_spec.rb +15 -8
- data/spec/lib/learn_test/strategies/none_spec.rb +54 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78b850c796efd54f383ea05c625ad8d5f6038d9dcf865b19fc21fd6dcad435fb
|
4
|
+
data.tar.gz: 88336d0c6c787c1680b22453220a1046741f7ffaf06d97ce090b7fd4d02d4f25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0abed1a972742bdbd28e05ca20218109f3834267ef560bf884b358e237107f6c294ecbda9248d570fe88c8f4014efb7cdc44bd6779b246acc59d639a35e80c
|
7
|
+
data.tar.gz: c36adeff838bf630cc640df29e38f7a82de8e65c5aeff5f20a1c107b93d277c4af07ceb2703306d4306a5295237aec822a1f3105bfebfd7a7d64998be5a69700
|
data/bin/learn-test-wip
CHANGED
data/lib/learn_test.rb
CHANGED
@@ -26,6 +26,7 @@ require_relative 'learn_test/strategies/java_junit'
|
|
26
26
|
require_relative 'learn_test/strategies/csharp_nunit'
|
27
27
|
require_relative 'learn_test/strategies/mocha'
|
28
28
|
require_relative 'learn_test/strategies/pytest'
|
29
|
+
require_relative 'learn_test/strategies/none'
|
29
30
|
|
30
31
|
module LearnTest
|
31
32
|
module Dependencies
|
data/lib/learn_test/git_wip.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'git'
|
4
|
+
require 'logger'
|
4
5
|
|
5
6
|
module LearnTest
|
6
7
|
module GitWip
|
@@ -9,25 +10,23 @@ module LearnTest
|
|
9
10
|
git = Git.open('./', log: log)
|
10
11
|
working_branch = git.current_branch
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
commands = [
|
14
|
+
'learn-test-wip save "Automatic test submission" --editor',
|
15
|
+
"git push origin wip/#{working_branch}:refs/heads/wip"
|
16
|
+
].join(';')
|
17
|
+
|
18
|
+
Open3.popen3(commands) do |_stdin, _stdout, _stderr, wait_thr|
|
19
|
+
# while out = stdout.gets do; puts out; end
|
20
|
+
# while err = stderr.gets do; puts err; end
|
20
21
|
|
21
22
|
if wait_thr.value.exitstatus.zero?
|
22
|
-
git.push('origin', "wip/#{working_branch}:refs/heads/wip")
|
23
23
|
git.config['remote.origin.url'].gsub('.git', '/tree/wip')
|
24
24
|
else
|
25
|
-
puts 'There was an error running learn-test-wip'
|
25
|
+
# puts 'There was an error running learn-test-wip'
|
26
26
|
false
|
27
27
|
end
|
28
28
|
end
|
29
29
|
rescue StandardError => e
|
30
|
-
puts e
|
31
30
|
false
|
32
31
|
end
|
33
32
|
end
|
data/lib/learn_test/runner.rb
CHANGED
@@ -9,7 +9,6 @@ module LearnTest
|
|
9
9
|
def initialize(repo, options = {})
|
10
10
|
@repo = repo
|
11
11
|
@options = options
|
12
|
-
die unless strategy
|
13
12
|
end
|
14
13
|
|
15
14
|
def run
|
@@ -34,7 +33,11 @@ module LearnTest
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def strategy
|
37
|
-
@strategy
|
36
|
+
return @strategy if @strategy
|
37
|
+
|
38
|
+
detected = strategies.map { |s| s.new(self) }.detect(&:detect)
|
39
|
+
|
40
|
+
@strategy = detected || LearnTest::Strategies::None.new(self)
|
38
41
|
end
|
39
42
|
|
40
43
|
private
|
@@ -68,10 +71,5 @@ module LearnTest
|
|
68
71
|
def local_test_run?
|
69
72
|
options.include?('-h') || options.include?('--local')
|
70
73
|
end
|
71
|
-
|
72
|
-
def die
|
73
|
-
puts "This directory doesn't appear to have any specs in it."
|
74
|
-
exit
|
75
|
-
end
|
76
74
|
end
|
77
75
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LearnTest
|
4
|
+
module Strategies
|
5
|
+
class None < LearnTest::Strategy
|
6
|
+
def service_endpoint
|
7
|
+
'/e/flatiron_none'
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
puts <<~MSG
|
12
|
+
This directory doesn't appear to have any specs in it, so there’s no test to run.
|
13
|
+
|
14
|
+
If you are working on Canvas, this assignment has been submitted. You can resubmit by running `learn test` again.
|
15
|
+
MSG
|
16
|
+
end
|
17
|
+
|
18
|
+
def results
|
19
|
+
{
|
20
|
+
username: username,
|
21
|
+
github_user_id: user_id,
|
22
|
+
learn_oauth_token: learn_oauth_token,
|
23
|
+
repo_name: runner.repo,
|
24
|
+
build: {
|
25
|
+
test_suite: [{ framework: 'none' }]
|
26
|
+
},
|
27
|
+
examples: 0,
|
28
|
+
passing_count: 0,
|
29
|
+
pending_count: 0,
|
30
|
+
failure_count: 0,
|
31
|
+
failure_descriptions: ''
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/learn_test/version.rb
CHANGED
data/spec/learn_test/git_spec.rb
CHANGED
@@ -7,28 +7,35 @@ describe LearnTest::GitWip do
|
|
7
7
|
let!(:git_url) { 'https://github.com/learn-co/learn-test' }
|
8
8
|
let!(:git_base) { instance_double(Git::Base) }
|
9
9
|
|
10
|
+
let(:wait_thr) { double }
|
11
|
+
let(:wait_thr_value) { double }
|
12
|
+
let(:stdout_and_stderr) { double }
|
13
|
+
|
10
14
|
context 'success' do
|
11
15
|
it 'should return the git url' do
|
12
16
|
expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
|
13
17
|
expect(git_base).to receive(:current_branch).and_return(working_branch)
|
14
18
|
|
15
|
-
expect(
|
16
|
-
expect(
|
19
|
+
expect(wait_thr).to receive(:value).and_return(wait_thr_value)
|
20
|
+
expect(wait_thr_value).to receive(:exitstatus).and_return(0)
|
17
21
|
|
18
|
-
expect(
|
19
|
-
expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
|
22
|
+
expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
|
20
23
|
|
24
|
+
expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
|
21
25
|
expect(subject.run!).to eq("#{git_url}/tree/wip")
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
29
|
context 'failure' do
|
26
30
|
it 'should return false on process error' do
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
|
32
|
+
expect(git_base).to receive(:current_branch).and_return(working_branch)
|
33
|
+
|
34
|
+
expect(wait_thr).to receive(:value).and_return(wait_thr_value)
|
35
|
+
expect(wait_thr_value).to receive(:exitstatus).and_return(1)
|
36
|
+
|
37
|
+
expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
|
30
38
|
|
31
|
-
expect($?).to receive(:success?).and_return(false)
|
32
39
|
expect(subject.run!).to eq(false)
|
33
40
|
end
|
34
41
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe LearnTest::Strategies::None do
|
4
|
+
describe '#run' do
|
5
|
+
it 'prints a message' do
|
6
|
+
strategy = LearnTest::Strategies::None.new(double(:runner, options: {}))
|
7
|
+
|
8
|
+
msg = <<~MSG
|
9
|
+
This directory doesn't appear to have any specs in it, so there’s no test to run.
|
10
|
+
|
11
|
+
If you are working on Canvas, this assignment has been submitted. You can resubmit by running `learn test` again.
|
12
|
+
MSG
|
13
|
+
|
14
|
+
expect { strategy.run }.to output(msg).to_stdout
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#results' do
|
19
|
+
it 'contains the appropriate attributes' do
|
20
|
+
user_id = rand(1000..9999)
|
21
|
+
username = "test-username-#{user_id}"
|
22
|
+
oauth_token = "test-token-#{user_id}"
|
23
|
+
repo = double(:repo)
|
24
|
+
|
25
|
+
runner = LearnTest::Runner.new(repo, {})
|
26
|
+
strategy = LearnTest::Strategies::None.new(runner)
|
27
|
+
|
28
|
+
expect(LearnTest::UsernameParser).to receive(:get_username)
|
29
|
+
.and_return(username)
|
30
|
+
|
31
|
+
expect(LearnTest::UserIdParser).to receive(:get_user_id)
|
32
|
+
.and_return(user_id)
|
33
|
+
|
34
|
+
expect(LearnTest::LearnOauthTokenParser).to receive(:get_learn_oauth_token)
|
35
|
+
.and_return(oauth_token)
|
36
|
+
|
37
|
+
|
38
|
+
expect(strategy.results).to eq(
|
39
|
+
username: username,
|
40
|
+
github_user_id: user_id,
|
41
|
+
learn_oauth_token: oauth_token,
|
42
|
+
repo_name: repo,
|
43
|
+
build: {
|
44
|
+
test_suite: [{ framework: 'none' }]
|
45
|
+
},
|
46
|
+
examples: 0,
|
47
|
+
passing_count: 0,
|
48
|
+
pending_count: 0,
|
49
|
+
failure_count: 0,
|
50
|
+
failure_descriptions: ''
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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: 3.2.
|
4
|
+
version: 3.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.8.1
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- learn@flatironschool.com
|
142
142
|
executables:
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/learn_test/strategies/karma.rb
|
182
182
|
- lib/learn_test/strategies/karma/karma.conf.js
|
183
183
|
- lib/learn_test/strategies/mocha.rb
|
184
|
+
- lib/learn_test/strategies/none.rb
|
184
185
|
- lib/learn_test/strategies/protractor.rb
|
185
186
|
- lib/learn_test/strategies/pytest.rb
|
186
187
|
- lib/learn_test/strategies/pytest/requirements_checker.rb
|
@@ -204,13 +205,14 @@ files:
|
|
204
205
|
- spec/learn_test/reporter_spec.rb
|
205
206
|
- spec/learn_test/username_parser_spec.rb
|
206
207
|
- spec/lib/learn_test/strategies/mocha_spec.rb
|
208
|
+
- spec/lib/learn_test/strategies/none_spec.rb
|
207
209
|
- spec/repo_parser_spec.rb
|
208
210
|
- spec/spec_helper.rb
|
209
211
|
homepage: https://github.com/learn-co/learn-test
|
210
212
|
licenses:
|
211
213
|
- MIT
|
212
214
|
metadata: {}
|
213
|
-
post_install_message:
|
215
|
+
post_install_message:
|
214
216
|
rdoc_options: []
|
215
217
|
require_paths:
|
216
218
|
- lib
|
@@ -222,12 +224,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
224
|
version: 2.5.0
|
223
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
226
|
requirements:
|
225
|
-
- - "
|
227
|
+
- - ">="
|
226
228
|
- !ruby/object:Gem::Version
|
227
|
-
version:
|
229
|
+
version: '0'
|
228
230
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
230
|
-
signing_key:
|
231
|
+
rubygems_version: 3.0.6
|
232
|
+
signing_key:
|
231
233
|
specification_version: 4
|
232
234
|
summary: Runs RSpec, Karma, Mocha, and Python Pytest Test builds and pushes JSON output
|
233
235
|
to Learn.
|
@@ -242,5 +244,6 @@ test_files:
|
|
242
244
|
- spec/learn_test/reporter_spec.rb
|
243
245
|
- spec/learn_test/username_parser_spec.rb
|
244
246
|
- spec/lib/learn_test/strategies/mocha_spec.rb
|
247
|
+
- spec/lib/learn_test/strategies/none_spec.rb
|
245
248
|
- spec/repo_parser_spec.rb
|
246
249
|
- spec/spec_helper.rb
|