learn-test 3.2.1.pre.4 → 3.2.2

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
  SHA256:
3
- metadata.gz: f43572cbddd931c8db3b3b0290d1dc68b324b4450b89c649b373179f7433b71a
4
- data.tar.gz: 7190b9aa495a2e2ebbbd4dd98f69051a64d5782c1be2350a9409edf39c3a7908
3
+ metadata.gz: 168abe900bd1294d73073dee5b63eb69b3ca135e8da57aceaffed7502227f0e3
4
+ data.tar.gz: eafade82d182826a76f31053845483815b63e44e2d94bcefe378793a2f168ea3
5
5
  SHA512:
6
- metadata.gz: e09523f95aa2f4f4bb195a01c57df89ae20f35c94cf0988a41ea1014e58edd606422cb593323bda45a285700b4c8f5dcf5899a4569d6458b4d20d2ac15cabdec
7
- data.tar.gz: 1641d96d75f9a25b9fb59650b0cc4e92403b46c3143d33f13970b58c3038f9ef10c9b1231c3fe2b4ca037cbd97b1a0584e691c831408ace3ce2ad50bbe5ab423
6
+ metadata.gz: 636b8afdded2b375a2e47e21bd1537829cc5df11fea011486e92b93c47394cfed7070fcbefe1e0390ae29e29d30839410d6fd5950f672952b2343c6a845898e5
7
+ data.tar.gz: 53d021bee5edee0154e8f3905c8782df206f5afe10b377df34cd010baa5a772caa7b3b41683b8033d9fb09ed8d924d3f2ec59c01e9b91ecc1031f3594b3d9d65
@@ -15,15 +15,12 @@
15
15
  # Please see http://www.gnu.org/licenses/gpl-2.0.txt
16
16
  #
17
17
 
18
- USAGE='[ info | save <message> [ --editor | --untracked | --no-gpg-sign ] | log [ --pretty ] | delete ] [ [--] <file>... ]'
18
+ USAGE='[ save <message> [ --editor | --untracked | --no-gpg-sign ] | delete ] [ [--] <file>... ]'
19
19
  LONG_USAGE="Manage Work In Progress branches
20
20
 
21
21
  Commands:
22
22
  git wip - create a new WIP commit
23
23
  git wip save <message> - create a new WIP commit with custom message
24
- git wip info [<branch>] - brief WIP info
25
- git wip log [<branch>] - show changes on the WIP branch
26
- git wip delete [<branch>] - delete a WIP branch
27
24
 
28
25
  Options for save:
29
26
  -e --editor - be less verbose, assume called from an editor
@@ -31,19 +28,19 @@ Options for save:
31
28
  -i --ignored - capture also ignored files
32
29
  --no-gpg-sign - do not sign commit; that is, countermand
33
30
  'commit.gpgSign = true'
34
-
35
- Options for log:
36
- -p --pretty - show a pretty graph
37
- -r --reflog - show changes in reflog
38
- -s --stat - show diffstat
39
31
  "
40
32
 
41
- source "$(git --exec-path)/git-sh-setup"
33
+ . "$(git --exec-path)/git-sh-setup"
42
34
 
43
35
  require_work_tree
44
36
 
45
- TMP="$GIT_DIR/.git-wip.$$"
46
- trap 'rm -f "$TMP-*"' 0
37
+ TMP=$(mktemp -d -t .git-wip)
38
+
39
+ cleanup () {
40
+ rm -f "$TMP-*"
41
+ }
42
+
43
+ trap cleanup 0
47
44
 
48
45
  WIP_INDEX="$TMP-INDEX"
49
46
 
@@ -65,10 +62,6 @@ report_soft_error () {
65
62
  die "$@"
66
63
  }
67
64
 
