learn-test 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
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 +359 -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 +23 -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 +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd9f8898b0c708a6bf7aad502d8441301bd2bab73d390f852150a4d698f69f97
4
- data.tar.gz: fa9228ecdb9b4092653cfd89a5d634aa6846e485b5bbb85f37c312c063dae750
3
+ metadata.gz: bed755ca8be57fd27faa4cd8599bca39ba5e646a479893121cc7b136e9a85390
4
+ data.tar.gz: 70cc99f2785201694ad6d4f250e5622c2521d4775fcb8fbbf9eefb01c13d6bac
5
5
  SHA512:
6
- metadata.gz: cf68d74186a0ca47a70ee3627b7a14e147eb821184b0026395ddf29bc1c64b3ad4b4678f66314cb1817b4c81b9dc74dd9842672167101830cf8ed754afd3ef5d
7
- data.tar.gz: bb9b1ffd334f270542322fa06d652ea15320ae2e537d181eb5aa60b4c9eb0e599f3a1215db93073f82507f616e8fd03a24aa13453fcd1d97b90fa97ac64f4a18
6
+ metadata.gz: e361131d7b082c1929417689267defe0da1b8aaf044374f296fb08c5face6422baa92e3cd8d8eeb9cb07e39123610ea218d10c11f4dca79f2fbc9c1337a5c457
7
+ data.tar.gz: 31d269a0e9656a7c97f11b3a24da5233bf7a463aeb429d475832dc65176a221f4cb580f88aaf7cab42e993381f3e3f23b0d095db23a7889736e24d8cff2cb12c
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,359 @@
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
+ SUBDIRECTORY_OK=Yes
42
+ OPTIONS_SPEC=
43
+
44
+ . "$(git --exec-path)/git-sh-setup"
45
+
46
+ require_work_tree
47
+
48
+ TMP="$GIT_DIR/.git-wip.$$"
49
+ trap 'rm -f "$TMP-*"' 0
50
+
51
+ WIP_INDEX="$TMP-INDEX"
52
+
53
+ WIP_PREFIX=refs/wip/
54
+ WIP_COMMAND=
55
+ WIP_MESSAGE=WIP
56
+ EDITOR_MODE=false
57
+
58
+ dbg() {
59
+ if test -n "$WIP_DEBUG"
60
+ then
61
+ printf '# %s\n' "$*"
62
+ fi
63
+ }
64
+
65
+ # some errors are not worth reporting in --editor mode
66
+ report_soft_error () {
67
+ $EDITOR_MODE && exit 0
68
+ die "$@"
69
+ }
70
+
71
+ cleanup () {
72
+ rm -f "$TMP-*"
73
+ }
74
+
75
+ get_work_branch () {
76
+ ref=$(git symbolic-ref -q HEAD) \
77
+ || report_soft_error "git-wip requires a branch"
78
+
79
+
80
+ branch=${ref#refs/heads/}
81
+ if [ $branch = $ref ] ; then
82
+ die "git-wip requires a local branch"
83
+ fi
84
+
85
+ echo $branch
86
+ }
87
+
88
+ get_wip_branch () {
89
+ return 0
90
+ }
91
+
92
+ check_files () {
93
+ local -a files="$@"
94
+
95
+ for f in "${files[@]}"
96
+ do
97
+ [ -f "$f" -o -d "$f" ] || die "$f: No such file or directory."
98
+ done
99
+ }
100
+
101
+ build_new_tree () {
102
+ local untracked=$1 ; shift
103
+ local ignored=$1 ; shift
104
+ local files="$@"
105
+
106
+ (
107
+ set -e
108
+ rm -f "$WIP_INDEX"
109
+ cp -p "$GIT_DIR/index" "$WIP_INDEX"
110
+ export GIT_INDEX_FILE="$WIP_INDEX"
111
+ git read-tree $wip_parent
112
+ if [ -n "$files" ]
113
+ then
114
+ git add -f "${files[@]}"
115
+ else
116
+ git add --update .
117
+ fi
118
+ [ -n "$untracked" ] && git add .
119
+ [ -n "$ignored" ] && git add -f -A .
120
+ git write-tree
121
+ rm -f "$WIP_INDEX"
122
+ )
123
+ }
124
+
125
+ do_save () {
126
+ local msg="$1" ; shift
127
+ local add_untracked=
128
+ local add_ignored=
129
+ local no_sign=
130
+
131
+ while test $# != 0
132
+ do
133
+ case "$1" in
134
+ -e|--editor)
135
+ EDITOR_MODE=true
136
+ ;;
137
+ -u|--untracked)
138
+ add_untracked=t
139
+ ;;
140
+ -i|--ignored)
141
+ add_ignored=t
142
+ ;;
143
+ --no-gpg-sign)
144
+ no_sign=--no-gpg-sign
145
+ ;;
146
+ --)
147
+ shift
148
+ break
149
+ ;;
150
+ *)
151
+ [ -f "$1" ] && break
152
+ die "Unknown option '$1'."
153
+ ;;
154
+ esac
155
+ shift
156
+ done
157
+ local files="$@"
158
+ local "add_untracked=$add_untracked"
159
+ local "add_ignored=$add_ignored"
160
+
161
+ if test ${#files} -gt 0
162
+ then
163
+ check_files "${files[@]}"
164
+ fi
165
+
166
+ dbg "msg=$msg"
167
+ dbg "files=$files"
168
+
169
+ local work_branch=$(get_work_branch)
170
+ local wip_branch="$WIP_PREFIX$work_branch"
171
+
172
+ dbg "work_branch=$work_branch"
173
+ dbg "wip_branch=$wip_branch"
174
+
175
+ # enable reflog
176
+ local wip_branch_file="$GIT_DIR/logs/$wip_branch"
177
+ dbg "wip_branch_file=$wip_branch_file"
178
+ mkdir -p "$(dirname "$wip_branch_file")"
179
+ : >>"$wip_branch_file"
180
+
181
+ if ! work_last=$(git rev-parse --verify $work_branch)
182
+ then
183
+ report_soft_error "'$work_branch' branch has no commits."
184
+ fi
185
+
186
+ dbg "work_last=$work_last"
187
+
188
+ if wip_last=$(git rev-parse --quiet --verify $wip_branch)
189
+ then
190
+ local base=$(git merge-base $wip_last $work_last) \
191
+ || die "'work_branch' and '$wip_branch' are unrelated."
192
+
193
+ if [ $base = $work_last ] ; then
194
+ wip_parent=$wip_last
195
+ else
196
+ wip_parent=$work_last
197
+ fi
198
+ else
199
+ wip_parent=$work_last
200
+ fi
201
+
202
+ dbg "wip_parent=$wip_parent"
203
+
204
+ new_tree=$( build_new_tree "$add_untracked" "$add_ignored" "${files[@]}" ) \
205
+ || die "Cannot save the current worktree state."
206
+
207
+ dbg "new_tree=$new_tree"
208
+
209
+ if git diff-tree --exit-code --quiet $new_tree $wip_parent ; then
210
+ report_soft_error "no changes"
211
+ fi
212
+
213
+ dbg "... has changes"
214
+
215
+ new_wip=$(printf '%s\n' "$msg" | git commit-tree $no_sign $new_tree -p $wip_parent 2>/dev/null) \
216
+ || die "Cannot record working tree state"
217
+
218
+ dbg "new_wip=$new_wip"
219
+
220
+ msg1=$(printf '%s\n' "$msg" | sed -e 1q)
221
+ git update-ref -m "git-wip: $msg1" $wip_branch $new_wip $wip_last
222
+
223
+ dbg "SUCCESS"
224
+ }
225
+
226
+ do_info () {
227
+ local branch=$1
228
+
229
+ die "info not implemented"
230
+ }
231
+
232
+ do_log () {
233
+ local work_branch=$1
234
+ [ -z $branch ] && work_branch=$(get_work_branch)
235
+ local wip_branch="$WIP_PREFIX$work_branch"
236
+
237
+ local log_cmd="log"
238
+ local graph=""
239
+ local pretty=""
240
+ local stat=""
241
+ while [ -n "$1" ]
242
+ do
243
+ case "$1" in
244
+ -p|--pretty)
245
+ graph="--graph"
246
+ pretty="--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
247
+ ;;
248
+ -s|--stat)
249
+ stat="--stat"
250
+ ;;
251
+ -r|--reflog)
252
+ log_cmd="reflog"
253
+ ;;
254
+ *)
255
+ break
256
+ ;;
257
+ esac
258
+ shift
259
+ done
260
+
261
+ if [ $log_cmd = reflog ]
262
+ then
263
+ echo git reflog $stat $pretty $wip_branch | sh
264
+ return $?
265
+ fi
266
+
267
+ if ! work_last=$(git rev-parse --verify $work_branch)
268
+ then
269
+ die "'$work_branch' branch has no commits."
270
+ fi
271
+
272
+ dbg work_last=$work_last
273
+
274
+ if ! wip_last=$(git rev-parse --quiet --verify $wip_branch)
275
+ then
276
+ die "'$work_branch' branch has no commits."
277
+ fi
278
+
279
+ dbg wip_last=$wip_last
280
+
281
+ local base=$(git merge-base $wip_last $work_last)
282
+
283
+ dbg base=$base
284
+
285
+ echo git log $graph $stat $pretty $@ $wip_last $work_last "^$base~1" | sh
286
+ }
287
+
288
+ do_delete () {
289
+ local branch=$1
290
+
291
+ die "delete not implemented"
292
+ }
293
+
294
+ do_help () {
295
+ local rc=$1
296
+
297
+ cat <<END
298
+ Usage: git wip $USAGE
299
+
300
+ $LONG_USAGE
301
+ END
302
+ exit $rc
303
+ }
304
+
305
+
306
+ if test $# -eq 0
307
+ then
308
+ dbg "no arguments"
309
+
310
+ do_save "WIP"
311
+ exit $?
312
+ fi
313
+
314
+ dbg "args: $@"
315
+
316
+ case "$1" in
317
+ save)
318
+ WIP_COMMAND=$1
319
+ shift
320
+ if [ -n "$1" ]
321
+ then
322
+ WIP_MESSAGE="$1"
323
+ shift
324
+ fi
325
+ ;;
326
+ info|log|delete)
327
+ WIP_COMMAND=$1
328
+ shift
329
+ ;;
330
+ help)
331
+ do_help 0
332
+ ;;
333
+ --*)
334
+ ;;
335
+ *)
336
+ [ -f "$1" ] || die "Unknown command '$1'."
337
+ ;;
338
+ esac
339
+
340
+ case $WIP_COMMAND in
341
+ save)
342
+ do_save "$WIP_MESSAGE" $@
343
+ ;;
344
+ info)
345
+ do_info $@
346
+ ;;
347
+ log)
348
+ do_log $@
349
+ ;;
350
+ delete)
351
+ do_delete $@
352
+ ;;
353
+ *)
354
+ usage
355
+ exit 1
356
+ ;;
357
+ esac
358
+
359
+ # vim: set noet sw=8