jml_test_runner 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66e000f0922639135776aa348a27f943fa1d37c7
4
+ data.tar.gz: f95ccf5445328366173f7cabacb1764ab8e87341
5
+ SHA512:
6
+ metadata.gz: c74d2dba3c5e7dcc2492a7de4186e58a8357870aac26e19c01bc5595757b34964da5b6a96c0e0e7aa3998485259cbd36bb8ad41a10c7e2db4df1c7656adc79a6
7
+ data.tar.gz: 9153dd674e46efe42cc0789e570e6730c54a146e874c614c53432141cdebb0909c88ba9d9aeae8e24e316b6c5abfcb37ed6273d003f2c65cf30b6f024ce5fd86
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ test_runner
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at morgan@jmorgan.org. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jml_test_runner.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rubocop', require: false
8
+ gem 'pry', require: false
9
+ gem 'pry-theme', require: false
10
+ gem 'colorize', require: false
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Morgan Lieberthal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # JmlTestRunner
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jml_test_runner`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jml_test_runner'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jml_test_runner
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jml_test_runner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'jml_test_runner'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require 'pry'
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/jml-run-tests ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path('../../lib', __FILE__))
4
+
5
+ require 'jml_test_runner'
6
+
7
+ JmlTestRunner::Runner.new(ARGV.first).run if $0 == __FILE__
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $:.unshift(lib) unless $:.include?(lib)
4
+ require 'jml_test_runner/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jml_test_runner'
8
+ spec.version = JmlTestRunner::VERSION
9
+ spec.authors = ['Morgan Lieberthal']
10
+ spec.email = ['morgan@jmorgan.org']
11
+
12
+ spec.summary = 'A test runner for `check`'
13
+ spec.homepage = 'https://github.com/baberthal/jml_test_runner'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'activesupport', '~> 4.2'
22
+ spec.add_runtime_dependency 'terminal-table', '~> 1.5'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.11'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ end
@@ -0,0 +1,12 @@
1
+ require 'colorize'
2
+
3
+ module JmlTestRunner
4
+ module Formatters
5
+ class Base
6
+ attr_accessor :suites
7
+ def initialize(runner)
8
+ @suites = runner.suites_run
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,85 @@
1
+ require 'jml_test_runner/formatters/base'
2
+ require 'terminal-table'
3
+
4
+ module JmlTestRunner
5
+ module Formatters
6
+ class Basic < Base
7
+ def print_formatted_output
8
+ @suites.each do |suite|
9
+ format_suite_summary(suite)
10
+ format_suite_test_cases(suite)
11
+ format_suite_summary_summary(suite)
12
+ end
13
+ end
14
+
15
+ def separator
16
+ msg = '=' * term_width
17
+ puts msg.colorize(:white).bold
18
+ end
19
+
20
+ def format_suite_summary(suite)
21
+ puts
22
+ separator
23
+ puts suite.title.colorize(:blue).bold
24
+ puts suite.timestamp.strftime('%D -- %H:%M:%S').colorize(:yellow)
25
+ end
26
+
27
+ def format_suite_summary_summary(suite)
28
+ full = "#{suite.count} Test(s) Run".colorize(:white)
29
+ passes = "#{suite.pass_count} Pass(es)".colorize(:green)
30
+ failures = "#{suite.failure_count} Failure(s)".colorize(:red)
31
+ errors = "#{suite.error_count} Error(s)".colorize(:yellow)
32
+ puts
33
+ puts "#{full} (#{passes} #{failures} #{errors})"
34
+ puts
35
+ end
36
+
37
+ # rubocop:disable Metrics/MethodLength
38
+ def format_suite_test_cases(suite) # rubocop:disable Metrics/AbcSize
39
+ table_rows = []
40
+ suite.tests.each do |test|
41
+ if test.success?
42
+ table_rows << [test.id, "\u2714".encode('utf-8').colorize(:green)]
43
+ elsif test.error?
44
+ table_rows << [test.id, "\u25C9".encode('utf-8').colorize(:yellow)]
45
+ table_rows << ['', test.message.colorize(:yellow)]
46
+ elsif test.failure?
47
+ table_rows << [test.id, "\u2718".encode('utf-8').colorize(:red)]
48
+ table_rows << ['', test.message.colorize(:red)]
49
+ else
50
+ table_rows << [test.id, 'UNKNOWN'.colorize(:red)]
51
+ table_rows << ['', test.message.colorize(:red)]
52
+ end
53
+ end
54
+ table = Terminal::Table.new(rows: table_rows)
55
+ table.style = { border_x: '', border_i: '' }
56
+ puts table
57
+ end
58
+
59
+ def term_width
60
+ result = if ENV['COLUMNS']
61
+ ENV['COLUMNS'].to_i
62
+ else
63
+ unix? ? dynamic_width : 80
64
+ end
65
+ result < 10 ? 80 : result
66
+ end
67
+
68
+ def unix?
69
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i # rubocop:disable Metrics/LineLength
70
+ end
71
+
72
+ def dynamic_width
73
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
74
+ end
75
+
76
+ def dynamic_width_stty
77
+ `stty size 2>/dev/null`.split[1].to_i
78
+ end
79
+
80
+ def dynamic_width_tput
81
+ `tput cols 2>/dev/null`.to_i
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1 @@
1
+ require 'jml_test_runner/formatters/basic'
@@ -0,0 +1,50 @@
1
+ require 'open3'
2
+ require 'jml_test_runner/suite'
3
+ require 'jml_test_runner/formatters'
4
+
5
+ module JmlTestRunner
6
+ class Runner
7
+ attr_reader :dir, :exes, :suites_run
8
+ def initialize(test_dir)
9
+ @dir = File.expand_path(test_dir)
10
+ @exes = Dir["#{@dir}/**/*"].select { |f| f =~ /(.+)_tests?$/ }
11
+ @suites_run = []
12
+ end
13
+
14
+ def run(suite_name = nil)
15
+ _check_for_suite(suite_name) if suite_name
16
+ _do_run(suite_name)
17
+ @formatter = JmlTestRunner::Formatters::Basic.new(self)
18
+ @formatter.print_formatted_output
19
+ end
20
+
21
+ private
22
+
23
+ def _check_for_suite(name)
24
+ raise "#{name} not found!" unless @exes.include?(name)
25
+ end
26
+
27
+ def _do_run(suite_name = nil)
28
+ return _run_single_test(suite_name) if suite_name
29
+ @exes.each do |exe|
30
+ _run_single_test(exe)
31
+ end
32
+ end
33
+
34
+ def _run_single_test(test_exe)
35
+ Open3.popen2(
36
+ {
37
+ 'CK_XML_LOG_FILE_NAME' => '-',
38
+ 'CK_VERBOSITY' => 'silent'
39
+ },
40
+ "./#{File.basename(test_exe)}",
41
+ chdir: @dir) do |_input, output, _th|
42
+ _parse_xml_output(output)
43
+ end
44
+ end
45
+
46
+ def _parse_xml_output(xml)
47
+ @suites_run.push(Suite.new(xml))
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,49 @@
1
+ require 'active_support/core_ext/hash/conversions'
2
+ require 'date'
3
+ require 'jml_test_runner/test_case'
4
+
5
+ module JmlTestRunner
6
+ class Suite
7
+ attr_reader :raw_input, :tests, :timestamp, :title
8
+ def initialize(raw)
9
+ @raw_input = Hash.from_xml(raw)
10
+ @tests = []
11
+ return unless @raw_input['testsuites']
12
+ parse_raw_xml
13
+ end
14
+
15
+ def failure_count
16
+ @tests.count { |t| t.result == :failure }
17
+ end
18
+
19
+ def pass_count
20
+ @tests.count { |t| t.result == :success }
21
+ end
22
+
23
+ def error_count
24
+ @tests.count { |t| t.result == :error }
25
+ end
26
+
27
+ def count
28
+ @tests.count
29
+ end
30
+
31
+ private
32
+
33
+ def parse_raw_xml
34
+ hash = @raw_input['testsuites']
35
+ @timestamp = DateTime.parse(hash['datetime'])
36
+ suite = hash['suite']
37
+ parse_suite_xml(suite)
38
+ end
39
+
40
+ def parse_suite_xml(suite_hash)
41
+ @title = suite_hash['title']
42
+ @duration = suite_hash['duration']
43
+ suite_hash['test'].each do |test|
44
+ next unless test.is_a?(Hash)
45
+ @tests.push(TestCase.new(test))
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ require 'pry'
2
+
3
+ module JmlTestRunner
4
+ class TestCase
5
+ attr_reader :result, :path, :fn, :id, :iteration,
6
+ :duration, :description, :message
7
+ def initialize(hash = {})
8
+ @result = hash['result'].to_sym
9
+ @path = hash['path']
10
+ @fn = hash['fn']
11
+ @id = hash['id']
12
+ @iteration = hash['iteration']
13
+ @duration = hash['duration']
14
+ @description = hash['description']
15
+ @message = hash['message']
16
+ end
17
+
18
+ def success?
19
+ @result == :success
20
+ end
21
+
22
+ def failure?
23
+ @result == :failure
24
+ end
25
+
26
+ def error?
27
+ @result == :error
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module JmlTestRunner
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'jml_test_runner/version'
2
+ require 'jml_test_runner/runner'
3
+
4
+ module JmlTestRunner
5
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jml_test_runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Morgan Lieberthal
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: terminal-table
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - morgan@jmorgan.org
86
+ executables:
87
+ - jml-run-tests
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".ruby-gemset"
94
+ - ".ruby-version"
95
+ - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - exe/jml-run-tests
104
+ - jml_test_runner.gemspec
105
+ - lib/jml_test_runner.rb
106
+ - lib/jml_test_runner/formatters.rb
107
+ - lib/jml_test_runner/formatters/base.rb
108
+ - lib/jml_test_runner/formatters/basic.rb
109
+ - lib/jml_test_runner/runner.rb
110
+ - lib/jml_test_runner/suite.rb
111
+ - lib/jml_test_runner/test_case.rb
112
+ - lib/jml_test_runner/version.rb
113
+ homepage: https://github.com/baberthal/jml_test_runner
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: A test runner for `check`
137
+ test_files: []