68
- cleanup () {
69
- rm -f "$TMP-*"
70
- }
71
-
72
65
  get_work_branch () {
73
66
  ref=$(git symbolic-ref -q HEAD) \
74
67
  || report_soft_error "git-wip requires a branch"
@@ -82,10 +75,6 @@ get_work_branch () {
82
75
  echo $branch
83
76
  }
84
77
 
85
- get_wip_branch () {
86
- return 0
87
- }
88
-
89
78
  check_files () {
90
79
  local -a files="$@"
91
80
 
@@ -220,86 +209,6 @@ do_save () {
220
209
  dbg "SUCCESS"
221
210
  }
222
211
 
223
- do_info () {
224
- local branch=$1
225
-
226
- die "info not implemented"
227
- }
228
-
229
- do_log () {
230
- local work_branch=$1
231
- [ -z $branch ] && work_branch=$(get_work_branch)
232
- local wip_branch="$WIP_PREFIX$work_branch"
233
-
234
- local log_cmd="log"
235
- local graph=""
236
- local pretty=""
237
- local stat=""
238
- while [ -n "$1" ]
239
- do
240
- case "$1" in
241
- -p|--pretty)
242
- graph="--graph"
243
- pretty="--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
244
- ;;
245
- -s|--stat)
246
- stat="--stat"
247
- ;;
248
- -r|--reflog)
249
- log_cmd="reflog"
250
- ;;
251
- *)
252
- break
253
- ;;
254
- esac
255
- shift
256
- done
257
-
258
- if [ $log_cmd = reflog ]
259
- then
260
- echo git reflog $stat $pretty $wip_branch | sh
261
- return $?
262
- fi
263
-
264
- if ! work_last=$(git rev-parse --verify $work_branch)
265
- then
266
- die "'$work_branch' branch has no commits."
267
- fi
268
-
269
- dbg work_last=$work_last
270
-
271
- if ! wip_last=$(git rev-parse --quiet --verify $wip_branch)
272
- then
273
- die "'$work_branch' branch has no commits."
274
- fi
275
-
276
- dbg wip_last=$wip_last
277
-
278
- local base=$(git merge-base $wip_last $work_last)
279
-
280
- dbg base=$base
281
-
282
- echo git log $graph $stat $pretty $@ $wip_last $work_last "^$base~1" | sh
283
- }
284
-
285
- do_delete () {
286
- local branch=$1
287
-
288
- die "delete not implemented"
289
- }
290
-
291
- do_help () {
292
- local rc=$1
293
-
294
- cat <<END
295
- Usage: git wip $USAGE
296
-
297
- $LONG_USAGE
298
- END
299
- exit $rc
300
- }
301
-
302
-
303
212
  if test $# -eq 0
304
213
  then
305
214
  dbg "no arguments"
@@ -320,13 +229,6 @@ save)
320
229
  shift
321
230
  fi
322
231
  ;;
323
- info|log|delete)
324
- WIP_COMMAND=$1
325
- shift
326
- ;;
327
- help)
328
- do_help 0
329
- ;;
330
232
  --*)
331
233
  ;;
332
234
  *)
@@ -338,15 +240,6 @@ case $WIP_COMMAND in
338
240
  save)
339
241
  do_save "$WIP_MESSAGE" $@
340
242
  ;;
341
- info)
342
- do_info $@
343
- ;;
344
- log)
345
- do_log $@
346
- ;;
347
- delete)
348
- do_delete $@
349
- ;;
350
243
  *)
351
244
  usage
352
245
  exit 1
@@ -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
@@ -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,26 +10,23 @@ module LearnTest
9
10
  git = Git.open('./', log: log)
10
11
  working_branch = git.current_branch
11
12
 
12
- Open3.popen3('./bin/learn-test-wip save "Automatic test submission" --editor') do |_stdin, _stdout, stderr, wait_thr|
13
- # while out = stdout.gets do
14
- # puts out
15
- # end
16
-
17
- while err = stderr.gets do
18
- puts err
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
- true
25
24
  else
26
- puts 'There was an error running learn-test-wip'
25
+ # puts 'There was an error running learn-test-wip'
27
26
  false
28
27
  end
29
28
  end
30
29
  rescue StandardError => e
31
- puts e
32
30
  false
33
31
  end
34
32
  end
@@ -57,7 +57,8 @@ module LearnTest
57
57
  LearnTest::Strategies::Protractor,
58
58
  LearnTest::Strategies::JavaJunit,
59
59
  LearnTest::Strategies::Mocha,
