learn-test 3.2.1.pre.7 → 3.3.0.pre.1

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.
@@ -0,0 +1,53 @@
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
+ expect(strategy.results).to eq(
38
+ username: username,
39
+ github_user_id: user_id,
40
+ learn_oauth_token: oauth_token,
41
+ repo_name: repo,
42
+ build: {
43
+ test_suite: [{ framework: 'none' }]
44
+ },
45
+ examples: 0,
46
+ passing_count: 0,
47
+ pending_count: 0,
48
+ failure_count: 0,
49
+ failure_descriptions: ''
50
+ )
51
+ end
52
+ end
53
+ end
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'aruba/rspec'
4
+ require 'digest'
5
+ require 'simplecov'
6
+
7
+ SimpleCov.start
8
+
3
9
  require_relative '../lib/learn_test'
10
+
4
11
  RSpec.configure do |config|
5
12
  config.expect_with :rspec do |expectations|
6
13
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
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.7
4
+ version: 3.3.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,24 +136,37 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.8.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: zeitwerk
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.4.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.4.0
139
153
  description:
140
154
  email:
141
155
  - learn@flatironschool.com
142
156
  executables:
143
157
  - learn-test
144
- - learn-test-wip
145
158
  extensions: []
146
159
  extra_rdoc_files: []
147
160
  files:
148
161
  - ".circleci/config.yml"
149
162
  - ".gitignore"
150
163
  - ".rspec"
164
+ - ".rubocop.yml"
151
165
  - Gemfile
152
166
  - LICENSE.txt
153
167
  - README.md
154
168
  - Rakefile
155
169
  - bin/learn-test
156
- - bin/learn-test-wip
157
170
  - learn-test.gemspec
158
171
  - lib/learn_test.rb
159
172
  - lib/learn_test/client.rb
@@ -168,7 +181,10 @@ files:
168
181
  - lib/learn_test/dependencies/selenium_server.rb
169
182
  - lib/learn_test/dependency.rb
170
183
  - lib/learn_test/file_finder.rb
171
- - lib/learn_test/git_wip.rb
184
+ - lib/learn_test/git.rb
185
+ - lib/learn_test/git/wip/base.rb
186
+ - lib/learn_test/git/wip/branch.rb
187
+ - lib/learn_test/git/wip/error.rb
172
188
  - lib/learn_test/github_interactor.rb
173
189
  - lib/learn_test/js_strategy.rb
174
190
  - lib/learn_test/learn_oauth_token_parser.rb
@@ -181,6 +197,7 @@ files:
181
197
  - lib/learn_test/strategies/karma.rb
182
198
  - lib/learn_test/strategies/karma/karma.conf.js
183
199
  - lib/learn_test/strategies/mocha.rb
200
+ - lib/learn_test/strategies/none.rb
184
201
  - lib/learn_test/strategies/protractor.rb
185
202
  - lib/learn_test/strategies/pytest.rb
186
203
  - lib/learn_test/strategies/pytest/requirements_checker.rb
@@ -196,14 +213,19 @@ files:
196
213
  - node_modules/karma-json-reporter/package.json
197
214
  - spec/features/rspec_unit_spec.rb
198
215
  - spec/fixtures/.netrc
216
+ - spec/fixtures/rspec-unit-spec/.results.json
199
217
  - spec/fixtures/rspec-unit-spec/.rspec
200
218
  - spec/fixtures/rspec-unit-spec/lib/dog.rb
201
219
  - spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
202
220
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
221
+ - spec/learn_test/git/wip/base_spec.rb
222
+ - spec/learn_test/git/wip/branch_spec.rb
223
+ - spec/learn_test/git/wip/error_spec.rb
203
224
  - spec/learn_test/git_spec.rb
204
225
  - spec/learn_test/reporter_spec.rb
205
226
  - spec/learn_test/username_parser_spec.rb
206
227
  - spec/lib/learn_test/strategies/mocha_spec.rb
228
+ - spec/lib/learn_test/strategies/none_spec.rb
207
229
  - spec/repo_parser_spec.rb
208
230
  - spec/spec_helper.rb
209
231
  homepage: https://github.com/learn-co/learn-test
@@ -234,13 +256,18 @@ summary: Runs RSpec, Karma, Mocha, and Python Pytest Test builds and pushes JSON
234
256
  test_files:
