learn-test 3.1.2 → 3.2.1.pre.4

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/Gemfile +2 -0
  4. data/Rakefile +2 -1
  5. data/bin/learn-test +15 -14
  6. data/bin/learn-test-wip +356 -0
  7. data/learn-test.gemspec +9 -8
  8. data/lib/learn_test.rb +3 -0
  9. data/lib/learn_test/client.rb +2 -0
  10. data/lib/learn_test/dependencies/ant.rb +2 -0
  11. data/lib/learn_test/dependencies/csharp.rb +3 -1
  12. data/lib/learn_test/dependencies/imagemagick.rb +2 -0
  13. data/lib/learn_test/dependencies/java.rb +2 -0
  14. data/lib/learn_test/dependencies/karma.rb +2 -0
  15. data/lib/learn_test/dependencies/nodejs.rb +2 -0
  16. data/lib/learn_test/dependencies/phantomjs.rb +6 -4
  17. data/lib/learn_test/dependencies/protractor.rb +2 -0
  18. data/lib/learn_test/dependencies/selenium_server.rb +2 -0
  19. data/lib/learn_test/dependency.rb +4 -4
  20. data/lib/learn_test/file_finder.rb +2 -1
  21. data/lib/learn_test/git_wip.rb +36 -0
  22. data/lib/learn_test/github_interactor.rb +2 -1
  23. data/lib/learn_test/js_strategy.rb +3 -1
  24. data/lib/learn_test/learn_oauth_token_parser.rb +2 -0
  25. data/lib/learn_test/netrc_interactor.rb +2 -1
  26. data/lib/learn_test/repo_parser.rb +2 -0
  27. data/lib/learn_test/reporter.rb +14 -7
  28. data/lib/learn_test/runner.rb +5 -3
  29. data/lib/learn_test/strategies/csharp_nunit.rb +5 -3
  30. data/lib/learn_test/strategies/java_junit.rb +9 -8
  31. data/lib/learn_test/strategies/karma.rb +9 -5
  32. data/lib/learn_test/strategies/mocha.rb +10 -8
  33. data/lib/learn_test/strategies/protractor.rb +7 -6
  34. data/lib/learn_test/strategies/pytest.rb +13 -13
  35. data/lib/learn_test/strategies/pytest/requirements_checker.rb +14 -12
  36. data/lib/learn_test/strategies/rspec.rb +11 -10
  37. data/lib/learn_test/strategy.rb +5 -6
  38. data/lib/learn_test/user_id_parser.rb +2 -1
  39. data/lib/learn_test/username_parser.rb +3 -2
  40. data/lib/learn_test/version.rb +3 -1
  41. data/spec/features/rspec_unit_spec.rb +4 -2
  42. data/spec/fixtures/rspec-unit-spec/lib/dog.rb +3 -1
  43. data/spec/fixtures/rspec-unit-spec/spec/dog_spec.rb +4 -2
  44. data/spec/fixtures/rspec-unit-spec/spec/spec_helper.rb +2 -0
  45. data/spec/learn_test/git_spec.rb +40 -0
  46. data/spec/learn_test/reporter_spec.rb +69 -31
  47. data/spec/learn_test/username_parser_spec.rb +2 -0
  48. data/spec/lib/learn_test/strategies/mocha_spec.rb +21 -20
  49. data/spec/repo_parser_spec.rb +14 -12
  50. data/spec/spec_helper.rb +2 -0
  51. metadata +9 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd9f8898b0c708a6bf7aad502d8441301bd2bab73d390f852150a4d698f69f97
4
- data.tar.gz: fa9228ecdb9b4092653cfd89a5d634aa6846e485b5bbb85f37c312c063dae750
3
+ metadata.gz: f43572cbddd931c8db3b3b0290d1dc68b324b4450b89c649b373179f7433b71a
4
+ data.tar.gz: 7190b9aa495a2e2ebbbd4dd98f69051a64d5782c1be2350a9409edf39c3a7908
5
5
  SHA512:
