sfb_scripts 1.6 → 1.7.0
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 +4 -4
- data/bin/test_runner +1 -0
- data/lib/sfb_scripts/needs_manager.rb +2 -1
- data/lib/sfb_scripts/shells/shell_runner.rb +13 -0
- data/lib/sfb_scripts/test_running/test_collection.rb +14 -5
- data/lib/sfb_scripts/test_running/test_runner.rb +21 -8
- data/lib/sfb_scripts/version.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f85e393c87cefd7c1457d0cdb1ef0e4701619a34
|
4
|
+
data.tar.gz: d6dfb9262c26a4914f92a6bb0aa4cb7ee0830c84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d350584195bd7d960fb1c635a3e72f0c7de42fbffeecf8332fc987d80176b58a68d3230dae49152431903ae85808f05b97e8f9d2e9ad99242a9f954f6a73319b
|
7
|
+
data.tar.gz: eedf607c18f39d291863208cf6d777a5fbc1d7f834236060b416fe536f104f2c77a08173aa57cbd8a001960539a720499965084bf87c851d5ffc907115aa330b
|
data/bin/test_runner
CHANGED
@@ -22,6 +22,7 @@ class CLI < Thor
|
|
22
22
|
desc "find", <<-DESC
|
23
23
|
Find tests and run them. By trying to match an individual test or the name of a test file(s).
|
24
24
|
DESC
|
25
|
+
option :timid, type: :boolean, desc: "Always ask user which tests to run if multiple test files are found. Defaults to false", default: false
|
25
26
|
def find(input)
|
26
27
|
if input == '--help'
|
27
28
|
puts "use 'test_runner --help find' to see the help"
|
@@ -39,6 +39,19 @@ class ShellRunner
|
|
39
39
|
return answer != 'n'
|
40
40
|
end
|
41
41
|
|
42
|
+
def get_number_list_for_question(question)
|
43
|
+
warn question
|
44
|
+
answer = STDIN.gets.strip
|
45
|
+
|
46
|
+
answer.split(',').map do |term|
|
47
|
+
if term.include?('-')
|
48
|
+
(term.split('-')[0].to_i..term.split('-')[1].to_i).to_a
|
49
|
+
else
|
50
|
+
term.to_i
|
51
|
+
end
|
52
|
+
end.flatten
|
53
|
+
end
|
54
|
+
|
42
55
|
def deny?(question)
|
43
56
|
! confirm?(question)
|
44
57
|
end
|
@@ -7,11 +7,16 @@ class TestCollection
|
|
7
7
|
def initialize(tests_data=[], query: '')
|
8
8
|
@query = query
|
9
9
|
@tests = tests_data.map do |test_data|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
if test_data.is_a? TestCase
|
11
|
+
test_data
|
12
|
+
else
|
13
|
+
test_data = {file: test_data} if test_data.is_a?(String)
|
14
|
+
|
15
|
+
TestCase.new(
|
16
|
+
full_path: test_data[:file],
|
17
|
+
line: test_data[:line]
|
18
|
+
)
|
19
|
+
end
|
15
20
|
end.compact
|
16
21
|
end
|
17
22
|
|
@@ -19,6 +24,10 @@ class TestCollection
|
|
19
24
|
tests.empty?
|
20
25
|
end
|
21
26
|
|
27
|
+
def uniq!
|
28
|
+
@tests = @tests.uniq {|e| "#{e.full_path} #{e.test_name} #{e.working_dir}" }
|
29
|
+
end
|
30
|
+
|
22
31
|
def present?
|
23
32
|
! empty?
|
24
33
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class TestRunner
|
2
2
|
|
3
|
-
attr_reader :shell, :all_engines_param
|
3
|
+
attr_reader :shell, :all_engines_param, :always_ask_before_grouping_tests
|
4
4
|
def initialize(env)
|
5
5
|
@shell = env[:shell]
|
6
6
|
@all_engines_param = env[:all_engines]
|
7
|
+
@always_ask_before_grouping_tests = env[:always_ask_before_grouping_tests]
|
7
8
|
end
|
8
9
|
|
9
10
|
# Hack: this could use *a lot* of love
|
@@ -17,7 +18,8 @@ class TestRunner
|
|
17
18
|
elsif tests.is_one_test_method?
|
18
19
|
test = tests.first
|
19
20
|
run_method(path: test.relative_path, name: test.test_name, dir: test.working_dir)
|
20
|
-
|
21
|
+
elsif always_ask_before_grouping_tests
|
22
|
+
ask_user_which_tests_to_run(tests)
|
21
23
|
elsif tests.in_one_file? && tests.all? {|t| t.is_method? }
|
22
24
|
shell.notify "Multiple matches in same file. Running those tests"
|
23
25
|
test = tests.first
|
@@ -32,20 +34,31 @@ class TestRunner
|
|
32
34
|
run_files(tests)
|
33
35
|
|
34
36
|
else
|
35
|
-
|
36
|
-
tests[0..10].each {|t| shell.notify "#{t.full_path}: #{t.test_name}" }
|
37
|
-
shell.notify '...'
|
38
|
-
exit
|
39
|
-
|
37
|
+
ask_user_which_tests_to_run(tests)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
41
|
def run_method(path:, name:, dir:)
|
44
42
|
test_runner = named_test_runner(dir)
|
45
|
-
|
46
43
|
shell.exec("#{test_runner} #{path} --name=/#{name}/", dir: dir)
|
47
44
|
end
|
48
45
|
|
46
|
+
def ask_user_which_tests_to_run(tests)
|
47
|
+
shell.warn 'Found too many tests. Please choose which matches you would like to run:'
|
48
|
+
|
49
|
+
tests.uniq!.each_with_index do |t, index|
|
50
|
+
shell.notify "(#{index}) #{t.full_path}: #{t.test_name}"
|
51
|
+
end
|
52
|
+
|
53
|
+
tests_to_run = shell.get_number_list_for_question('Please enter the match numbers you would like to run(comma seperated)')
|
54
|
+
|
55
|
+
new_tests = tests_to_run.map do |index|
|
56
|
+
tests[index]
|
57
|
+
end
|
58
|
+
@always_ask_before_grouping_tests = false
|
59
|
+
run(TestCollection.new(new_tests))
|
60
|
+
end
|
61
|
+
|
49
62
|
def run_files(tests)
|
50
63
|
begin
|
51
64
|
test_runner = test_collection_runner(tests.working_dir)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfb_scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/sfb_scripts/test_running/test_runner.rb
|
87
87
|
- lib/sfb_scripts/tester.rb
|
88
88
|
- lib/sfb_scripts/upper.rb
|
89
|
+
- lib/sfb_scripts/version.rb
|
89
90
|
homepage: http://github.com/petekinnecom/sfb_scripts/
|
90
91
|
licenses:
|
91
92
|
- MIT
|