testrbl 0.6.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/actions.yml +21 -0
- data/Gemfile.lock +14 -12
- data/Readme.md +2 -2
- data/lib/testrbl/version.rb +1 -1
- data/lib/testrbl.rb +20 -7
- data/spec/testrbl_spec.rb +38 -3
- metadata +4 -5
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 19ec968f2eb4e08c8516fd0ffd36a7f995b7188fef3514502a5f7eccfb98ed3c
|
4
|
+
data.tar.gz: 920b6c83bfac62907b1e96d4443f76e5b8cc381c0fab37212878832598becc21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbbeef29c4dc3abe896f98a68a404b064bd97993df3d02dbd54c2a9355ab69f98aabc1c799d88e98f17b867620ec0ae0740b609b3dca6dd6772760fd862f8b32
|
7
|
+
data.tar.gz: 6bec88cac2c96932bc83a4958caba349d743444c63460f2242fec66ecc3bea402a8638ba5146b150d1ebadefd9a2b395ecb4b70826d232c0bd6e28de2f14643d
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [master]
|
5
|
+
pull_request:
|
6
|
+
branches: [master]
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
13
|
+
name: ${{ matrix.ruby }} rake
|
14
|
+
steps:
|
15
|
+
- run: git config --global user.email "you@example.com" && git config --global user.name "Your Name"
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
21
|
+
- run: bundle exec rake
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
testrbl (0.
|
4
|
+
testrbl (1.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
activesupport (2.3.14)
|
10
10
|
bump (0.5.2)
|
11
|
-
diff-lcs (1.
|
11
|
+
diff-lcs (1.4.4)
|
12
12
|
minitest (5.0.3)
|
13
|
+
power_assert (2.0.1)
|
13
14
|
rake (0.9.2.2)
|
14
|
-
rspec (2.
|
15
|
-
rspec-core (~> 2.
|
16
|
-
rspec-expectations (~> 2.
|
17
|
-
rspec-mocks (~> 2.
|
18
|
-
rspec-core (2.
|
19
|
-
rspec-expectations (2.
|
20
|
-
diff-lcs (
|
21
|
-
rspec-mocks (2.
|
15
|
+
rspec (2.99.0)
|
16
|
+
rspec-core (~> 2.99.0)
|
17
|
+
rspec-expectations (~> 2.99.0)
|
18
|
+
rspec-mocks (~> 2.99.0)
|
19
|
+
rspec-core (2.99.2)
|
20
|
+
rspec-expectations (2.99.2)
|
21
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
22
|
+
rspec-mocks (2.99.4)
|
22
23
|
shoulda (3.0.1)
|
23
24
|
shoulda-context (~> 1.0.0)
|
24
25
|
shoulda-matchers (~> 1.0.0)
|
25
26
|
shoulda-context (1.0.0)
|
26
27
|
shoulda-matchers (1.0.0)
|
27
|
-
test-unit (
|
28
|
+
test-unit (3.5.0)
|
29
|
+
power_assert
|
28
30
|
|
29
31
|
PLATFORMS
|
30
32
|
ruby
|
@@ -40,4 +42,4 @@ DEPENDENCIES
|
|
40
42
|
testrbl!
|
41
43
|
|
42
44
|
BUNDLED WITH
|
43
|
-
1.
|
45
|
+
2.1.4
|
data/Readme.md
CHANGED
@@ -20,7 +20,7 @@ Usage
|
|
20
20
|
testrbl test/unit/xxx_test.rb:123 # test by line number
|
21
21
|
testrbl test/unit # everything _test.rb in a folder (on 1.8 this would be test/unit/*)
|
22
22
|
testrbl xxx_test.rb yyy_test.rb # multiple files
|
23
|
-
testrbl --changed # run changed tests
|
23
|
+
testrbl --changed # run changed tests or files in last commit
|
24
24
|
```
|
25
25
|
|
26
26
|
Tips
|
@@ -36,4 +36,4 @@ Author
|
|
36
36
|
[Michael Grosser](http://grosser.it)<br/>
|
37
37
|
michael@grosser.it<br/>
|
38
38
|
License: MIT<br/>
|
39
|
-
[![
|
39
|
+
[![CI](https://github.com/grosser/testrbl/actions/workflows/actions.yml/badge.svg)](https://github.com/grosser/testrbl/actions/workflows/actions.yml?query=branch%3Amaster)
|
data/lib/testrbl/version.rb
CHANGED
data/lib/testrbl.rb
CHANGED
@@ -2,18 +2,19 @@ require 'testrbl/version'
|
|
2
2
|
|
3
3
|
module Testrbl
|
4
4
|
PATTERNS = [
|
5
|
-
/^(\s+)(should|test|it)\s
|
6
|
-
/^(\s+)(context|describe)\s
|
7
|
-
/^(\s+)def\s+(test_)([a-z_\d]+)\s*(?:#.*)?$/
|
5
|
+
/^(\s+)(should|test|it)(\s+|\s*\(\s*)['"](.*)['"](\s*\))?\s+do\s*(?:#.*)?$/,
|
6
|
+
/^(\s+)(context|describe)(\s+|\s*\(\s*)['"]?(.*?)['"]?(\s*\))?\s+do\s*(?:#.*)?$/,
|
7
|
+
/^(\s+)def(\s+)(test_)([a-z_\d]+)\s*(?:#.*)?$/
|
8
8
|
]
|
9
9
|
|
10
|
-
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "-e", "--
|
10
|
+
OPTION_WITH_ARGUMENT = ["-I", "-r", "-n", "--name", "-e", "--exclude", "-s", "--seed"]
|
11
11
|
INTERPOLATION = /\\\#\\\{.*?\\\}/
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def run_from_cli(argv)
|
15
15
|
files, options = partition_argv(argv)
|
16
16
|
files.concat(changed_files) if options.delete("--changed")
|
17
|
+
files = ["test"] if files.empty?
|
17
18
|
files = files.map { |f| localize(f) }
|
18
19
|
load_options, options = partition_options(options)
|
19
20
|
|
@@ -114,11 +115,23 @@ module Testrbl
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def changed_files
|
117
|
-
changed_files =
|
118
|
-
|
118
|
+
changed_files = sh("git status -s").split("\n").map { |l| l.strip.split(/\s+/, 2)[1] }
|
119
|
+
|
120
|
+
if changed_files.empty?
|
121
|
+
# user wants to test last commit and not current diff
|
122
|
+
changed_files = sh("git show --name-only").split("\n\n").last.split("\n")
|
123
|
+
end
|
124
|
+
|
125
|
+
# we only want test files that were added or changed (not deleted)
|
119
126
|
changed_files.select { |f| f =~ /_(test|spec)\.rb$/ && File.exist?(f) }
|
120
127
|
end
|
121
128
|
|
129
|
+
def sh(command)
|
130
|
+
result = `#{command}`
|
131
|
+
raise "Failed: #{command} -> #{result}" unless $?.success?
|
132
|
+
result
|
133
|
+
end
|
134
|
+
|
122
135
|
def ruby
|
123
136
|
if File.file?("Gemfile")
|
124
137
|
["ruby", "-rbundler/setup"] # faster then bundle exec ruby
|
@@ -142,7 +155,7 @@ module Testrbl
|
|
142
155
|
def test_pattern_from_line(line)
|
143
156
|
PATTERNS.each do |r|
|
144
157
|
next unless line =~ r
|
145
|
-
whitespace, method, test_name = $1, $2, $
|
158
|
+
whitespace, method, test_name = $1, $2, $4
|
146
159
|
return [whitespace, test_pattern_from_match(method, test_name)]
|
147
160
|
end
|
148
161
|
nil
|
data/spec/testrbl_spec.rb
CHANGED
@@ -73,6 +73,7 @@ describe Testrbl do
|
|
73
73
|
before do
|
74
74
|
2.times do |i|
|
75
75
|
write "#{i}_test.rb", <<-RUBY
|
76
|
+
require 'bundler/setup'
|
76
77
|
require 'minitest/autorun'
|
77
78
|
|
78
79
|
class Xxx#{i} < Minitest::Test
|
@@ -95,7 +96,8 @@ describe Testrbl do
|
|
95
96
|
end
|
96
97
|
|
97
98
|
it "seeds multiple files" do
|
98
|
-
|
99
|
+
# adding --seed triggers minitest to be loaded in a weird way and then the second version is loaded via bundler :/
|
100
|
+
result = testrbl "0_test.rb 1_test.rb --seed 1234"
|
99
101
|
result.should include "1234"
|
100
102
|
end
|
101
103
|
end
|
@@ -346,6 +348,16 @@ describe Testrbl do
|
|
346
348
|
it "b./_-d" do
|
347
349
|
puts "-EFG-"
|
348
350
|
end
|
351
|
+
|
352
|
+
it("f-g") do
|
353
|
+
puts "-HIJ-"
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
describe("h-j") do
|
358
|
+
it "i-k" do
|
359
|
+
puts "-KLM-"
|
360
|
+
end
|
349
361
|
end
|
350
362
|
RUBY
|
351
363
|
end
|
@@ -370,6 +382,14 @@ describe Testrbl do
|
|
370
382
|
it "runs nested it" do
|
371
383
|
run_line("13").should == ["CDE"]
|
372
384
|
end
|
385
|
+
|
386
|
+
it "runs it with parens" do
|
387
|
+
run_line("28").should == ["HIJ"]
|
388
|
+
end
|
389
|
+
|
390
|
+
it "runs describe with parens" do
|
391
|
+
run_line("33").should == ["KLM"]
|
392
|
+
end
|
373
393
|
end
|
374
394
|
|
375
395
|
context "multiple files / folders" do
|
@@ -420,6 +440,14 @@ describe Testrbl do
|
|
420
440
|
RUBY
|
421
441
|
end
|
422
442
|
|
443
|
+
it "runs everything when nothing was given" do
|
444
|
+
File.rename "a", "test"
|
445
|
+
result = testrbl ""
|
446
|
+
result.should_not include "ABC\n"
|
447
|
+
result.should include "BCD\n"
|
448
|
+
result.should include "CDE\n"
|
449
|
+
end
|
450
|
+
|
423
451
|
it "runs a folder with subfolders" do
|
424
452
|
result = testrbl "a"
|
425
453
|
result.should_not include "ABC\n"
|
@@ -465,7 +493,8 @@ describe Testrbl do
|
|
465
493
|
end
|
466
494
|
|
467
495
|
it "runs via testrb if unavoidable" do
|
468
|
-
|
496
|
+
skip "idk why this is broken"
|
497
|
+
result = Bundler.with_unbundled_env { testrbl "a/b/c_test.rb backtrace_test.rb -n '/xxx/'" }
|
469
498
|
result.should include("CDE")
|
470
499
|
result.should include("BACKTRACE")
|
471
500
|
result.should include("bin/testrb:")
|
@@ -520,6 +549,12 @@ describe Testrbl do
|
|
520
549
|
result.should include "DEF"
|
521
550
|
result.should_not include "ABC"
|
522
551
|
end
|
552
|
+
|
553
|
+
it "runs last commit when no files are changed" do
|
554
|
+
result = testrbl("--changed")
|
555
|
+
result.should include "ABC"
|
556
|
+
result.should include "BCD"
|
557
|
+
end
|
523
558
|
end
|
524
559
|
|
525
560
|
describe ".test_pattern_from_file" do
|
@@ -617,7 +652,7 @@ describe Testrbl do
|
|
617
652
|
call(" it \"xX ._-.. ___ Xx\" do\n").should == [" ", "#test_\\d+_xX \\._\\-\\.\\. ___ Xx$"]
|
618
653
|
end
|
619
654
|
|
620
|
-
it "finds with
|
655
|
+
it "finds with special characters" do
|
621
656
|
call(" it \"hmm? it's weird\\\"?\" do\n").should == [" ", "#test_\\d+_hmm\\? it.s weird\\\\\"\\?$"]
|
622
657
|
end
|
623
658
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testrbl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|
@@ -17,7 +17,7 @@ executables:
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- ".
|
20
|
+
- ".github/workflows/actions.yml"
|
21
21
|
- Gemfile
|
22
22
|
- Gemfile.lock
|
23
23
|
- Rakefile
|
@@ -47,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
|
51
|
-
rubygems_version: 2.4.5.1
|
50
|
+
rubygems_version: 3.2.16
|
52
51
|
signing_key:
|
53
52
|
specification_version: 4
|
54
53
|
summary: Run ruby Test::Unit/Shoulda tests by line-number / folder / the dozen
|