6
- metadata.gz: cf68d74186a0ca47a70ee3627b7a14e147eb821184b0026395ddf29bc1c64b3ad4b4678f66314cb1817b4c81b9dc74dd9842672167101830cf8ed754afd3ef5d
7
- data.tar.gz: bb9b1ffd334f270542322fa06d652ea15320ae2e537d181eb5aa60b4c9eb0e599f3a1215db93073f82507f616e8fd03a24aa13453fcd1d97b90fa97ac64f4a18
6
+ metadata.gz: e09523f95aa2f4f4bb195a01c57df89ae20f35c94cf0988a41ea1014e58edd606422cb593323bda45a285700b4c8f5dcf5899a4569d6458b4d20d2ac15cabdec
7
+ data.tar.gz: 1641d96d75f9a25b9fb59650b0cc4e92403b46c3143d33f13970b58c3038f9ef10c9b1231c3fe2b4ca037cbd97b1a0584e691c831408ace3ce2ad50bbe5ab423
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
+ --order rand
2
3
  --require spec_helper
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  group :test do
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'optparse'
4
5
  require_relative '../lib/learn_test'
@@ -6,45 +7,45 @@ require_relative '../lib/learn_test'
6
7
  options = {}
7
8
 
8
9
  OptionParser.new do |opts|
9
- opts.banner = "Usage: learn [options]"
10
+ opts.banner = 'Usage: learn [options]'
10
11
 
11
- opts.on("--sync", "Report test results synchronously") do |s|
12
+ opts.on('--sync', 'Report test results synchronously') do |s|
12
13
  options[:sync] = s
13
14
  end
14
15
 
15
- opts.on("-d", "--debug", "Output errors during results synchronization") do |d|
16
+ opts.on('-d', '--debug', 'Output errors during results synchronization') do |d|
16
17
  options[:debug] = d
17
18
  end
18
19
 
19
- opts.on("-n", "--[no-]color", "Turn off color output") do |c|
20
+ opts.on('-n', '--[no-]color', 'Turn off color output') do |c|
20
21
  options[:color] = c
21
22
  end
22
23
 
23
- opts.on("-f", "--format") do |f|
24
+ opts.on('-f', '--format') do |f|
24
25
  options[:format] = f
25
26
  end
26
27
 
27
- opts.on("-l", "--local", "Don't push results to Learn") do |l|
28
+ opts.on('-l', '--local', "Don't push results to Learn") do |l|
28
29
  options[:local] = l
29
30
  end
30
31
 
31
- opts.on("-b", "--browser", "Run tests in browser") do |b|
32
+ opts.on('-b', '--browser', 'Run tests in browser') do |b|
32
33
  options[:browser] = b
33
34
  end
34
35
 
35
- opts.on("-o", "--out FILE") do |o|
36
+ opts.on('-o', '--out FILE') do |o|
36
37
  options[:out] = o
37
38
  end
38
39
 
39
- opts.on("-s", "--skip") do |s|
40
+ opts.on('-s', '--skip') do |s|
40
41
  options[:skip] = s
41
42
  end
42
43
 
43
- opts.on("-t", "--test") do |t|
44
+ opts.on('-t', '--test') do |t|
44
45
  options[:test] = t
45
46
  end
46
47
 
47
- opts.on("-v", "--version") do |v|
48
+ opts.on('-v', '--version') do |v|
48
49
  puts LearnTest::VERSION
49
50
  exit
50
51
  end
@@ -57,16 +58,16 @@ OptionParser.new do |opts|
57
58
  options[:fail_fast] = f
58
59
  end
59
60
 
60
- opts.on("-e", "--example STRING", "Run examples whose full nested names include STRING (may be used more than once)") do |s|
61
+ opts.on('-e', '--example STRING', 'Run examples whose full nested names include STRING (may be used more than once)') do |s|
61
62
  (options[:example] ||= []) << s
62
63
  end
63
64
 
64
- if ARGV.any? { |arg| arg == "init" }
65
+ if ARGV.any? { |arg| arg == 'init' }
65
66
  options[:init] = true
66
67
  end
67
68
 
68
69
  options[:argv] = ARGV
69
70
  end.parse!
70
71
 
71
- repo = options[:test] ? "git@github.com:flatiron-school/a-sample-repo.git" : LearnTest::RepoParser.get_repo
72
+ repo = options[:test] ? 'git@github.com:flatiron-school/a-sample-repo.git' : LearnTest::RepoParser.get_repo
72
73
  LearnTest::Runner.new(repo, options).run
