collateral_cucumber 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/collateralizer.rb +36 -0
- data/lib/exec.rb +19 -0
- data/lib/ff_interaction.rb +56 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 733d1a905b47169727e532883fbf8eca3304ea81b882f2bee6c83770762e2dae
|
4
|
+
data.tar.gz: 6b983a9d604ca7883a4d4f038b47a8e09b85b35161b68017de538457825cedfb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22f9f97ef5110a4251da9ce1f4a3be8fd465542184cb91b6005856e147eb4b68b87aea9e631823aed412c9e62e31963f86a81a81c731565e25a349f40c6a9c18
|
7
|
+
data.tar.gz: 5400308da22a7815d2374c45d459eda920fdb82ed6a639f3f5166e9e807af3f2aec3b9aa5e9db99716c91b4df18bc08932a30568d8caa1a44dcae05c14642319
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Collateralizer
|
2
|
+
def total_builds
|
3
|
+
ENV['total_number_of_builds'].to_i
|
4
|
+
end
|
5
|
+
|
6
|
+
def build_number
|
7
|
+
ENV['build_number'].to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def job_splitter(scenarios)
|
11
|
+
split = scenarios.length.to_i / total_builds.to_i
|
12
|
+
|
13
|
+
container = []
|
14
|
+
total_builds.times { container.push([]) }
|
15
|
+
mod_scenarios = scenarios.clone
|
16
|
+
|
17
|
+
total_builds.times do |index|
|
18
|
+
container[index].push(mod_scenarios[0..(split - 1)])
|
19
|
+
container[index].flatten!
|
20
|
+
|
21
|
+
(0..(split - 1)).to_a.length.times do
|
22
|
+
mod_scenarios.delete_at(0)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
mod_scenarios.each_with_index do |value, index|
|
27
|
+
container[index].push(value)
|
28
|
+
end
|
29
|
+
container
|
30
|
+
end
|
31
|
+
|
32
|
+
def job_assigner(scenarios)
|
33
|
+
scenarios[(build_number - 1)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/lib/exec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'collateralizer'
|
2
|
+
require 'ff_interaction'
|
3
|
+
|
4
|
+
class Executor
|
5
|
+
attr_accessor(:col, :ffi, :file_location, :test_tag)
|
6
|
+
|
7
|
+
def initialize(file_location = "features", test_tag = "regression")
|
8
|
+
@col = Collateralizer.new
|
9
|
+
@ffi = FFInteraction.new(test_tag)
|
10
|
+
@file_location = file_location
|
11
|
+
end
|
12
|
+
|
13
|
+
def exec(actual_mod: true)
|
14
|
+
scenarios = ffi.feature_iterator(file_location)
|
15
|
+
splits = col.job_splitter(scenarios)
|
16
|
+
assignment = col.job_assigner(splits)
|
17
|
+
ffi.feature_mod_iterator(assignment, file_location, actual_mod)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class FFInteraction
|
2
|
+
#feature file interaction class
|
3
|
+
|
4
|
+
attr_accessor(:tag)
|
5
|
+
|
6
|
+
def initialize(tag = "@regression")
|
7
|
+
@tag = tag
|
8
|
+
end
|
9
|
+
|
10
|
+
def feature_mod_iterator(split_assignment, current_location = 'features', assign = true)
|
11
|
+
output_array = []
|
12
|
+
split_assignment.each do |value|
|
13
|
+
mod_value = value.gsub(tag, '@split_builds')
|
14
|
+
search_regex = /#{value}$/
|
15
|
+
files = return_all_files(current_location, '*', 'feature')
|
16
|
+
mod_scenario_tagging(search_regex, mod_value, assign, files, output_array)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def mod_scenario_tagging(regex, mod_value, assign, files, output_array)
|
21
|
+
files.each do |file|
|
22
|
+
output = File.open(file, 'r', &:read)
|
23
|
+
modified = output.gsub(regex, mod_value)
|
24
|
+
if assign
|
25
|
+
File.open(file, 'w+') { |f| f.print(modified) }
|
26
|
+
else
|
27
|
+
output_array.push(modified)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
output_array
|
31
|
+
end
|
32
|
+
|
33
|
+
def feature_iterator(current_location = 'features')
|
34
|
+
files = return_all_files(current_location, '*', 'feature')
|
35
|
+
array = []
|
36
|
+
files.each do |file|
|
37
|
+
array.push(return_all_gherkin_scenarios(file))
|
38
|
+
end
|
39
|
+
array.flatten
|
40
|
+
end
|
41
|
+
|
42
|
+
def return_all_gherkin_scenarios(file)
|
43
|
+
output = File.open(file, 'r', &:read)
|
44
|
+
output.scan(/(#{tag}\s*(.*\n) (Scenario:|Scenario Outline:)?.*)/).map { |value| value[0] }
|
45
|
+
end
|
46
|
+
|
47
|
+
def return_all_files(current_location, filter = '*', file_type = '*')
|
48
|
+
Dir.glob("#{current_location}/**/#{filter}.#{file_type}")
|
49
|
+
end
|
50
|
+
|
51
|
+
#may be implemented in V2
|
52
|
+
# def regex_generation(value)
|
53
|
+
# par_mod = value.gsub('(', '\(').gsub(')', '\)')
|
54
|
+
# regex = /#{par_mod}/
|
55
|
+
# end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: collateral_cucumber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jerren Every
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby Gem for splitting Cucumber tests out based on tagging
|
14
|
+
email: jerren1122@hotmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/collateralizer.rb
|
20
|
+
- lib/exec.rb
|
21
|
+
- lib/ff_interaction.rb
|
22
|
+
homepage: ''
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.7.6.2
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Ruby Gem for splitting Cucumber tests out based on tagging
|
46
|
+
test_files: []
|