235
257
  - spec/features/rspec_unit_spec.rb
236
258
  - spec/fixtures/.netrc
259
+ - spec/fixtures/rspec-unit-spec/.results.json
237
260
  - spec/fixtures/rspec-unit-spec/.rspec
238
261
  - spec/fixtures/rspec-unit-spec/lib/dog.rb
239
262
  - spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
240
263
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
264
+ - spec/learn_test/git/wip/base_spec.rb
265
+ - spec/learn_test/git/wip/branch_spec.rb
266
+ - spec/learn_test/git/wip/error_spec.rb
241
267
  - spec/learn_test/git_spec.rb
242
268
  - spec/learn_test/reporter_spec.rb
243
269
  - spec/learn_test/username_parser_spec.rb
244
270
  - spec/lib/learn_test/strategies/mocha_spec.rb
271
+ - spec/lib/learn_test/strategies/none_spec.rb
245
272
  - spec/repo_parser_spec.rb
246
273
  - spec/spec_helper.rb
@@ -1,249 +0,0 @@
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='[ save <message> [ --editor | --untracked | --no-gpg-sign ] | 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
-
25
- Options for save:
26
- -e --editor - be less verbose, assume called from an editor
27
- -u --untracked - capture also untracked files
28
- -i --ignored - capture also ignored files
29
- --no-gpg-sign - do not sign commit; that is, countermand
30
- 'commit.gpgSign = true'
31
- "
32
-
33
- . "$(git --exec-path)/git-sh-setup"
34
-
35
- require_work_tree
36
-
37
- TMP=$(mktemp -d -t .git-wip)
38
-
39
- cleanup () {
40
- rm -f "$TMP-*"
41
- }
42
-
43
- trap cleanup 0
44
-
45
- WIP_INDEX="$TMP-INDEX"
46
-
47
- WIP_PREFIX=refs/wip/
48
- WIP_COMMAND=
49
- WIP_MESSAGE=WIP
50
- EDITOR_MODE=false
51
-
52
- dbg() {
53
- if test -n "$WIP_DEBUG"
54
- then
55
- printf '# %s\n' "$*"
56
- fi
57
- }
58
-
59
- # some errors are not worth reporting in --editor mode
60
- report_soft_error () {
61
- $EDITOR_MODE && exit 0
62
- die "$@"
63
- }
64
-
65
- get_work_branch () {
66
- ref=$(git symbolic-ref -q HEAD) \
67
- || report_soft_error "git-wip requires a branch"
68
-
69
-
70
- branch=${ref#refs/heads/}
71
- if [ $branch = $ref ] ; then
72
- die "git-wip requires a local branch"
73
- fi
74
-
75
- echo $branch
76
- }
77
-
78
- check_files () {
79
- local -a files="$@"
80
-
81
- for f in "${files[@]}"
82
- do
83
- [ -f "$f" -o -d "$f" ] || die "$f: No such file or directory."
84
- done
85
- }
86
-
87
- build_new_tree () {
88
- local untracked=$1 ; shift
89
- local ignored=$1 ; shift
90
- local files="$@"
91
-
92
- (
93
- set -e
94
- rm -f "$WIP_INDEX"
95
- cp -p "$GIT_DIR/index" "$WIP_INDEX"
96
- export GIT_INDEX_FILE="$WIP_INDEX"
97
- git read-tree $wip_parent
98
- if [ -n "$files" ]
99
- then
100
- git add -f "${files[@]}"
101
- else
102
- git add --update .
103
- fi
104
- [ -n "$untracked" ] && git add .
105
- [ -n "$ignored" ] && git add -f -A .
106
- git write-tree
107
- rm -f "$WIP_INDEX"
108
- )
109
- }
110
-
111
- do_save () {
112
- local msg="$1" ; shift
113
- local add_untracked=
114
- local add_ignored=
115
- local no_sign=
116
-
117
- while test $# != 0
118
- do
119
- case "$1" in
120
- -e|--editor)
121
- EDITOR_MODE=true
122
- ;;
123
- -u|--untracked)
124
- add_untracked=t
125
- ;;
126
- -i|--ignored)
127
- add_ignored=t
128
- ;;
129
- --no-gpg-sign)
130
- no_sign=--no-gpg-sign
131
- ;;
132
- --)
133
- shift
134
- break
135
- ;;
136
- *)
137
- [ -f "$1" ] && break
138
- die "Unknown option '$1'."
139
- ;;
140
- esac
141
- shift
142
- done
143
- local files="$@"
144
- local "add_untracked=$add_untracked"
145
- local "add_ignored=$add_ignored"
146
-
147
- if test ${#files} -gt 0
148
- then
149
- check_files "${files[@]}"
150
- fi
151
-
152
- dbg "msg=$msg"
153
- dbg "files=$files"
154
-
155
- local work_branch=$(get_work_branch)
156
- local wip_branch="$WIP_PREFIX$work_branch"
157
-
158
- dbg "work_branch=$work_branch"
159
- dbg "wip_branch=$wip_branch"
160
-
161
- # enable reflog
162
- local wip_branch_file="$GIT_DIR/logs/$wip_branch"
163
- dbg "wip_branch_file=$wip_branch_file"
164
- mkdir -p "$(dirname "$wip_branch_file")"
165
- : >>"$wip_branch_file"
166
-
167
- if ! work_last=$(git rev-parse --verify $work_branch)
168
- then
169
- report_soft_error "'$work_branch' branch has no commits."
170
- fi
171
-
172
- dbg "work_last=$work_last"
173
-
174
- if wip_last=$(git rev-parse --quiet --verify $wip_branch)
175
- then
176
- local base=$(git merge-base $wip_last $work_last) \
177
- || die "'work_branch' and '$wip_branch' are unrelated."
178
-
179
- if [ $base = $work_last ] ; then
180
- wip_parent=$wip_last
181
- else
182
- wip_parent=$work_last
183
- fi
184
- else
185
- wip_parent=$work_last
186
- fi
187
-
188
- dbg "wip_parent=$wip_parent"
189
-
190
- new_tree=$( build_new_tree "$add_untracked" "$add_ignored" "${files[@]}" ) \
191
- || die "Cannot save the current worktree state."
192
-
193
- dbg "new_tree=$new_tree"
194
-
195
- if git diff-tree --exit-code --quiet $new_tree $wip_parent ; then
196
- report_soft_error "no changes"
197
- fi
198
-
199
- dbg "... has changes"
200
-
201
- new_wip=$(printf '%s\n' "$msg" | git commit-tree $no_sign $new_tree -p $wip_parent 2>/dev/null) \
202
- || die "Cannot record working tree state"
203
-
204
- dbg "new_wip=$new_wip"
205
-
206
- msg1=$(printf '%s\n' "$msg" | sed -e 1q)
207
- git update-ref -m "git-wip: $msg1" $wip_branch $new_wip $wip_last
208
-
209
- dbg "SUCCESS"
210
- }
211
-
212
- if test $# -eq 0
213
- then
214
- dbg "no arguments"
215
-
216
- do_save "WIP"
217
- exit $?
218
- fi
219
-
220
- dbg "args: $@"
221
-
222
- case "$1" in
223
- save)
224
- WIP_COMMAND=$1
225
- shift
226
- if [ -n "$1" ]
227
- then
228
- WIP_MESSAGE="$1"
229
- shift
230
- fi
231
- ;;
232
- --*)
233
- ;;
234
- *)
235
- [ -f "$1" ] || die "Unknown command '$1'."
236
- ;;
237
- esac
238
-
239
- case $WIP_COMMAND in
240
- save)
241
- do_save "$WIP_MESSAGE" $@
242
- ;;
243
- *)
244
- usage
245
- exit 1
246
- ;;
247
- esac
248
-
249
- # vim: set noet sw=8
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'git'
4
- require 'logger'
5
-
6
- module LearnTest
7
- module GitWip
8
- class << self
9
- def run!(log: false)
10
- git = Git.open('./', log: log)
11
- working_branch = git.current_branch
12
-
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
21
-
22
- if wait_thr.value.exitstatus.zero?
23
- git.config['remote.origin.url'].gsub('.git', '/tree/wip')
24
- else
25
- # puts 'There was an error running learn-test-wip'
26
- false
27
- end
28
- end
29
- rescue StandardError => e
30
- false
31
- end
32
- end
33
- end
34
- end