fixman 0.1.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 +7 -0
- data/History.txt +6 -0
- data/Manifest.txt +23 -0
- data/README.md +176 -0
- data/Rakefile +19 -0
- data/bin/fixman +50 -0
- data/lib/fixman.rb +13 -0
- data/lib/fixman/command_line.rb +184 -0
- data/lib/fixman/configuration.rb +161 -0
- data/lib/fixman/controller.rb +121 -0
- data/lib/fixman/raw_task.rb +103 -0
- data/lib/fixman/repository.rb +99 -0
- data/lib/fixman/task.rb +19 -0
- data/lib/fixman/task_parse_error.rb +12 -0
- data/lib/fixman/tester.rb +69 -0
- data/lib/fixman/utilities.rb +8 -0
- data/test/test_command_line.rb +250 -0
- data/test/test_configuration.rb +58 -0
- data/test/test_controller.rb +16 -0
- data/test/test_fixman.rb +7 -0
- data/test/test_raw_task.rb +97 -0
- data/test/test_repository.rb +21 -0
- data/test/test_task.rb +28 -0
- data/test/test_tester.rb +89 -0
- metadata +163 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'fixman'
|
2
|
+
require 'minitest'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
class TestRawTask < MiniTest::Test
|
6
|
+
def setup
|
7
|
+
@params = {
|
8
|
+
name: 'task',
|
9
|
+
target_placeholder: 'TARGET'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_refine
|
14
|
+
# Vanilla case
|
15
|
+
params = @params.merge({
|
16
|
+
command: {
|
17
|
+
action: 'true',
|
18
|
+
exit_status: 0,
|
19
|
+
}
|
20
|
+
})
|
21
|
+
raw_task = Fixman::RawTask.new params
|
22
|
+
tasks = raw_task.refine
|
23
|
+
assert_equal 1, tasks.size
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_substitute_variables
|
27
|
+
params = @params.merge({
|
28
|
+
command: {
|
29
|
+
action: 'true V1 V2 TARGET',
|
30
|
+
exit_status: 0,
|
31
|
+
},
|
32
|
+
variables: [
|
33
|
+
{ key: 'V1', values: ['1', '2', '3'] },
|
34
|
+
{ key: 'V2', values: ['1', '3'] },
|
35
|
+
]
|
36
|
+
})
|
37
|
+
raw_task = Fixman::RawTask.new params
|
38
|
+
expected_actions = Set.new [
|
39
|
+
'true 1 1 TARGET',
|
40
|
+
'true 1 3 TARGET',
|
41
|
+
'true 2 1 TARGET',
|
42
|
+
'true 2 3 TARGET',
|
43
|
+
'true 3 1 TARGET',
|
44
|
+
'true 3 3 TARGET',
|
45
|
+
]
|
46
|
+
assert_equal expected_actions, raw_task.send(:substitute_variables).to_set
|
47
|
+
|
48
|
+
params[:variables] = [ { key: 'X', values: ['1', '2', '3'] } ]
|
49
|
+
raw_task = Fixman::RawTask.new params
|
50
|
+
expected_actions = [ 'true V1 V2 TARGET' ]
|
51
|
+
assert_equal expected_actions, raw_task.send(:substitute_variables)
|
52
|
+
|
53
|
+
# TODO test empty values array for an existing variable key
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_shell_to_proc
|
57
|
+
raw_task = Fixman::RawTask.new @params
|
58
|
+
|
59
|
+
p = raw_task.send(:shell_to_proc, 'true', 0)
|
60
|
+
assert_equal true, p.call
|
61
|
+
|
62
|
+
p = raw_task.send(:shell_to_proc, 'true', 200)
|
63
|
+
assert_equal false, p.call
|
64
|
+
|
65
|
+
p = raw_task.send(:shell_to_proc, 'false', 0)
|
66
|
+
assert_equal false, p.call
|
67
|
+
|
68
|
+
p = raw_task.send(:shell_to_proc, 'false', 1)
|
69
|
+
assert_equal true, p.call
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_refine_condition
|
73
|
+
raw_task = Fixman::RawTask.new @params
|
74
|
+
p = raw_task.send(:refine_condition)
|
75
|
+
assert_equal Proc, p.class
|
76
|
+
assert_equal true, p.call
|
77
|
+
|
78
|
+
params = @params.merge({
|
79
|
+
condition: {
|
80
|
+
type: :ruby,
|
81
|
+
action: 'proc { "test me" }'
|
82
|
+
}
|
83
|
+
})
|
84
|
+
raw_task = Fixman::RawTask.new params
|
85
|
+
p = raw_task.send(:refine_condition)
|
86
|
+
assert_equal 'test me', p.call
|
87
|
+
|
88
|
+
params[:condition] = {
|
89
|
+
type: :shell,
|
90
|
+
action: 'false',
|
91
|
+
exit_status: 1
|
92
|
+
}
|
93
|
+
raw_task = Fixman::RawTask.new params
|
94
|
+
p = raw_task.send(:refine_condition)
|
95
|
+
assert_equal true, p.call
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fixman'
|
2
|
+
require 'minitest'
|
3
|
+
|
4
|
+
class TestRepository < Minitest::Test
|
5
|
+
def test_extract_name_owner
|
6
|
+
url = 'http://www.github.com/madgen/fixman'
|
7
|
+
owner, name = Fixman::Repository.extract_owner_and_name(url)
|
8
|
+
assert_equal 'madgen', owner
|
9
|
+
assert_equal 'fixman', name
|
10
|
+
|
11
|
+
url = 'http://www.github.com/matz/ruby.git'
|
12
|
+
owner, name = Fixman::Repository.extract_owner_and_name(url)
|
13
|
+
assert_equal 'matz', owner
|
14
|
+
assert_equal 'ruby', name
|
15
|
+
|
16
|
+
url = 'http://www.hithub.com/matz/ruby.git'
|
17
|
+
owner, name = Fixman::Repository.extract_owner_and_name(url)
|
18
|
+
assert_equal nil, owner
|
19
|
+
assert_equal nil, name
|
20
|
+
end
|
21
|
+
end
|
data/test/test_task.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fixman'
|
2
|
+
require 'minitest'
|
3
|
+
|
4
|
+
class TestTask < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@t_proc = proc { true }
|
7
|
+
@f_proc = proc { false }
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_vanilla_run
|
11
|
+
task = Fixman::Task.new 'Task', @t_proc, @t_proc, @t_proc
|
12
|
+
assert_equal true, task.run('vanilla_target')
|
13
|
+
|
14
|
+
task = Fixman::Task.new 'Task', @t_proc, @f_proc, @t_proc
|
15
|
+
assert_equal false, task.run('vanilla_target')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_run_with_cleanup
|
19
|
+
counter = [0]
|
20
|
+
cleanup = proc { |c| c[0] += 2 }
|
21
|
+
|
22
|
+
task = Fixman::Task.new 'Task', @t_proc, @t_proc, cleanup
|
23
|
+
task.run counter
|
24
|
+
assert_equal 2, counter[0]
|
25
|
+
task.run counter
|
26
|
+
assert_equal 4, counter[0]
|
27
|
+
end
|
28
|
+
end
|
data/test/test_tester.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'fixman'
|
2
|
+
require 'minitest'
|
3
|
+
require 'set'
|
4
|
+
require 'pry'
|
5
|
+
require 'pry-byebug'
|
6
|
+
|
7
|
+
class TestTester < Minitest::Test
|
8
|
+
def setup
|
9
|
+
fixtures_base = Pathname.new(Dir.pwd) + 'test' + 'fixtures'
|
10
|
+
fixture_ledger = ''
|
11
|
+
raw_tasks = []
|
12
|
+
extra_repo_info = nil
|
13
|
+
groups = nil
|
14
|
+
@conf = Fixman::Configuration.new(fixtures_base,
|
15
|
+
fixture_ledger,
|
16
|
+
raw_tasks,
|
17
|
+
groups,
|
18
|
+
extra_repo_info)
|
19
|
+
@condition = proc { |target| target.to_s =~ /\/a.*\.txt/ }
|
20
|
+
path_to_repo = Pathname.new(Dir.pwd) + 'test' + 'fixtures' + 'example_repo'
|
21
|
+
@expected_targets = ['a123.txt', 'a124.txt', 'a125.txt'].map do |filename|
|
22
|
+
path_to_repo + filename
|
23
|
+
end
|
24
|
+
@expected_targets += ['abc.txt', 'add.txt'].map do |filename|
|
25
|
+
path_to_repo + 'sub' + filename
|
26
|
+
end
|
27
|
+
@cleanup = @command = proc { true }
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_collect
|
31
|
+
condition = proc { false }
|
32
|
+
tester = Fixman::Tester.new @conf
|
33
|
+
targets = tester.send(:collect, condition)
|
34
|
+
assert_equal [], targets
|
35
|
+
|
36
|
+
tester = Fixman::Tester.new @conf
|
37
|
+
targets = tester.send(:collect, @condition)
|
38
|
+
assert_equal @expected_targets.to_set, targets.to_set
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_test_task_condition_is_applied
|
42
|
+
tester = Fixman::Tester.new @conf
|
43
|
+
task = Fixman::Task.new 'test_task', @condition, @command, @cleanup
|
44
|
+
expected_result = tester.send(:report, 'test_task', @expected_targets, [])
|
45
|
+
assert_output(output_for_test_task(task)) do
|
46
|
+
assert_equal expected_result, tester.send(:test_task, task)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_test_task_notes_failures
|
51
|
+
tester = Fixman::Tester.new @conf
|
52
|
+
raw_task = Fixman::RawTask.new({
|
53
|
+
name: 'test_task',
|
54
|
+
target_placeholder: 'TARGET',
|
55
|
+
command: {
|
56
|
+
action: 'echo TARGET | sed "s/12//; t suc; q 1; :suc q 0" > /dev/null',
|
57
|
+
exit_status: 0
|
58
|
+
},
|
59
|
+
condition: {
|
60
|
+
type: :ruby,
|
61
|
+
action: 'proc { true }',
|
62
|
+
},
|
63
|
+
cleanup: {
|
64
|
+
type: :ruby,
|
65
|
+
action: 'proc { true }',
|
66
|
+
}
|
67
|
+
})
|
68
|
+
|
69
|
+
task = raw_task.refine.first
|
70
|
+
task.instance_variable_set :@condition, @condition
|
71
|
+
assert_output(output_for_test_task(task)) do
|
72
|
+
tester.send(:test_task, task)
|
73
|
+
end
|
74
|
+
failures = @expected_targets.select do |target|
|
75
|
+
!(target.to_s =~ /12/)
|
76
|
+
end
|
77
|
+
expected_result = tester.send(:report, 'test_task', @expected_targets, failures)
|
78
|
+
assert_output(output_for_test_task(task)) do
|
79
|
+
assert_equal expected_result, tester.send(:test_task, task)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def output_for_test_task task
|
84
|
+
<<-HERE.gsub(/^\s+/, '')
|
85
|
+
Collecting targets for #{task.name}...
|
86
|
+
Running the #{task.name} on targets...
|
87
|
+
HERE
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fixman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mistral Contrastin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: classy_hash
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: git
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hoe
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.14'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.14'
|
97
|
+
description: |-
|
98
|
+
THIS PROJECT IS NOT YET READY FOR USAGE!
|
99
|
+
|
100
|
+
A tool to test source code analysis command line tools against source code
|
101
|
+
remotely available in git repositories such as GitHub.
|
102
|
+
email:
|
103
|
+
- madgenhetic@gmail.com
|
104
|
+
executables:
|
105
|
+
- fixman
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files:
|
108
|
+
- History.txt
|
109
|
+
- Manifest.txt
|
110
|
+
- README.md
|
111
|
+
files:
|
112
|
+
- History.txt
|
113
|
+
- Manifest.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/fixman
|
117
|
+
- lib/fixman.rb
|
118
|
+
- lib/fixman/command_line.rb
|
119
|
+
- lib/fixman/configuration.rb
|
120
|
+
- lib/fixman/controller.rb
|
121
|
+
- lib/fixman/raw_task.rb
|
122
|
+
- lib/fixman/repository.rb
|
123
|
+
- lib/fixman/task.rb
|
124
|
+
- lib/fixman/task_parse_error.rb
|
125
|
+
- lib/fixman/tester.rb
|
126
|
+
- lib/fixman/utilities.rb
|
127
|
+
- test/test_command_line.rb
|
128
|
+
- test/test_configuration.rb
|
129
|
+
- test/test_controller.rb
|
130
|
+
- test/test_fixman.rb
|
131
|
+
- test/test_raw_task.rb
|
132
|
+
- test/test_repository.rb
|
133
|
+
- test/test_task.rb
|
134
|
+
- test/test_tester.rb
|
135
|
+
homepage: https://github.com/madgen/fixman
|
136
|
+
licenses:
|
137
|
+
- Apache
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options:
|
141
|
+
- "--main"
|
142
|
+
- README.md
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.4.8
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: THIS PROJECT IS NOT YET READY FOR USAGE! A tool to test source code analysis
|
161
|
+
command line tools against source code remotely available in git repositories such
|
162
|
+
as GitHub.
|
163
|
+
test_files: []
|