60
- LearnTest::Strategies::Pytest
60
+ LearnTest::Strategies::Pytest,
61
+ LearnTest::Strategies::None
61
62
  ]
62
63
  end
63
64
 
@@ -0,0 +1,40 @@
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 detect
11
+ runner.files.include?('.canvas')
12
+ end
13
+
14
+ def run
15
+ puts 'Your assignment was submitted. You can resubmit by running `learn test` again.'
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: [{
26
+ framework: 'none',
27
+ formatted_output: '',
28
+ duration: nil
29
+ }]
30
+ },
31
+ examples: 0,
32
+ passing_count: 0,
33
+ pending_count: 0,
34
+ failure_count: 0,
35
+ failure_descriptions: ''
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnTest
4
- VERSION = '3.2.1.pre.4'
4
+ VERSION = '3.2.2'
5
5
  end
@@ -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(subject).to receive(:`).with(/learn-test-wip save ".+" -u &> \/dev\/null/ )
16
- expect($?).to receive(:success?).and_return(true)
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(git_base).to receive(:push).with('origin', "wip/#{working_branch}:refs/heads/wip")
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
- allow(Git::Base).to receive(:open).and_return(git_base)
28
- allow(git_base).to receive(:current_branch)
29
- allow(subject).to receive(:`)
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,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe LearnTest::Strategies::None do
4
+ describe '#detect' do
5
+ context 'there is a .canvas file' do
6
+ before { FileUtils.touch('.canvas') }
7
+ after { FileUtils.rm('.canvas') }
8
+
9
+ it 'is true' do
10
+ runner = LearnTest::Runner.new(double(:repo), {})
11
+ strategy = LearnTest::Strategies::None.new(runner)
12
+
13
+ expect(strategy.detect).to eq(true)
14
+ end
15
+ end
16
+
17
+ context 'there is no .canvas file' do
18
+ it 'is false' do
19
+ runner = LearnTest::Runner.new(double(:repo), {})
20
+ strategy = LearnTest::Strategies::None.new(runner)
21
+
22
+ expect(strategy.detect).to eq(false)
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#run' do
28
+ it 'prints a message' do
29
+ strategy = LearnTest::Strategies::None.new(double(:runner, options: {}))
30
+ msg = "Your assignment was submitted. You can resubmit by running `learn test` again.\n"
31
+
32
+ expect { strategy.run }.to output(msg).to_stdout
33
+ end
34
+ end
35
+
36
+ describe '#results' do
37
+ it 'contains the appropriate attributes' do
38
+ user_id = rand(1000..9999)
39
+ username = "test-username-#{user_id}"
40
+ oauth_token = "test-token-#{user_id}"
41
+ repo = double(:repo)
42
+
43
+ runner = LearnTest::Runner.new(repo, {})
44
+ strategy = LearnTest::Strategies::None.new(runner)
45
+
46
+ expect(LearnTest::UsernameParser).to receive(:get_username)
47
+ .and_return(username)
48
+
49
+ expect(LearnTest::UserIdParser).to receive(:get_user_id)
50
+ .and_return(user_id)
51
+
52
+ expect(LearnTest::LearnOauthTokenParser).to receive(:get_learn_oauth_token)
53
+ .and_return(oauth_token)
54
+
55
+
56
+ expect(strategy.results).to eq(
57
+ username: username,
58
+ github_user_id: user_id,
59
+ learn_oauth_token: oauth_token,
60
+ repo_name: repo,
61
+ build: {
62
+ test_suite: [{
63
+ framework: 'none',
64
+ formatted_output: '',
65
+ duration: nil
66
+ }]
67
+ },
68
+ examples: 0,
69
+ passing_count: 0,
70
+ pending_count: 0,
71
+ failure_count: 0,
72
+ failure_descriptions: ''
73
+ )
74
+ end
75
+ end
76
+ 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.1.pre.4
4
+ version: 3.2.2
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-08-25 00:00:00.000000000 Z
11
+ date: 2020-09-21 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: 1.3.1
229
+ version: '0'
228
230
  requirements: []
229
- rubygems_version: 3.1.2
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