devtools-runtest 2.0.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.
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.3
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "simplecov"
5
+ gem "codeclimate-test-reporter", "~> 1.0.0"
6
+ end
7
+
8
+ # Specify your gem's dependencies in ora-dev-tools.gemspec
9
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Donovan Young
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.
@@ -0,0 +1,34 @@
1
+ [![Build Status](https://travis-ci.org/dyoung522/devtools-runtest.svg?branch=master)](https://travis-ci.org/dyoung522/devtools-runtest)
2
+ [![Code Climate](https://codeclimate.com/github/dyoung522/devtools-runtest/badges/gpa.svg)](https://codeclimate.com/github/dyoung522/devtools-runtest)
3
+ [![Test Coverage](https://codeclimate.com/github/dyoung522/devtools-runtest/badges/coverage.svg)](https://codeclimate.com/github/dyoung522/devtools-runtest/coverage)
4
+
5
+ # RunTest
6
+
7
+ Runs specs based upon local configuration
8
+
9
+ ## Installation
10
+
11
+ Install it from the command line
12
+
13
+ $ gem install devtools-runtest
14
+
15
+ ## Usage
16
+
17
+ Once installed, this gem provides the `runtest` command line utility.
18
+
19
+ Please run `runtest --help` for more information.
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`.
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on [our GitHub page](https://github.com/dyoung522/devtools)
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ Rake::Task[:build].enhance [:spec]
7
+
8
+ task :default => :spec
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "devtools"
5
+ require "runtest"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "pry"
15
+ Pry.start
16
+
@@ -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
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "runtest/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "devtools-runtest"
8
+ spec.version = RunTest::VERSION
9
+ spec.authors = ["Donovan Young"]
10
+ spec.email = ["dyoung522@gmail.com"]
11
+
12
+ spec.summary = %q{Runs specs based on configuration}
13
+ spec.description = %q{Runs all or specific specs based on local configuration options}
14
+ spec.homepage = "https://github.com/dyoung522/devtools-runtest"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "config", "~> 1.3"
23
+ spec.add_dependency "devtools-base", "~> 2.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry", "~> 0.4"
29
+ end
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path("../../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require "devtools"
6
+ require "runtest"
7
+ require "find"
8
+ require "pp"
9
+
10
+ module RunTest
11
+ def self.run_command(command)
12
+ puts "COMMAND> #{command}" if Options.verbose >= 4
13
+ system command unless Options.dryrun
14
+ end
15
+
16
+ files = { jest: [], mocha: [], diff: [] }
17
+
18
+ RunTest::OptParse.parse(ARGV)
19
+
20
+ pp Options if Options.verbose >= 5
21
+
22
+ if Options.changed
23
+ files[:diff] = %x(#{Options.commands.diff}).split("\n").collect do |f|
24
+ f =~ /-spec/ ? File.basename(f, ".js") : "#{File.basename(f, ".js")}-spec"
25
+ end.uniq.compact
26
+
27
+ DevTools::Utils.die "No modified spec files found" if files[:diff].empty? && ARGV.empty?
28
+ end
29
+
30
+ if !files[:diff].empty? || ARGV.length > 0
31
+ [files[:diff], ARGV].flatten.compact.uniq.each do |arg|
32
+ found = false
33
+
34
+ puts "looking for tests matching \"#{arg}\"" if Options.verbose > 1
35
+
36
+ Find.find(Options.basedir) do |path|
37
+ if FileTest.directory?(path)
38
+ if File.basename(path)[0] == ?.
39
+ Find.prune # Don't look any further into this directory.
40
+ else
41
+ next
42
+ end
43
+ else
44
+ if path =~ /_*(spec|test)s?_*\/.*#{arg}.*/
45
+ files[$1 =~ /test/ ? :jest : :mocha].push path
46
+ found = true
47
+ end
48
+ end
49
+ end
50
+
51
+ puts "No tests found matching #{arg}" unless found
52
+ end
53
+
54
+ [:jest, :mocha].each do |suite|
55
+ next unless Options[suite]
56
+
57
+ if files[suite].length > 0
58
+ if Options.verbose > 2
59
+ puts "\nRunning #{suite.capitalize} on..."
60
+ puts " #{files[suite].join("\n ")}\n\n"
61
+ else
62
+ puts "\nRunning #{files[suite].length} #{suite.capitalize} test(s)" if Options.verbose > 0
63
+ end
64
+
65
+ run_command "#{Options.commands[suite]} #{files[suite].join(" ")}"
66
+ end
67
+ end
68
+
69
+ exit ( files[:jest].length > 0 || files[:mocha].length > 0 ? 0 : 1 )
70
+
71
+ else
72
+ [:jest, :mocha].each do |suite|
73
+ if Options[suite]
74
+ puts "Running full #{suite.capitalize} test suite" if Options.verbose > 0
75
+ run_command Options.commands[suite.to_s + "_full"]
76
+ end
77
+ end
78
+ end
79
+ end # module RunTest
80
+
@@ -0,0 +1,3 @@
1
+ require "devtools"
2
+ require "runtest/version"
3
+ require "runtest/options"
@@ -0,0 +1,100 @@
1
+ module RunTest
2
+ class OptParse
3
+ def self.default_options
4
+ {
5
+ basedir: "src/js",
6
+ changed: false,
7
+ commands: Config::Options.new,
8
+ jest: true,
9
+ mocha: true,
10
+ verbose: 0
11
+ }
12
+ end
13
+
14
+ #
15
+ # Return a structure describing the Options.
16
+ #
17
+ def self.parse(args, unit_testing=false)
18
+ # The Options specified on the command line will be collected in *Options*.
19
+ # We set default values here.
20
+ opt_parse = DevTools::OptParse.new({ name: PROGRAM_NAME,
21
+ version: VERSION,
22
+ defaults: default_options,
23
+ testing: unit_testing })
24
+
25
+ opt_parse.default_options(Options.commands, {
26
+ diff: "git diff --name-only develop src/js | egrep \".js$\"",
27
+ jest: "$(npm bin)/jest",
28
+ jest_full: "npm run test:jest",
29
+ mocha: "$(npm bin)/mocha --require src/js/util/test-dom.js --compilers js:babel-core/register",
30
+ mocha_full: "npm run test:mocha"
31
+ })
32
+
33
+ parser = opt_parse.parser
34
+
35
+ parser.banner = "Usage: #{DevTools::PROGRAM} [OPTIONS] [PATTERN]"
36
+ parser.banner += "\n\nWhere [PATTERN] is any full or partial filename."
37
+ parser.banner += " All tests matching this filename pattern will be run."
38
+
39
+ parser.separator ""
40
+ parser.separator "[OPTIONS]"
41
+
42
+ parser.separator ""
43
+ parser.separator "Specific Options:"
44
+
45
+ # Base directory
46
+ parser.on("-b", "--basedir DIR", "Specify the base directory to search for tests (DEFAULT: '#{Options.basedir}')") do |dir|
47
+ Options.basedir = dir
48
+ end
49
+
50
+ # Changed switch
51
+ parser.on("-c", "--changed", "Run specs for any files that have recently been modified") do
52
+ Options.changed = true
53
+ end
54
+
55
+ parser.separator ""
56
+ parser.separator "Test Runners:"
57
+
58
+ parser.on("-j", "--[no-]jest", "Only/Don't run Jest tests") do |jest|
59
+ Options.jest = true; Options.mocha = false
60
+ (Options.jest = false; Options.mocha = true) unless jest
61
+ end
62
+
63
+ parser.on("-m", "--[no-]mocha", "Only/Don't run Mocha tests") do |mocha|
64
+ Options.jest = false; Options.mocha = true
65
+ (Options.jest = true; Options.mocha = false) unless mocha
66
+ end
67
+
68
+ parser.separator ""
69
+ parser.separator "Test Commands:"
70
+
71
+ parser.on("--diff-cmd CMD", "Overwrite git diff command: '#{Options.commands.diff}'") do |cmd|
72
+ Options.commands.diff = cmd
73
+ end
74
+
75
+ parser.on("--jest-cmd CMD", "Overwrite Jest command: '#{Options.commands.jest}'") do |cmd|
76
+ Options.commands.jest = cmd
77
+ end
78
+
79
+ parser.on("--jest-full-cmd CMD", "Overwrite Jest full-suite command: '#{Options.commands.jest_full}'") do |cmd|
80
+ Options.commands.jest_full = cmd
81
+ end
82
+
83
+ parser.on("--mocha-cmd CMD", "Overwrite Mocha command: '#{Options.commands.mocha}'") do |cmd|
84
+ Options.commands.mocha = cmd
85
+ end
86
+
87
+ parser.on("--mocha-full-cmd CMD", "Overwrite Mocha command: '#{Options.commands.mocha_full}'") do |cmd|
88
+ Options.commands.mocha_full = cmd
89
+ end
90
+
91
+ parser.separator ""
92
+ parser.separator "Common Options:"
93
+
94
+ parser.parse!(args)
95
+
96
+ return Options
97
+ end
98
+ end # class OptParse
99
+ end # module RunTest
100
+
@@ -0,0 +1,4 @@
1
+ module RunTest
2
+ PROGRAM_NAME = "RunTest"
3
+ VERSION = "2.0.0"
4
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devtools-runtest
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Donovan Young
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: config
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: devtools-base
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
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.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
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
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
97
+ description: Runs all or specific specs based on local configuration options
98
+ email:
99
+ - dyoung522@gmail.com
100
+ executables:
101
+ - runtest
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".codeclimate.yml"
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - devtools-runtest.gemspec
117
+ - exe/runtest
118
+ - lib/runtest.rb
119
+ - lib/runtest/options.rb
120
+ - lib/runtest/version.rb
121
+ homepage: https://github.com/dyoung522/devtools-runtest
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.6.8
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Runs specs based on configuration
145
+ test_files: []