@@ -0,0 +1,356 @@
1
+ #!/bin/bash
2
+ #
3
+ # Copyright Bart Trojanowski <bart@jukie.net>
4
+ #
5
+ # git-wip is a script that will manage Work In Progress (or WIP) branches.
6
+ # WIP branches are mostly throw away but identify points of development
7
+ # between commits. The intent is to tie this script into your editor so
8
+ # that each time you save your file, the git-wip script captures that
9
+ # state in git. git-wip also helps you return back to a previous state of
10
+ # development.
11
+ #
12
+ # See also http://github.com/bartman/git-wip
13
+ #
14
+ # The code is licensed as GPL v2 or, at your option, any later version.
15
+ # Please see http://www.gnu.org/licenses/gpl-2.0.txt
16
+ #
17
+
18
+ USAGE='[ info | save <message> [ --editor | --untracked | --no-gpg-sign ] | log [ --pretty ] | delete ] [ [--] <file>... ]'
19
+ LONG_USAGE="Manage Work In Progress branches
20
+
21
+ Commands:
22
+ git wip - create a new WIP commit
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
+
28
+ Options for save:
29
+ -e --editor - be less verbose, assume called from an editor
30
+ -u --untracked - capture also untracked files
31
+ -i --ignored - capture also ignored files
32
+ --no-gpg-sign - do not sign commit; that is, countermand
33
+ '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
+ "
40
+
41
+ source "$(git --exec-path)/git-sh-setup"
42
+
43
+ require_work_tree
44
+
45
+ TMP="$GIT_DIR/.git-wip.$$"
46
+ trap 'rm -f "$TMP-*"' 0
47
+
48
+ WIP_INDEX="$TMP-INDEX"
49
+
50
+ WIP_PREFIX=refs/wip/
51
+ WIP_COMMAND=
52
+ WIP_MESSAGE=WIP
53
+ EDITOR_MODE=false
54
+
55
+ dbg() {
56
+ if test -n "$WIP_DEBUG"
57
+ then
58
+ printf '# %s\n' "$*"
59
+ fi
60
+ }
61
+
62
+ # some errors are not worth reporting in --editor mode
63
+ report_soft_error () {
64
+ $EDITOR_MODE && exit 0
65
+ die "$@"
66
+ }
67
+
68
+ cleanup () {
69
+ rm -f "$TMP-*"
70
+ }
71
+
72
+ get_work_branch () {
73
+ ref=$(git symbolic-ref -q HEAD) \
74
+ || report_soft_error "git-wip requires a branch"
75
+
76
+
77
+ branch=${ref#refs/heads/}
78
+ if [ $branch = $ref ] ; then
79
+ die "git-wip requires a local branch"
80
+ fi
81
+
82
+ echo $branch
83
+ }
84
+
85
+ get_wip_branch () {
86
+ return 0
87
+ }
88
+
89
+ check_files () {
90
+ local -a files="$@"
91
+
92
+ for f in "${files[@]}"
93
+ do
94
+ [ -f "$f" -o -d "$f" ] || die "$f: No such file or directory."
95
+ done
96
+ }
97
+
98
+ build_new_tree () {
99
+ local untracked=$1 ; shift
100
+ local ignored=$1 ; shift
101
+ local files="$@"
102
+
103
+ (
104
+ set -e
105
+ rm -f "$WIP_INDEX"
106
+ cp -p "$GIT_DIR/index" "$WIP_INDEX"
107
+ export GIT_INDEX_FILE="$WIP_INDEX"
108
+ git read-tree $wip_parent
109
+ if [ -n "$files" ]
110
+ then
111
+ git add -f "${files[@]}"
112
+ else
113
+ git add --update .
114
+ fi
115
+ [ -n "$untracked" ] && git add .
116
+ [ -n "$ignored" ] && git add -f -A .
117
+ git write-tree
118
+ rm -f "$WIP_INDEX"
119
+ )
120
+ }
121
+
122
+ do_save () {
123
+ local msg="$1" ; shift
124
+ local add_untracked=
125
+ local add_ignored=
126
+ local no_sign=
127
+
128
+ while test $# != 0
129
+ do
130
+ case "$1" in
131
+ -e|--editor)
132
+ EDITOR_MODE=true
133
+ ;;
134
+ -u|--untracked)
135
+ add_untracked=t
136
+ ;;
137
+ -i|--ignored)
138
+ add_ignored=t
139
+ ;;
140
+ --no-gpg-sign)
141
+ no_sign=--no-gpg-sign
142
+ ;;
143
+ --)
144
+ shift
145
+ break
146
+ ;;
147
+ *)
148
+ [ -f "$1" ] && break
149
+ die "Unknown option '$1'."
150
+ ;;
151
+ esac
152
+ shift
153
+ done
154
+ local files="$@"
155
+ local "add_untracked=$add_untracked"
156
+ local "add_ignored=$add_ignored"
157
+
158
+ if test ${#files} -gt 0
159
+ then
160
+ check_files "${files[@]}"
161
+ fi
162
+
163
+ dbg "msg=$msg"
164
+ dbg "files=$files"
165
+
166
+ local work_branch=$(get_work_branch)
167
+ local wip_branch="$WIP_PREFIX$work_branch"
168
+
169
+ dbg "work_branch=$work_branch"
170
+ dbg "wip_branch=$wip_branch"
171
+
172
+ # enable reflog
173
+ local wip_branch_file="$GIT_DIR/logs/$wip_branch"
174
+ dbg "wip_branch_file=$wip_branch_file"
175
+ mkdir -p "$(dirname "$wip_branch_file")"
176
+ : >>"$wip_branch_file"
177
+
178
+ if ! work_last=$(git rev-parse --verify $work_branch)
179
+ then
180
+ report_soft_error "'$work_branch' branch has no commits."
181
+ fi
182
+
183
+ dbg "work_last=$work_last"
184
+
185
+ if wip_last=$(git rev-parse --quiet --verify $wip_branch)
186
+ then
187
+ local base=$(git merge-base $wip_last $work_last) \
188
+ || die "'work_branch' and '$wip_branch' are unrelated."
189
+
190
+ if [ $base = $work_last ] ; then
191
+ wip_parent=$wip_last
192
+ else
193
+ wip_parent=$work_last
194
+ fi
195
+ else
196
+ wip_parent=$work_last
197
+ fi
198
+
199
+ dbg "wip_parent=$wip_parent"
200
+
201
+ new_tree=$( build_new_tree "$add_untracked" "$add_ignored" "${files[@]}" ) \
202
+ || die "Cannot save the current worktree state."
203
+
204
+ dbg "new_tree=$new_tree"
205
+
206
+ if git diff-tree --exit-code --quiet $new_tree $wip_parent ; then
207
+ report_soft_error "no changes"
208
+ fi
209
+
210
+ dbg "... has changes"
211
+
212
+ new_wip=$(printf '%s\n' "$msg" | git commit-tree $no_sign $new_tree -p $wip_parent 2>/dev/null) \
213
+ || die "Cannot record working tree state"
214
+
215
+ dbg "new_wip=$new_wip"
216
+
217
+ msg1=$(printf '%s\n' "$msg" | sed -e 1q)
218
+ git update-ref -m "git-wip: $msg1" $wip_branch $new_wip $wip_last
219
+
220
+ dbg "SUCCESS"
221
+ }
222
+
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
+ if test $# -eq 0
304
+ then
305
+ dbg "no arguments"
306
+
307
+ do_save "WIP"
308
+ exit $?
309
+ fi
310
+
311
+ dbg "args: $@"
312
+
313
+ case "$1" in
314
+ save)
315
+ WIP_COMMAND=$1
316
+ shift
317
+ if [ -n "$1" ]
318
+ then
319
+ WIP_MESSAGE="$1"
320
+ shift
321
+ fi
322
+ ;;
323
+ info|log|delete)
324
+ WIP_COMMAND=$1
325
+ shift
326
+ ;;
327
+ help)
328
+ do_help 0
329
+ ;;
330
+ --*)
331
+ ;;
332
+ *)
333
+ [ -f "$1" ] || die "Unknown command '$1'."
334
+ ;;
335
+ esac
336
+
337
+ case $WIP_COMMAND in
338
+ save)
339
+ do_save "$WIP_MESSAGE" $@
340
+ ;;
341
+ info)
342
+ do_info $@
343
+ ;;
344
+ log)
345
+ do_log $@
346
+ ;;
347
+ delete)
348
+ do_delete $@
349
+ ;;
350
+ *)
351
+ usage
352
+ exit 1
353
+ ;;
354
+ esac
355
+
356
+ # vim: set noet sw=8