koboldy 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/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +136 -0
- data/Rakefile +2 -0
- data/koboldy.gemspec +24 -0
- data/lib/koboldy.rb +4 -0
- data/lib/koboldy/conf.rb +106 -0
- data/lib/koboldy/io.rb +33 -0
- data/lib/koboldy/run.rb +139 -0
- data/lib/koboldy/version.rb +3 -0
- data/test/data/kobold_test_data.txt +98 -0
- data/test/kobold/conf_test.rb +106 -0
- data/test/kobold/run_test.rb +78 -0
- data/test/run_test.rb +9 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ddb5c7b0e1e855cf5a413bd6dcbe28e9ceb4517
|
4
|
+
data.tar.gz: 7708cec25453bbafc8dcc1f776e9895df5ac45cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70a7305f92ab33d36138c8bf34ca3159ac5c214d68aea9e660d4e0350190cbc7f2a470447639dae33883d28481558fe7ce613eb3a924df79f3d1dba72a9ef234
|
7
|
+
data.tar.gz: 291046c04e81623ec0ca5ebaaaceab37b8b725ef2e4ac4376b0ebc405de47e3bb4382094026183feb6e7747e955ec69f314fb5e97c32c47339777f97deee7407
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Kazuaki MATSUO
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# Koboldy
|
2
|
+
|
3
|
+
Support library for kobold https://github.com/yahoo/kobold
|
4
|
+
|
5
|
+
- Generate kobold-configuration
|
6
|
+
- Run and analyse the result
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'koboldy'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install koboldy
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
### Install kobold
|
27
|
+
|
28
|
+
`koboldy` is support library of **kobold** which is image comparing library for npm.
|
29
|
+
|
30
|
+
https://github.com/yahoo/kobold
|
31
|
+
|
32
|
+
### Create configuration file
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Koboldy::Conf.instance.add_block_out(0, 0, 0, 0)
|
36
|
+
.add_block_out(50, 50, 50, 50)
|
37
|
+
.add_block_out_red(255)
|
38
|
+
.add_compose_left_to_right(true)
|
39
|
+
.generate_into("config_file.txt")
|
40
|
+
|
41
|
+
> cat config_file.txt
|
42
|
+
{
|
43
|
+
"blockOut": [
|
44
|
+
{
|
45
|
+
"x": 0,
|
46
|
+
"y": 0,
|
47
|
+
"width": 0,
|
48
|
+
"height": 0
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"x": 50,
|
52
|
+
"y": 50,
|
53
|
+
"width": 50,
|
54
|
+
"height": 50
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"blockOutRed": 255,
|
58
|
+
"composeLeftToRight": true
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
62
|
+
### Run with command
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
@run = Koboldy::Run.new("kobold")
|
66
|
+
cmd = @run.config("config_file")
|
67
|
+
.approved("expected_folder")
|
68
|
+
.highlight("compared_folder")
|
69
|
+
.build("test_target_folder")
|
70
|
+
.fail_orphans
|
71
|
+
.fail_additions
|
72
|
+
.base_uri(`pwd`)
|
73
|
+
|
74
|
+
> "kobold --config config_file --approved-folder expected_folder" +
|
75
|
+
" --highlight-folder compared_folder --build-folder test_target_folder --fail-orphans --fail-additions path"
|
76
|
+
|
77
|
+
cmd.check_and_save("result.txt")
|
78
|
+
```
|
79
|
+
|
80
|
+
### Get results
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
@run.results("result.txt")
|
84
|
+
|
85
|
+
>
|
86
|
+
{
|
87
|
+
"passing": 250,
|
88
|
+
"failing": 101,
|
89
|
+
"pending": 0,
|
90
|
+
"additions": {
|
91
|
+
"count": 2,
|
92
|
+
"messages": [
|
93
|
+
[
|
94
|
+
"Screen is new: 0004_03_01_bargain_store_details"
|
95
|
+
],
|
96
|
+
[
|
97
|
+
"Screen is new: 0017_01_05_open_contact5"
|
98
|
+
]
|
99
|
+
]
|
100
|
+
},
|
101
|
+
"orphans": {
|
102
|
+
"count": 3,
|
103
|
+
"messages": [
|
104
|
+
[
|
105
|
+
"Error: Approved screen is orphaned: 0000_01_03_hot_recommend"
|
106
|
+
],
|
107
|
+
[
|
108
|
+
"Error: Approved screen is orphaned: 0102_02_01_open_recipe_2446163"
|
109
|
+
],
|
110
|
+
[
|
111
|
+
"Error: Approved screen is orphaned: 0102_02_02_open_tukurepo_2446163"
|
112
|
+
]
|
113
|
+
]
|
114
|
+
},
|
115
|
+
"different": {
|
116
|
+
"count": 2,
|
117
|
+
"messages": [
|
118
|
+
[
|
119
|
+
"Error: Screens are different for 0000_01_04_recent"
|
120
|
+
],
|
121
|
+
[
|
122
|
+
"Error: Screens are different for 0000_01_05_my_folder"
|
123
|
+
]
|
124
|
+
]
|
125
|
+
}
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
|
130
|
+
## Contributing
|
131
|
+
|
132
|
+
1. Fork it ( https://github.com/KazuCocoa/koboldy/fork )
|
133
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
134
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
135
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
136
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/koboldy.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'koboldy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "koboldy"
|
8
|
+
spec.version = Koboldy::VERSION
|
9
|
+
spec.authors = ["Kazuaki MATSUO"]
|
10
|
+
spec.email = ["fly.49.89.over@gmail.com"]
|
11
|
+
spec.summary = %q{Support library for kobold which is nodejs app.}
|
12
|
+
spec.description = %q{Support library for kobold https://github.com/yahoo/kobold}
|
13
|
+
spec.homepage = "https://github.com/KazuCocoa/koboldy"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.required_ruby_version = ">= 2.0.0"
|
21
|
+
|
22
|
+
spec.add_development_dependency "test-unit"
|
23
|
+
spec.add_development_dependency "rantly"
|
24
|
+
end
|
data/lib/koboldy.rb
ADDED
data/lib/koboldy/conf.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
require "json"
|
3
|
+
require "singleton"
|
4
|
+
|
5
|
+
class Koboldy
|
6
|
+
class Conf
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
# see https://github.com/yahoo/blink-diff if you would like to know setting more.
|
12
|
+
def initialize
|
13
|
+
@config = OpenStruct.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param [Integer] x Base x-coordinate
|
17
|
+
# @param [Integer] y Base y-coordinate
|
18
|
+
# @param [Integer] width Width of blockOut
|
19
|
+
# @param [Integer] height Height of blockOut
|
20
|
+
# @return [OpenStruct]
|
21
|
+
def add_block_out(x, y, width, height)
|
22
|
+
param = OpenStruct.new
|
23
|
+
param.x = x.to_i
|
24
|
+
param.y = y.to_i
|
25
|
+
param.width = width.to_i
|
26
|
+
param.height = height.to_i
|
27
|
+
|
28
|
+
@config.blockOut = [] if @config.blockOut.nil?
|
29
|
+
@config.blockOut.push param.to_h
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [Boolean] boolean You can set true/false. Only for blockOut config
|
34
|
+
# @return [OpenStruct]
|
35
|
+
def add_block_out_debug(boolean)
|
36
|
+
@config.debug = boolean
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [Boolean] boolean You can set true/false
|
41
|
+
# @return [OpenStruct]
|
42
|
+
def add_hide_shift(boolean)
|
43
|
+
@config.hideShift = boolean
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param [Boolean] boolean You can set true/false
|
48
|
+
# @return [OpenStruct]
|
49
|
+
def add_compose_left_to_right(boolean)
|
50
|
+
@config.composeLeftToRight = boolean
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [Integer] value You can set value from 0 to 255
|
55
|
+
# @return [OpenStruct]
|
56
|
+
def add_block_out_red(value)
|
57
|
+
@config.blockOutRed = color_value(value)
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
# @param [Integer] value You can set value from 0 to 255
|
62
|
+
# @return [OpenStruct]
|
63
|
+
def add_block_out_blue(value)
|
64
|
+
@config.blockOutBlue = color_value(value)
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
# @param [Integer] value You can set value from 0 to 255
|
69
|
+
# @return [OpenStruct]
|
70
|
+
def add_block_out_green(value)
|
71
|
+
@config.blockOutGreen = color_value(value)
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
# @param [Integer] value You can set value from 0 to 255
|
76
|
+
# @return [OpenStruct]
|
77
|
+
def add_delta(value)
|
78
|
+
@config.delta = value.to_i
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def generate_into(file_path)
|
83
|
+
File.open(file_path, "w") do |file|
|
84
|
+
file.puts JSON.pretty_generate(@config.to_h)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# clear @config instance.
|
89
|
+
def clear_config
|
90
|
+
@config = OpenStruct.new
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def color_value(value)
|
97
|
+
if value.to_i < 0
|
98
|
+
0
|
99
|
+
elsif value.to_i > 255
|
100
|
+
255
|
101
|
+
else
|
102
|
+
value.to_i
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end # class Conf
|
106
|
+
end # class Koboldy
|
data/lib/koboldy/io.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
class Koboldy
|
4
|
+
module Io
|
5
|
+
class << self
|
6
|
+
def capture_stdout
|
7
|
+
out = StringIO.new
|
8
|
+
$stdout = out
|
9
|
+
yield
|
10
|
+
out.string
|
11
|
+
ensure
|
12
|
+
$stdout = STDOUT
|
13
|
+
end
|
14
|
+
|
15
|
+
def capture_stderr
|
16
|
+
out = StringIO.new
|
17
|
+
$stderr = out
|
18
|
+
yield
|
19
|
+
out.string
|
20
|
+
ensure
|
21
|
+
$stderr = STDOUT
|
22
|
+
end
|
23
|
+
|
24
|
+
def capture(cmd, in_file_path)
|
25
|
+
File.open(in_file_path, "w") do |file|
|
26
|
+
Open3.popen2e(cmd) do |s_in, s_out, status|
|
27
|
+
s_out.each { |line| file.puts(line) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end # class << self
|
32
|
+
end # module Io
|
33
|
+
end # class Kobold
|
data/lib/koboldy/run.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
require_relative "io"
|
4
|
+
|
5
|
+
class Koboldy
|
6
|
+
class Run
|
7
|
+
def initialize(kobold_cmd = "kobold")
|
8
|
+
@cmd = kobold_cmd
|
9
|
+
end
|
10
|
+
|
11
|
+
def clear_cmd(kobold_cmd = "kobold")
|
12
|
+
@cmd = kobold_cmd
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [String] file A path to configuration file
|
16
|
+
# @return [Self]
|
17
|
+
def config(file)
|
18
|
+
@cmd.concat(" --config #{file}")
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [String] expected_folder A path to expected files
|
23
|
+
# @return [Self]
|
24
|
+
def approved(expected_folder)
|
25
|
+
@cmd.concat(" --approved-folder #{expected_folder}")
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
# @param [String] compared_folder A path to compared files
|
30
|
+
# @return [Self]
|
31
|
+
def highlight(compared_folder)
|
32
|
+
@cmd.concat(" --highlight-folder #{compared_folder}")
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# @param [String] test_target_folder A path to test target files
|
37
|
+
# @return [Self]
|
38
|
+
def build(test_target_folder)
|
39
|
+
@cmd.concat(" --build-folder #{test_target_folder}")
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
# Add "--fail-orphans" option
|
44
|
+
# @return [Self]
|
45
|
+
def fail_orphans
|
46
|
+
@cmd.concat(" --fail-orphans")
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# Add "--fail-additions" option
|
51
|
+
# @return [Self]
|
52
|
+
def fail_additions
|
53
|
+
@cmd.concat(" --fail-additions")
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
# @param [String] command Add aditional options.
|
58
|
+
# @return [Self]
|
59
|
+
def additional_option(command)
|
60
|
+
@cmd.concat(" #{command}")
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param [String] path Path of current path.
|
65
|
+
def base_uri(path)
|
66
|
+
@cmd.concat(" #{path}")
|
67
|
+
end
|
68
|
+
|
69
|
+
# @param [String] in_file_path A path to file which you would like to save standard output and error.
|
70
|
+
# @return [String] File path which is saved results.
|
71
|
+
def check_and_save(in_file_path = "./tmp/kobold.txt")
|
72
|
+
fail "no command: #{@cmd}" if @cmd.nil?
|
73
|
+
Koboldy::Io.capture(@cmd, in_file_path)
|
74
|
+
in_file_path
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param [String] from_path A path you would like to analysis outputs by kobold command.
|
78
|
+
# @param [String] into_file(Option) A path you would like to save the result. If into_file is empty, then the method return JSON.
|
79
|
+
# @return [String] into_file A path to saved result file.
|
80
|
+
def results(from_path, into_file = "")
|
81
|
+
result = File.read(from_path)
|
82
|
+
add, orp, dif = additions(result), orphans(result), different(result)
|
83
|
+
|
84
|
+
hash = {
|
85
|
+
:passing => passing(result),
|
86
|
+
:failing => failing(result),
|
87
|
+
:pending => pending(result),
|
88
|
+
:additions => { count: add.length, messages: add }, # 期待結果に無い
|
89
|
+
:orphans => { count: orp.length, messages: orp }, # 比較対象に無い
|
90
|
+
:different => { count: dif.length, messages: dif }, # 比較結果が異なる
|
91
|
+
}
|
92
|
+
|
93
|
+
return JSON.pretty_generate(hash) if into_file.empty?
|
94
|
+
|
95
|
+
File.write(into_file, JSON.pretty_generate(hash))
|
96
|
+
into_file
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def passing(result)
|
102
|
+
passing = result.scan(/.*passing.*/).first.to_s
|
103
|
+
find_score(passing)
|
104
|
+
end
|
105
|
+
|
106
|
+
def failing(result)
|
107
|
+
failing = result.scan(/.*failing.*/).first.to_s
|
108
|
+
find_score(failing)
|
109
|
+
end
|
110
|
+
|
111
|
+
def pending(result)
|
112
|
+
pending = result.scan(/.*pending.*/).first.to_s
|
113
|
+
find_score(pending)
|
114
|
+
end
|
115
|
+
|
116
|
+
def find_score(scored_line)
|
117
|
+
return 0 if scored_line.nil? || scored_line.empty?
|
118
|
+
scored_line.split(/\s/).find { |item| item =~ /\A\d+\z/ }.to_i
|
119
|
+
end
|
120
|
+
|
121
|
+
def additions(result)
|
122
|
+
result.scan(/Screen is new:.*/).map do |line|
|
123
|
+
line.to_s.split(/\u001b\[0m\u001b\[90m/)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def orphans(result)
|
128
|
+
result.scan(/Error: Approved screen is orphaned.*/).map do |line|
|
129
|
+
line.to_s.split(/\u001b\[0m\u001b\[90m/)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def different(result)
|
134
|
+
result.scan(/Error: Screens are different for.*/).map do |line|
|
135
|
+
line.to_s.split(/\u001b\[0m\u001b\[90m/)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end # class Run
|
139
|
+
end # module Kobold
|
@@ -0,0 +1,98 @@
|
|
1
|
+
[0m 9100 - 05 - 01 - mypage[0m
|
2
|
+
[32m ✓[0m[90m should load the approved screen [0m
|
3
|
+
[32m ✓[0m[90m should load the build screen [0m
|
4
|
+
[32m ✓[0m[90m should load the configuration of screen [0m
|
5
|
+
[31m 99) should be similar[0m
|
6
|
+
[0m 9100 - 05 - 02 - myfolders[0m
|
7
|
+
[32m ✓[0m[90m should load the approved screen [0m
|
8
|
+
[32m ✓[0m[90m should load the build screen [0m
|
9
|
+
[32m ✓[0m[90m should load the configuration of screen [0m
|
10
|
+
[31m 100) should be similar[0m
|
11
|
+
[0m 9102 - rotate[0m
|
12
|
+
[32m ✓[0m[90m should load the approved screen [0m
|
13
|
+
[32m ✓[0m[90m should load the build screen [0m
|
14
|
+
[32m ✓[0m[90m should load the configuration of screen [0m
|
15
|
+
[31m 101) should be similar[0m
|
16
|
+
|
17
|
+
|
18
|
+
[92m [0m[32m 250 passing[0m[90m (1m)[0m
|
19
|
+
[31m 101 failing[0m
|
20
|
+
|
21
|
+
[0m 1) Kobold 0000 - 01 - 03 - hot - recommend is orphaned:
|
22
|
+
[0m[31m Error: Approved screen is orphaned: 0000_01_03_hot_recommend[0m[90m
|
23
|
+
at Context.<anonymous> (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:224:13)
|
24
|
+
at callFn (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:249:21)
|
25
|
+
at Test.Runnable.run (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:242:7)
|
26
|
+
at Runner.runTest (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:373:10)
|
27
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:451:12
|
28
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:298:14)
|
29
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:308:7
|
30
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:246:23)
|
31
|
+
at Immediate._onImmediate (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:275:5)
|
32
|
+
at processImmediate [as _immediateCallback] (timers.js:358:17)
|
33
|
+
[0m
|
34
|
+
[0m 2) Kobold 0102 - 02 - 01 - open - recipe - 2446163 is orphaned:
|
35
|
+
[0m[31m Error: Approved screen is orphaned: 0102_02_01_open_recipe_2446163[0m[90m
|
36
|
+
at Context.<anonymous> (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:224:13)
|
37
|
+
at callFn (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:249:21)
|
38
|
+
at Test.Runnable.run (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:242:7)
|
39
|
+
at Runner.runTest (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:373:10)
|
40
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:451:12
|
41
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:298:14)
|
42
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:308:7
|
43
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:246:23)
|
44
|
+
at Immediate._onImmediate (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:275:5)
|
45
|
+
at processImmediate [as _immediateCallback] (timers.js:358:17)
|
46
|
+
[0m
|
47
|
+
[0m 3) Kobold 0102 - 02 - 02 - open - tukurepo - 2446163 is orphaned:
|
48
|
+
[0m[31m Error: Approved screen is orphaned: 0102_02_02_open_tukurepo_2446163[0m[90m
|
49
|
+
at Context.<anonymous> (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:224:13)
|
50
|
+
at callFn (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:249:21)
|
51
|
+
at Test.Runnable.run (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:242:7)
|
52
|
+
at Runner.runTest (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:373:10)
|
53
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:451:12
|
54
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:298:14)
|
55
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:308:7
|
56
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:246:23)
|
57
|
+
at Immediate._onImmediate (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:275:5)
|
58
|
+
at processImmediate [as _immediateCallback] (timers.js:358:17)
|
59
|
+
[0m 11) Kobold 0004 - 03 - 01 - bargain - store - details is an addition:
|
60
|
+
[0m[31m Error: Screen is new: 0004_03_01_bargain_store_details[0m[90m
|
61
|
+
at Context.<anonymous> (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:264:13)
|
62
|
+
at callFn (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:249:21)
|
63
|
+
at Test.Runnable.run (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:242:7)
|
64
|
+
at Runner.runTest (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:373:10)
|
65
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:451:12
|
66
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:298:14)
|
67
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:308:7
|
68
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:246:23)
|
69
|
+
at Immediate._onImmediate (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:275:5)
|
70
|
+
at processImmediate [as _immediateCallback] (timers.js:358:17)
|
71
|
+
[0m
|
72
|
+
[0m 12) Kobold 0017 - 01 - 05 - open - contact5 is an addition:
|
73
|
+
[0m[31m Error: Screen is new: 0017_01_05_open_contact5[0m[90m
|
74
|
+
at Context.<anonymous> (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:264:13)
|
75
|
+
at callFn (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:249:21)
|
76
|
+
at Test.Runnable.run (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runnable.js:242:7)
|
77
|
+
at Runner.runTest (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:373:10)
|
78
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:451:12
|
79
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:298:14)
|
80
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:308:7
|
81
|
+
at next (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:246:23)
|
82
|
+
at Immediate._onImmediate (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/mocha/lib/runner.js:275:5)
|
83
|
+
at processImmediate [as _immediateCallback] (timers.js:358:17)
|
84
|
+
[0m
|
85
|
+
[0m 21) Kobold 0000 - 01 - 04 - recent should be similar:
|
86
|
+
[0m[31m Error: Screens are different for 0000_01_04_recent[0m[90m
|
87
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:453:12
|
88
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/promise/lib/core.js:33:15
|
89
|
+
at flush (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/promise/node_modules/asap/asap.js:27:13)
|
90
|
+
at process._tickCallback (node.js:355:11)
|
91
|
+
[0m
|
92
|
+
[0m 22) Kobold 0000 - 01 - 05 - my - folder should be similar:
|
93
|
+
[0m[31m Error: Screens are different for 0000_01_05_my_folder[0m[90m
|
94
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/lib/kobold.js:453:12
|
95
|
+
at /Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/promise/lib/core.js:33:15
|
96
|
+
at flush (/Users/kazuaki-matsuo/Documents/github/mobile_automated_testing_appium/node_modules/kobold/node_modules/promise/node_modules/asap/asap.js:27:13)
|
97
|
+
at process._tickCallback (node.js:355:11)
|
98
|
+
[0m
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "rantly"
|
3
|
+
|
4
|
+
require "./lib/koboldy/conf"
|
5
|
+
|
6
|
+
class TestKobold < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@kobold ||= Koboldy::Conf.instance
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
@kobold.clear_config
|
13
|
+
end
|
14
|
+
|
15
|
+
data( # x y width height
|
16
|
+
"test1" => Rantly { [integer, integer, integer, integer] })
|
17
|
+
test "#add_block_out" do |(x, y, width, height)|
|
18
|
+
expected = [{ x: x, y: y,width: width, height: height }]
|
19
|
+
@kobold.add_block_out(x, y, width, height)
|
20
|
+
assert_equal(@kobold.config["blockOut"], expected)
|
21
|
+
|
22
|
+
expected.push({ x: x, y: y,width: width, height: height })
|
23
|
+
@kobold.add_block_out(x, y, width, height)
|
24
|
+
assert_equal(@kobold.config["blockOut"], expected)
|
25
|
+
end
|
26
|
+
|
27
|
+
data( # on/off
|
28
|
+
"test1" => [true],
|
29
|
+
"test2" => [false])
|
30
|
+
test "#add_hide_shift" do |(boolean)|
|
31
|
+
@kobold.add_hide_shift boolean
|
32
|
+
assert_equal(@kobold.config["hideShift"], boolean)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
data( # on/off
|
37
|
+
"test1" => [true],
|
38
|
+
"test2" => [false])
|
39
|
+
test "#add_compose_left_to_right" do |(boolean)|
|
40
|
+
@kobold.add_compose_left_to_right boolean
|
41
|
+
assert_equal(@kobold.config["composeLeftToRight"], boolean)
|
42
|
+
end
|
43
|
+
|
44
|
+
data( # expected value
|
45
|
+
"test1" => [ 0, -1],
|
46
|
+
"test2" => [ 0, 0],
|
47
|
+
"test3" => [255, 255],
|
48
|
+
"test4" => [255, 256])
|
49
|
+
test "#add_block_out_red" do |(expected, actual)|
|
50
|
+
@kobold.add_block_out_red actual
|
51
|
+
assert_equal(@kobold.config["blockOutRed"], expected)
|
52
|
+
end
|
53
|
+
|
54
|
+
data( # expected value
|
55
|
+
"test1" => [ 0, -1],
|
56
|
+
"test2" => [ 0, 0],
|
57
|
+
"test3" => [255, 255],
|
58
|
+
"test4" => [255, 256])
|
59
|
+
test "#add_block_out_blue" do |(expected, actual)|
|
60
|
+
@kobold.add_block_out_blue actual
|
61
|
+
assert_equal(@kobold.config["blockOutBlue"], expected)
|
62
|
+
end
|
63
|
+
|
64
|
+
data( # expected value
|
65
|
+
"test1" => [ 0, -1],
|
66
|
+
"test2" => [ 0, 0],
|
67
|
+
"test3" => [255, 255],
|
68
|
+
"test4" => [255, 256])
|
69
|
+
test "#add_block_out_green" do |(expected, actual)|
|
70
|
+
@kobold.add_block_out_green actual
|
71
|
+
assert_equal(@kobold.config["blockOutGreen"], expected)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
test "add some items" do
|
77
|
+
@kobold.add_block_out(0, 0, 0, 0)
|
78
|
+
.add_block_out(50, 50, 50, 50)
|
79
|
+
.add_block_out_red(255)
|
80
|
+
.add_compose_left_to_right(true)
|
81
|
+
|
82
|
+
expected =<<-EOS.chomp
|
83
|
+
{
|
84
|
+
"blockOut": [
|
85
|
+
{
|
86
|
+
"x": 0,
|
87
|
+
"y": 0,
|
88
|
+
"width": 0,
|
89
|
+
"height": 0
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"x": 50,
|
93
|
+
"y": 50,
|
94
|
+
"width": 50,
|
95
|
+
"height": 50
|
96
|
+
}
|
97
|
+
],
|
98
|
+
"blockOutRed": 255,
|
99
|
+
"composeLeftToRight": true
|
100
|
+
}
|
101
|
+
EOS
|
102
|
+
assert_equal(JSON.pretty_generate(@kobold.config.to_h), expected)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
require "./lib/koboldy/run"
|
4
|
+
|
5
|
+
class RunTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
# Called before every test method runs. Can be used
|
8
|
+
# to set up fixture information.
|
9
|
+
def setup
|
10
|
+
@run = Koboldy::Run.new("kobold")
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
# Do nothing
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def test_cmd_configuration
|
19
|
+
expected = "kobold --config a --approved-folder b --highlight-folder c --build-folder d --fail-orphans --fail-additions neko"
|
20
|
+
cmd = @run
|
21
|
+
.config("a")
|
22
|
+
.approved("b")
|
23
|
+
.highlight("c")
|
24
|
+
.build("d")
|
25
|
+
.fail_orphans
|
26
|
+
.fail_additions
|
27
|
+
.base_uri("neko")
|
28
|
+
assert_equal(cmd, expected)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_result_check
|
32
|
+
expected = <<-EOS.chomp
|
33
|
+
{
|
34
|
+
"passing": 250,
|
35
|
+
"failing": 101,
|
36
|
+
"pending": 0,
|
37
|
+
"additions": {
|
38
|
+
"count": 2,
|
39
|
+
"messages": [
|
40
|
+
[
|
41
|
+
"Screen is new: 0004_03_01_bargain_store_details"
|
42
|
+
],
|
43
|
+
[
|
44
|
+
"Screen is new: 0017_01_05_open_contact5"
|
45
|
+
]
|
46
|
+
]
|
47
|
+
},
|
48
|
+
"orphans": {
|
49
|
+
"count": 3,
|
50
|
+
"messages": [
|
51
|
+
[
|
52
|
+
"Error: Approved screen is orphaned: 0000_01_03_hot_recommend"
|
53
|
+
],
|
54
|
+
[
|
55
|
+
"Error: Approved screen is orphaned: 0102_02_01_open_recipe_2446163"
|
56
|
+
],
|
57
|
+
[
|
58
|
+
"Error: Approved screen is orphaned: 0102_02_02_open_tukurepo_2446163"
|
59
|
+
]
|
60
|
+
]
|
61
|
+
},
|
62
|
+
"different": {
|
63
|
+
"count": 2,
|
64
|
+
"messages": [
|
65
|
+
[
|
66
|
+
"Error: Screens are different for 0000_01_04_recent"
|
67
|
+
],
|
68
|
+
[
|
69
|
+
"Error: Screens are different for 0000_01_05_my_folder"
|
70
|
+
]
|
71
|
+
]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
EOS
|
75
|
+
result = @run.results("./test/data/kobold_test_data.txt")
|
76
|
+
assert_equal(result, expected)
|
77
|
+
end
|
78
|
+
end
|
data/test/run_test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: koboldy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kazuaki MATSUO
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rantly
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Support library for kobold https://github.com/yahoo/kobold
|
42
|
+
email:
|
43
|
+
- fly.49.89.over@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- koboldy.gemspec
|
54
|
+
- lib/koboldy.rb
|
55
|
+
- lib/koboldy/conf.rb
|
56
|
+
- lib/koboldy/io.rb
|
57
|
+
- lib/koboldy/run.rb
|
58
|
+
- lib/koboldy/version.rb
|
59
|
+
- test/data/kobold_test_data.txt
|
60
|
+
- test/kobold/conf_test.rb
|
61
|
+
- test/kobold/run_test.rb
|
62
|
+
- test/run_test.rb
|
63
|
+
homepage: https://github.com/KazuCocoa/koboldy
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.0
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.2.2
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Support library for kobold which is nodejs app.
|
87
|
+
test_files:
|
88
|
+
- test/data/kobold_test_data.txt
|
89
|
+
- test/kobold/conf_test.rb
|
90
|
+
- test/kobold/run_test.rb
|
91
|
+
- test/run_test.rb
|