test_diff 0.1.1 → 0.1.2
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 +8 -8
- data/lib/test_diff/run_diff.rb +21 -8
- data/lib/test_diff/storage.rb +15 -6
- data/lib/test_diff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWVkMDZlMTVhZWIwMDYzMjk1ZTM1MTc4N2ZlMDQwZjFlZWM4Mzc3Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTAzOGEwOTNkNTRjZGYwM2Q4YTZhODdjN2I4ZGQ1Y2QyZDJkZThkOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTEyNzk0OTBkZjRkNGIxM2ExOTM2YzRlZmZlZDZlY2NmZmIzNzIyOTFlZmEw
|
10
|
+
ODUxZTdjYzhlOGJjZGQ2ZDNmZWE3Y2VmNjI5ZjViZmExZWQ1OTM1OGQ5YjI4
|
11
|
+
OTljNjRmZWVkN2FjYTVlMWEzZGNjNjcyODlkODMyZGE4MjNjMGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGFhYzA4MjU2MmZkZjAyZGFlYWUwZDNlYTY0YmRhNjMwNzExNGRjZmU0Y2M3
|
14
|
+
NTlmOWE1MzMyYjM3NjM0OGZiNTQ0NWEyMzg2NDRhNTdiMDFmOGJiMzRlN2I4
|
15
|
+
NWMxZmNiNjI4MzgyOTg3OWY4NGU5ZDU3MzBlMjMwZDdjN2VkYWQ=
|
data/lib/test_diff/run_diff.rb
CHANGED
@@ -15,6 +15,7 @@ module TestDiff
|
|
15
15
|
|
16
16
|
def run
|
17
17
|
add_changed_files
|
18
|
+
remove_tests_that_do_not_exist
|
18
19
|
remove_tests_in_wrong_folder
|
19
20
|
select_test_group
|
20
21
|
run_test_group
|
@@ -37,6 +38,12 @@ module TestDiff
|
|
37
38
|
@specs_to_run = @specs_to_run.slice(group.to_i * groups_size, groups_size)
|
38
39
|
end
|
39
40
|
|
41
|
+
def remove_tests_that_do_not_exist
|
42
|
+
@specs_to_run.delete_if do |s|
|
43
|
+
!File.exist?(s)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
40
47
|
def remove_tests_in_wrong_folder
|
41
48
|
@specs_to_run.delete_if do |s|
|
42
49
|
!s.start_with?("#{spec_folder}/")
|
@@ -44,22 +51,28 @@ module TestDiff
|
|
44
51
|
end
|
45
52
|
|
46
53
|
def add_changed_files
|
47
|
-
|
48
|
-
|
54
|
+
_build_specs_to_run
|
55
|
+
|
56
|
+
@specs_to_run.flatten!
|
57
|
+
@specs_to_run.sort!
|
58
|
+
@specs_to_run.uniq!
|
59
|
+
end
|
60
|
+
|
61
|
+
def _build_specs_to_run
|
62
|
+
files = []
|
63
|
+
`git diff --name-only #{sha1} HEAD`.split("\n").each do |file_name|
|
49
64
|
if file_name.end_with?('spec.rb') || file_name.end_with?('test.rb')
|
50
65
|
@specs_to_run << file_name
|
51
66
|
elsif !file_name.start_with?(@storage.folder)
|
52
|
-
|
67
|
+
files << file_name
|
53
68
|
_add_rails_view_spec(file_name)
|
54
69
|
end
|
55
70
|
end
|
56
|
-
|
57
|
-
@specs_to_run.flatten!
|
58
|
-
@specs_to_run.sort!
|
71
|
+
_add_calculated_tests(files)
|
59
72
|
end
|
60
73
|
|
61
|
-
def _add_calculated_tests(
|
62
|
-
@specs_to_run << @storage.find_for(
|
74
|
+
def _add_calculated_tests(files)
|
75
|
+
@specs_to_run << @storage.find_for(files, spec_folder)
|
63
76
|
end
|
64
77
|
|
65
78
|
def _add_rails_view_spec(file_name)
|
data/lib/test_diff/storage.rb
CHANGED
@@ -31,10 +31,12 @@ module TestDiff
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def find_for(
|
34
|
+
def find_for(files, sub_folder = nil)
|
35
35
|
results = []
|
36
|
-
|
37
|
-
|
36
|
+
root_folder = @folder
|
37
|
+
root_folder += "/#{sub_folder}" if sub_folder
|
38
|
+
Dir["#{root_folder}/**/*.yml"].each do |storage_file|
|
39
|
+
find_for_storage_file(results, storage_file, files)
|
38
40
|
end
|
39
41
|
results
|
40
42
|
end
|
@@ -47,14 +49,21 @@ module TestDiff
|
|
47
49
|
|
48
50
|
private
|
49
51
|
|
50
|
-
def find_for_storage_file(results, storage_file,
|
52
|
+
def find_for_storage_file(results, storage_file, files)
|
51
53
|
YAML::Store.new(storage_file).transaction(true) do |store|
|
52
|
-
|
53
|
-
|
54
|
+
found_files = files & store.roots
|
55
|
+
found_files.each do |file|
|
56
|
+
if _active_file?(store[file])
|
57
|
+
results << storage_file.gsub('.yml', '').gsub("#{@folder}/", '')
|
58
|
+
end
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
def _active_file?(file)
|
64
|
+
!file.to_s.split(',').delete_if { |s| s == '' || s == '0' }.empty?
|
65
|
+
end
|
66
|
+
|
58
67
|
def get_store(file)
|
59
68
|
dir = File.dirname("#{@folder}/#{file}")
|
60
69
|
filename = File.basename(file) + '.yml'
|
data/lib/test_diff/version.rb
CHANGED