├── lib ├── rubytest-cli.yml └── rubytest-cli.rb ├── .gitignore ├── .yardopts ├── HISTORY.md ├── bin ├── ruby-test └── rubytest ├── Gemfile ├── Indexfile ├── .index ├── LICENSE.txt ├── README.md ├── man ├── rubytest.1.ronn ├── rubytest.1 └── rubytest.1.html └── .gemspec /lib/rubytest-cli.yml: -------------------------------------------------------------------------------- 1 | ../.index -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .reap/digest 2 | .yardoc 3 | doc 4 | log 5 | pkg 6 | tmp 7 | web 8 | QED.md 9 | *.lock 10 | *.gem 11 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --title "Ruby Test CLI" 2 | --readme README.md 3 | --output-dir doc 4 | --protected 5 | --private 6 | lib 7 | - 8 | *.txt 9 | *.md 10 | 11 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | # RELEASE HISTORY 2 | 3 | ## 0.1.0 / 2013-02-19 4 | 5 | First release of Ruby Test CLI. 6 | 7 | Changes: 8 | 9 | * It's Your Birthday! 10 | 11 | -------------------------------------------------------------------------------- /bin/ruby-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | require 'rubytest-cli' 4 | Test::CLI.run 5 | rescue RuntimeError => error 6 | raise error if $DEBUG 7 | $stderr.puts error 8 | end 9 | 10 | -------------------------------------------------------------------------------- /bin/rubytest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | require 'rubytest-cli' 4 | Test::CLI.run 5 | rescue RuntimeError => error 6 | raise error if $DEBUG 7 | $stderr.puts error 8 | end 9 | 10 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rubytest", ">= 0.8.0" 4 | gem "ansi" 5 | 6 | group :build do 7 | #gem "fire" 8 | #gem "detroit" 9 | end 10 | 11 | group :test do 12 | #gem "qed" 13 | #gem "ae" 14 | end 15 | 16 | -------------------------------------------------------------------------------- /Indexfile: -------------------------------------------------------------------------------- 1 | --- 2 | name: 3 | rubytest-cli 4 | 5 | version: 6 | 0.2.0 7 | 8 | title: 9 | Rubytest CLI 10 | 11 | summary: 12 | Command line interface for Ruby Universal Test Harness 13 | 14 | description: 15 | Rubytest CLI is a command-line interface for running tests for 16 | Rubytest-based test frameworks. 17 | 18 | resources: 19 | home: http://rubyworks.github.com/rubytest-cli 20 | code: http://github.com/rubyworks/rubytest-cli 21 | bugs: http://github.com/rubyworks/rubytest-cli/issues 22 | mail: http://groups.google.com/group/rubyworks-mailinglist 23 | 24 | repositories: 25 | upstream: git@github.com:rubyworks/rubytest-cli.git 26 | 27 | authors: 28 | - trans 29 | 30 | created: 2011-07-23 31 | 32 | copyrights: 33 | - 2011 RubyWorks (BSD-2-Clause) 34 | 35 | -------------------------------------------------------------------------------- /.index: -------------------------------------------------------------------------------- 1 | --- 2 | revision: 2013 3 | type: ruby 4 | sources: 5 | - Indexfile 6 | - Gemfile 7 | authors: 8 | - name: trans 9 | email: transfire@gmail.com 10 | organizations: [] 11 | requirements: 12 | - version: '>= 0.8.0' 13 | name: rubytest 14 | - version: '>= 0' 15 | name: ansi 16 | conflicts: [] 17 | alternatives: [] 18 | resources: 19 | - type: home 20 | uri: http://rubyworks.github.com/rubytest-cli 21 | label: Homepage 22 | - type: code 23 | uri: http://github.com/rubyworks/rubytest-cli 24 | label: Source Code 25 | - type: bugs 26 | uri: http://github.com/rubyworks/rubytest-cli/issues 27 | label: Issue Tracker 28 | - type: mail 29 | uri: http://groups.google.com/group/rubyworks-mailinglist 30 | label: Mailing List 31 | repositories: 32 | - name: upstream 33 | scm: git 34 | uri: git@github.com:rubyworks/rubytest-cli.git 35 | categories: [] 36 | copyrights: 37 | - holder: RubyWorks 38 | year: '2011' 39 | license: BSD-2-Clause 40 | customs: [] 41 | paths: 42 | lib: 43 | - lib 44 | name: rubytest-cli 45 | title: Rubytest CLI 46 | version: 0.2.0 47 | summary: Command line interface for Ruby Universal Test Harness 48 | description: Rubytest CLI is a command-line interface for running tests for Rubytest-based 49 | test frameworks. 50 | created: '2011-07-23' 51 | date: '2014-07-18' 52 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | # COPYRIGHT NOTICES 2 | 3 | ## Ruby Test 4 | 5 | **Project** | Ruby Test 6 | --------------|------------------------------------------ 7 | **Website** | http://rubyworks.github.com/ruby-test 8 | **License** | BSD-2-Clause 9 | **Copyright** | (c) 2011 Rubyworks 10 | 11 | Copyright 2011 Rubyworks. All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 16 | 1. Redistributions of source code must retain the above copyright notice, 17 | this list of conditions and the following disclaimer. 18 | 19 | 2. Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | 23 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 24 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 25 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 30 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 32 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rubytest CLI 2 | 3 | [Website](http://rubyworks.github.com/rubytest-cli) / 4 | [Support](http://github.com/rubyworks/rubytest-cli/issues) / 5 | [Development](http://github.com/rubyworks/rubytest-cli) 6 | 7 | Command line interface for running tests for Rubytest-based test frameworks. 8 | 9 | 10 | ## Status 11 | 12 | [![Gem Version](http://img.shields.io/gem/v/rubytest-cli.svg?style=flat)](http://rubygems.org/gem/rubytest-cli) 13 | [![Build Status](http://img.shields.io/travis/rubyworks/rubytest-cli.svg?style=flat)](http://travis-ci.org/rubyworks/rubytest-cli) 14 | [![Fork Me](http://img.shields.io/badge/scm-github-blue.svg?style=flat)](http://github.com/rubyworks/rubytest-cli) 15 | [![Report Issue](http://img.shields.io/github/issues/rubyworks/rubytest-cli.svg?style=flat)](http://github.com/rubyworks/rubytest-cli/issues) 16 | [![Gittip](http://img.shields.io/badge/gittip-$1/wk-green.svg?style=flat)](https://www.gittip.com/on/github/rubyworks/) 17 | [![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund) 18 | 19 | 20 | ## Usage 21 | 22 | The rubytest command-line tool follows many of the usual conventions 23 | so it's use is farily straightforward. The `-h/--help` option is 24 | available to detail all its options. Here is a basic example of usage. 25 | 26 | $ rubytest -Ilib test/*_test.rb 27 | 28 | This would add `lib` to Ruby's $LOAD_PATH and then load all the 29 | test files matching the `test/*_test.rb` glob. 30 | 31 | When running tests, you need to be sure to load in your test framework 32 | or your framework's Ruby Test adapter. This is usually done via a helper 33 | script in the test files, but might also be done via command line options, 34 | e.g. 35 | 36 | $ rubytest -r lemon -r ae test/test_*.rb 37 | 38 | Of course, it can become tedious having to type such a long command 39 | over and over. One way to handle this is to use an a *runtime adjunct tool* 40 | like [DotOpts](http://rubyworks.github.com/dotopts). For example, a project 41 | might add a `.opts` file with the entry: 42 | 43 | rubytest 44 | -f progress 45 | -r spectroscope 46 | -r rspecial 47 | spec/spec_*.rb 48 | 49 | That will work in many cases, but to make things *solid* Ruby Test CLI 50 | supports a default configuration file. To utilize, add an `etc/test.rb` file 51 | to a project and add `Test.run` (or the alias `Test.configure`) entries to it. 52 | 53 | ```ruby 54 | Test.run do |r| 55 | r.loadpath 'lib' 56 | r.test_files << 'test/*_test.rb' 57 | end 58 | 59 | Test.run 'coverage' do |r| 60 | r.loadpath 'lib' 61 | r.test_files << 'test/*_test.rb' 62 | r.before do 63 | require 'simplecov' 64 | Simplecov.setup do |s| 65 | s.filter 'test/' 66 | s.command_name File.basename($0) 67 | s.coverage_dir 'log/coverage' 68 | end 69 | # to ensure proper coverage 70 | require 'myapp' 71 | end 72 | end 73 | ``` 74 | 75 | Now when rubytest is used, the first configuration will apply. To use 76 | the 'coverage' configuration use `-p/--profile` option. 77 | 78 | $ rubytest -p coverage 79 | 80 | In this manner a project can have any number of different test configurations, 81 | and it is easy to select between them. 82 | 83 | Note that the above example could have used `Test.configure` instead 84 | of `Test.run`. They do the same thing. But do not use `Test.run!` because 85 | that will cause testing to be run immediately. 86 | 87 | The configuration file can be in the `config` directory instead of `etc`, which 88 | is nice for Rails projects. But if you prefer a file in the project's root 89 | then either `Testfile` or `.test` can be also be used instead. All of these 90 | locations are supported simply because no one configuration convention has 91 | taken a solid hold in the Ruby community. However, we highly recommend using 92 | `etc/test.rb`. In the end that seems like the best overall convention. 93 | 94 | 95 | ## Copyrights 96 | 97 | Rubytest CLI is copyrighted open-source software. 98 | 99 | Copyright (c) 2013 Rubyworks. All rights reserved. 100 | 101 | It is redistributable and modifiable in accordance with the terms of the 102 | [BSD-2-Clause] license. 103 | 104 | See LICENSE.txt for the full text. 105 | 106 | 107 | -------------------------------------------------------------------------------- /man/rubytest.1.ronn: -------------------------------------------------------------------------------- 1 | rubytest(1) - ruby test via rubytest api 2 | ======================================== 3 | 4 | ## DESCRIPTION 5 | 6 | The rubytest command is a command line interface for running tests 7 | for RubyTest-based test frameworks. 8 | 9 | 10 | ## OVERVIEW 11 | 12 | The rubytest command-line tool follows many of the usual conventions 13 | so it's use is farily straightforward. The `-h/--help` option is 14 | available to detail all its options. Here is a basic example of usage. 15 | 16 | $ rubytest -Ilib test/*_test.rb 17 | 18 | This would add `lib` to Ruby's $LOAD_PATH and then load all the 19 | test files matching the `test/*_test.rb` glob. 20 | 21 | When running tests, you need to be sure to load in your test framework 22 | or your framework's Ruby Test adapter. This is usually done via a helper 23 | script in the test files, but might also be done via command line options, 24 | e.g. 25 | 26 | $ rubytest -r lemon -r ae test/test_*.rb 27 | 28 | Of course, it can become tedious having to type such a long command over and over. 29 | This can be dealt with via a configuration file. To utilize, add an `etc/test.rb` 30 | file to a project and add `Test.run` (an alias for `Test.configure`) entries to it. 31 | 32 | Test.run do |r| 33 | r.loadpath 'lib' 34 | r.test_files << 'test/*_test.rb' 35 | end 36 | 37 | Test.run 'coverage' do |r| 38 | r.loadpath 'lib' 39 | r.test_files << 'test/*_test.rb' 40 | r.before do 41 | require 'simplecov' 42 | Simplecov.setup do |s| 43 | s.filter 'test/' 44 | s.command_name File.basename($0) 45 | s.coverage_dir 'log/coverage' 46 | end 47 | # to ensure proper coverage 48 | require 'myapp' 49 | end 50 | end 51 | 52 | Now when rubytest is used, the first configuration will apply. To use 53 | the 'coverage' configuration use `-p/--profile` option. 54 | 55 | $ rubytest -p coverage 56 | 57 | In this manner a project can have any number of different test configurations, 58 | and it is easy to select between them. 59 | 60 | Note that the above example could have used `Test.configure` instead 61 | of `Test.run`. They do the same thing. But do not use `Test.run!` because 62 | that will cause testing to be run immediately. 63 | 64 | The configuration file can be in the `config` directory instead of `etc`, which 65 | is nice for Rails projects. But if you prefer a file in the project's root 66 | then either `Testfile` or `.test` can be also be used instead. All of these 67 | locations are supported simply because no one configuration convention has 68 | taken a solid hold in the Ruby community. However, we highly recommend using 69 | `etc/test.rb`. In the end that seems like the best overall convention. 70 | 71 | 72 | ## USAGE 73 | 74 | rubytest [options] [files ...] 75 | 76 | 77 | ## OPTIONS 78 | 79 | * `-p` `--profile ` 80 | Use configuration profile. 81 | 82 | * `-f` `--format ` 83 | Report format. 84 | 85 | * `y` `--tapy` 86 | Shortcut for -f tapy. 87 | 88 | * `-j` `--tapj` 89 | Shortcut for -f tapj. 90 | 91 | * `-t` `--tag ` 92 | Select tests by tag. 93 | 94 | * `-u` `--unit ` 95 | Select tests by software unit. 96 | 97 | * `-m` `--match ` 98 | Select tests by description. 99 | 100 | * `-A` `--autopath` 101 | Automatically add paths to $LOAD_PATH. 102 | 103 | * `-I` `--loadpath ` 104 | Add given path to $LOAD_PATH. 105 | 106 | * `-C` `--chdir ` 107 | Change directory before running tests. 108 | 109 | * `-R` `--chroot` 110 | Change to project root directory before running tests. 111 | 112 | * `-r` `--require ` 113 | Require file. 114 | 115 | * `-c` `--config ` 116 | Use alternate config file. 117 | 118 | * `-V` `--verbose` 119 | Provide extra detail in reports. 120 | 121 | * `--[no-]ansi` 122 | Turn on/off ANSI colors. 123 | 124 | * `--debug` 125 | Turn on debugging mode. 126 | 127 | * `--about` 128 | Display information about rubytest. 129 | 130 | * `--version` 131 | Display rubytest version. 132 | 133 | * `-h` `--help` 134 | Display this help message. 135 | 136 | 137 | ## RESOURCES 138 | 139 | * [Website](http://rubyworks.github.com/rubytest-cli) / 140 | * [Support](http://github.com/rubyworks/rubytest-cli/issues) / 141 | * [Development](http://github.com/rubyworks/rubytest-cli)     142 | * [![Build Status](https://secure.travis-ci.org/rubyworks/rubytest.png)](http://travis-ci.org/rubyworks/rubytest-cli) 143 | * [![Gem Version](https://badge.fury.io/rb/rubytest.png)](http://badge.fury.io/rb/rubytest-cli) 144 | 145 | 146 | ## COPYRIGHT 147 | 148 | Rubytest is copyrighted open-source software. 149 | 150 | Copyright (c) 2013 Rubyworks. All rights reserved. 151 | 152 | It is redistributable and modifiable in accordance with the terms of the 153 | BSD-2-Clause license. 154 | 155 | 156 | ## SEE ALSO 157 | 158 | ruby(1) 159 | 160 | -------------------------------------------------------------------------------- /man/rubytest.1: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "RUBYTEST" "1" "July 2014" "" "" 5 | . 6 | .SH "NAME" 7 | \fBrubytest\fR \- ruby test via rubytest api 8 | . 9 | .SH "DESCRIPTION" 10 | The rubytest command is a command line interface for running tests for RubyTest\-based test frameworks\. 11 | . 12 | .SH "OVERVIEW" 13 | The rubytest command\-line tool follows many of the usual conventions so it\'s use is farily straightforward\. The \fB\-h/\-\-help\fR option is available to detail all its options\. Here is a basic example of usage\. 14 | . 15 | .IP "" 4 16 | . 17 | .nf 18 | 19 | $ rubytest \-Ilib test/*_test\.rb 20 | . 21 | .fi 22 | . 23 | .IP "" 0 24 | . 25 | .P 26 | This would add \fBlib\fR to Ruby\'s $LOAD_PATH and then load all the test files matching the \fBtest/*_test\.rb\fR glob\. 27 | . 28 | .P 29 | When running tests, you need to be sure to load in your test framework or your framework\'s Ruby Test adapter\. This is usually done via a helper script in the test files, but might also be done via command line options, e\.g\. 30 | . 31 | .IP "" 4 32 | . 33 | .nf 34 | 35 | $ rubytest \-r lemon \-r ae test/test_*\.rb 36 | . 37 | .fi 38 | . 39 | .IP "" 0 40 | . 41 | .P 42 | Of course, it can become tedious having to type such a long command over and over\. This can be dealt with via a configuration file\. To utilize, add an \fBetc/test\.rb\fR file to a project and add \fBTest\.run\fR (an alias for \fBTest\.configure\fR) entries to it\. 43 | . 44 | .IP "" 4 45 | . 46 | .nf 47 | 48 | Test\.run do |r| 49 | r\.loadpath \'lib\' 50 | r\.test_files << \'test/*_test\.rb\' 51 | end 52 | 53 | Test\.run \'coverage\' do |r| 54 | r\.loadpath \'lib\' 55 | r\.test_files << \'test/*_test\.rb\' 56 | r\.before do 57 | require \'simplecov\' 58 | Simplecov\.setup do |s| 59 | s\.filter \'test/\' 60 | s\.command_name File\.basename($0) 61 | s\.coverage_dir \'log/coverage\' 62 | end 63 | # to ensure proper coverage 64 | require \'myapp\' 65 | end 66 | end 67 | . 68 | .fi 69 | . 70 | .IP "" 0 71 | . 72 | .P 73 | Now when rubytest is used, the first configuration will apply\. To use the \'coverage\' configuration use \fB\-p/\-\-profile\fR option\. 74 | . 75 | .IP "" 4 76 | . 77 | .nf 78 | 79 | $ rubytest \-p coverage 80 | . 81 | .fi 82 | . 83 | .IP "" 0 84 | . 85 | .P 86 | In this manner a project can have any number of different test configurations, and it is easy to select between them\. 87 | . 88 | .P 89 | Note that the above example could have used \fBTest\.configure\fR instead of \fBTest\.run\fR\. They do the same thing\. But do not use \fBTest\.run!\fR because that will cause testing to be run immediately\. 90 | . 91 | .P 92 | The configuration file can be in the \fBconfig\fR directory instead of \fBetc\fR, which is nice for Rails projects\. But if you prefer a file in the project\'s root then either \fBTestfile\fR or \fB\.test\fR can be also be used instead\. All of these locations are supported simply because no one configuration convention has taken a solid hold in the Ruby community\. However, we highly recommend using \fBetc/test\.rb\fR\. In the end that seems like the best overall convention\. 93 | . 94 | .SH "USAGE" 95 | . 96 | .nf 97 | 98 | rubytest [options] [files \.\.\.] 99 | . 100 | .fi 101 | . 102 | .SH "OPTIONS" 103 | . 104 | .IP "\(bu" 4 105 | \fB\-p\fR \fB\-\-profile \fR Use configuration profile\. 106 | . 107 | .IP "\(bu" 4 108 | \fB\-f\fR \fB\-\-format \fR Report format\. 109 | . 110 | .IP "\(bu" 4 111 | \fBy\fR \fB\-\-tapy\fR Shortcut for \-f tapy\. 112 | . 113 | .IP "\(bu" 4 114 | \fB\-j\fR \fB\-\-tapj\fR Shortcut for \-f tapj\. 115 | . 116 | .IP "\(bu" 4 117 | \fB\-t\fR \fB\-\-tag \fR Select tests by tag\. 118 | . 119 | .IP "\(bu" 4 120 | \fB\-u\fR \fB\-\-unit \fR Select tests by software unit\. 121 | . 122 | .IP "\(bu" 4 123 | \fB\-m\fR \fB\-\-match \fR Select tests by description\. 124 | . 125 | .IP "\(bu" 4 126 | \fB\-A\fR \fB\-\-autopath\fR Automatically add paths to $LOAD_PATH\. 127 | . 128 | .IP "\(bu" 4 129 | \fB\-I\fR \fB\-\-loadpath \fR Add given path to $LOAD_PATH\. 130 | . 131 | .IP "\(bu" 4 132 | \fB\-C\fR \fB\-\-chdir \fR Change directory before running tests\. 133 | . 134 | .IP "\(bu" 4 135 | \fB\-R\fR \fB\-\-chroot\fR Change to project root directory before running tests\. 136 | . 137 | .IP "\(bu" 4 138 | \fB\-r\fR \fB\-\-require \fR Require file\. 139 | . 140 | .IP "\(bu" 4 141 | \fB\-c\fR \fB\-\-config \fR Use alternate config file\. 142 | . 143 | .IP "\(bu" 4 144 | \fB\-V\fR \fB\-\-verbose\fR Provide extra detail in reports\. 145 | . 146 | .IP "\(bu" 4 147 | \fB\-\-[no\-]ansi\fR Turn on/off ANSI colors\. 148 | . 149 | .IP "\(bu" 4 150 | \fB\-\-debug\fR Turn on debugging mode\. 151 | . 152 | .IP "\(bu" 4 153 | \fB\-\-about\fR Display information about rubytest\. 154 | . 155 | .IP "\(bu" 4 156 | \fB\-\-version\fR Display rubytest version\. 157 | . 158 | .IP "\(bu" 4 159 | \fB\-h\fR \fB\-\-help\fR Display this help message\. 160 | . 161 | .IP "" 0 162 | . 163 | .SH "RESOURCES" 164 | . 165 | .IP "\(bu" 4 166 | Website \fIhttp://rubyworks\.github\.com/rubytest\-cli\fR / 167 | . 168 | .IP "\(bu" 4 169 | Support \fIhttp://github\.com/rubyworks/rubytest\-cli/issues\fR / 170 | . 171 | .IP "\(bu" 4 172 | Development \fIhttp://github\.com/rubyworks/rubytest\-cli\fR \~ \~ 173 | . 174 | .IP "\(bu" 4 175 | \fIhttp://travis\-ci\.org/rubyworks/rubytest\-cli\fR 176 | . 177 | .IP "\(bu" 4 178 | \fIhttp://badge\.fury\.io/rb/rubytest\-cli\fR 179 | . 180 | .IP "" 0 181 | . 182 | .SH "COPYRIGHT" 183 | Rubytest is copyrighted open\-source software\. 184 | . 185 | .IP "" 4 186 | . 187 | .nf 188 | 189 | Copyright (c) 2013 Rubyworks\. All rights reserved\. 190 | . 191 | .fi 192 | . 193 | .IP "" 0 194 | . 195 | .P 196 | It is redistributable and modifiable in accordance with the terms of the BSD\-2\-Clause license\. 197 | . 198 | .SH "SEE ALSO" 199 | ruby(1) 200 | -------------------------------------------------------------------------------- /lib/rubytest-cli.rb: -------------------------------------------------------------------------------- 1 | require 'rubytest' 2 | 3 | module Test 4 | 5 | # Command line interface to test runner. 6 | # 7 | class CLI 8 | 9 | # Test configuration file can be in `etc/test.rb` or `config/test.rb`, or 10 | # `Testfile` or '.test` with optional `.rb` extension, in that order of 11 | # precedence. To use a different file there is the -c/--config option. 12 | GLOB_CONFIG = '{etc/test.rb,config/test.rb,testfile.rb,testfile,.test.rb,.test}' 13 | 14 | # Convenience method for invoking the CLI. 15 | # 16 | # @return nothing 17 | def self.run(*argv) 18 | new.run(*argv) 19 | end 20 | 21 | # Initialize CLI instance. 22 | # 23 | # @return nothing 24 | def initialize 25 | require 'optparse' 26 | 27 | @config = {} 28 | @config_file = nil 29 | #@config = Test.configuration(true) 30 | end 31 | 32 | # Run tests. 33 | # 34 | # @return nothing 35 | def run(argv=nil) 36 | #require_dotopts 37 | argv = (argv || ARGV.dup) 38 | options.parse!(argv) 39 | 40 | @config[:files] = argv unless argv.empty? 41 | 42 | load_config 43 | 44 | test_config = Test.configuration(profile) 45 | test_config.apply_environment_defaults 46 | test_config.apply(@config) 47 | 48 | Test.run!(test_config) 49 | 50 | #runner = Runner.new(test_config) 51 | #begin 52 | # success = runner.run 53 | # exit -1 unless success 54 | #rescue => error 55 | # raise error if $DEBUG 56 | # $stderr.puts('ERROR: ' + error.to_s) 57 | # exit -1 58 | #end 59 | end 60 | 61 | # TODO: Not sure if this should be used or not. 62 | def require_dotopts 63 | begin 64 | require 'dotopts' 65 | rescue LoadError 66 | end 67 | end 68 | 69 | # Setup OptionsParser instance. 70 | # 71 | # @return [OptionParser] 72 | def options 73 | conf = self 74 | 75 | OptionParser.new do |opt| 76 | opt.banner = "Usage: #{File.basename($0)} [options] [files ...]" 77 | 78 | opt.on '-p', '--profile NAME', 'use configuration profile' do |name| 79 | conf.profile = name 80 | end 81 | 82 | #opt.separator "PRESET OPTIONS:" 83 | #pnames = profile_names 84 | #unless pnames.empty? 85 | # pnames.each do |pname| 86 | # opt.separator((" " * 40) + "* #{pname}") 87 | # end 88 | #end 89 | #opt.separator "CONFIG OPTIONS:" 90 | 91 | opt.on '-f', '--format NAME', 'report format' do |name| 92 | conf.format = name 93 | end 94 | opt.on '-y', '--tapy', 'shortcut for -f tapy' do 95 | conf.format = 'tapy' 96 | end 97 | opt.on '-j', '--tapj', 'shortcut for -f tapj' do 98 | conf.format = 'tapj' 99 | end 100 | 101 | # tempted to change -T 102 | opt.on '-t', '--tag TAG', 'select tests by tag' do |tag| 103 | conf.tags.concat makelist(tag) 104 | end 105 | opt.on '-u', '--unit TAG', 'select tests by software unit' do |unit| 106 | conf.units.concat makelist(unit) 107 | end 108 | opt.on '-m', '--match TEXT', 'select tests by description' do |text| 109 | conf.match.concat makelist(text) 110 | end 111 | 112 | opt.on '-A', '--autopath', 'automatically add paths to $LOAD_PATH' do |paths| 113 | conf.autopath = true 114 | end 115 | opt.on '-I', '--loadpath PATH', 'add given path to $LOAD_PATH' do |paths| 116 | #makelist(paths).reverse_each do |path| 117 | # $LOAD_PATH.unshift path 118 | #end 119 | conf.loadpath.concat makelist(paths) 120 | end 121 | opt.on '-C', '--chdir DIR', 'change directory before running tests' do |dir| 122 | conf.chdir = dir 123 | end 124 | opt.on '-R', '--chroot', 'change to project root directory before running tests' do 125 | conf.chdir = Config.root 126 | end 127 | opt.on '-r', '--require FILE', 'require file' do |file| 128 | conf.requires.concat makelist(file) 129 | end 130 | opt.on '-c', '--config FILE', "use alternate config file" do |file| 131 | conf.config_files << file 132 | end 133 | #opt.on '-T', '--tests GLOB', "tests to run (if none given as arguments)" do |glob| 134 | # config.files << glob 135 | #end 136 | opt.on '-V' , '--verbose', 'provide extra detail in reports' do 137 | conf.verbose = true 138 | end 139 | #opt.on('--log PATH', 'log test output to path'){ |path| 140 | # config.log = path 141 | #} 142 | opt.on("--[no-]ansi" , 'turn on/off ANSI colors'){ |v| $ansi = v } 143 | opt.on("--debug" , 'turn on debugging mode'){ $DEBUG = true } 144 | 145 | #opt.separator "COMMAND OPTIONS:" 146 | opt.on('--about' , 'display information about rubytest') do 147 | puts "Ruby Test v%s" % [Test.index['version']] 148 | Test.index['copyrights'].each do |c| 149 | puts "(c) %s %s (%s)" % c.values_at('year', 'holder', 'license') 150 | end 151 | exit 152 | end 153 | opt.on('--version' , 'display rubytest version') do 154 | puts Test::VERSION 155 | exit 156 | end 157 | opt.on('-h', '--help', 'display this help message'){ 158 | puts opt 159 | exit 160 | } 161 | end 162 | end 163 | 164 | # Test run configuration. 165 | # 166 | # @return [Hash] 167 | def config 168 | @config 169 | end 170 | 171 | # Load configuration file. An example file might look like: 172 | # 173 | # Test.configure do |run| 174 | # run.files << 'test/case_*.rb' 175 | # end 176 | # 177 | # @deprecated Planned for deprecation in April 2013. 178 | def load_config 179 | file = config_file 180 | unless file 181 | if chdir 182 | file = Dir.glob(File.join(chdir, GLOB_CONFIG)).first 183 | else 184 | file = Dir.glob(GLOB_CONFIG).first 185 | end 186 | end 187 | load file if file 188 | end 189 | 190 | # Find traditional configuration file. 191 | # 192 | # @return [String] Config file path. 193 | def config_file 194 | @config_file 195 | end 196 | 197 | # 198 | def profile 199 | @profile 200 | end 201 | 202 | # 203 | def profile=(name) 204 | @profile = name.to_s 205 | end 206 | 207 | # 208 | def format 209 | @config[:format] 210 | end 211 | 212 | # 213 | def format=(format) 214 | @config[:format] = format.to_s 215 | end 216 | 217 | def tags 218 | @config[:tags] ||= [] 219 | end 220 | 221 | def units 222 | @config[:units] ||= [] 223 | end 224 | 225 | def match 226 | @config[:match] ||= [] 227 | end 228 | 229 | def autopath? 230 | @config[:autopath] 231 | end 232 | 233 | def autopath=(bool) 234 | @config[:autopath] = !! bool 235 | end 236 | 237 | def chdir 238 | @config[:chdir] 239 | end 240 | 241 | def chdir=(dir) 242 | @config[:chdir] = dir.to_str 243 | end 244 | 245 | def loadpath 246 | @config[:loadpath] ||= [] 247 | end 248 | 249 | def requires 250 | @config[:requires] ||= [] 251 | end 252 | 253 | def verbose? 254 | @config[:verbose] 255 | end 256 | 257 | def verbose=(bool) 258 | @config[:verbose] = !! bool 259 | end 260 | 261 | private 262 | 263 | # If given a String then split up at `:` and `;` markers. 264 | # Otherwise ensure the list is an Array and the entries are 265 | # all strings and not empty. 266 | # 267 | # @return [Array] 268 | def makelist(list) 269 | case list 270 | when String 271 | list = list.split(/[:;]/) 272 | else 273 | list = Array(list).map{ |path| path.to_s } 274 | end 275 | list.reject{ |path| path.strip.empty? } 276 | end 277 | 278 | end 279 | 280 | end 281 | -------------------------------------------------------------------------------- /.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'yaml' 4 | require 'pathname' 5 | 6 | module Indexer 7 | 8 | # Convert index data into a gemspec. 9 | # 10 | # Notes: 11 | # * Assumes all executables are in bin/. 12 | # * Does not yet handle default_executable setting. 13 | # * Does not yet handle platform setting. 14 | # * Does not yet handle required_ruby_version. 15 | # * Support for rdoc entries is weak. 16 | # 17 | class GemspecExporter 18 | 19 | # File globs to include in package --unless a manifest file exists. 20 | FILES = ".index .yardopts alt bin data demo ext features lib man spec test try* [A-Z]*.*" unless defined?(FILES) 21 | 22 | # File globs to omit from FILES. 23 | OMIT = "Config.rb" unless defined?(OMIT) 24 | 25 | # Standard file patterns. 26 | PATTERNS = { 27 | :root => '{.index,Gemfile}', 28 | :bin => 'bin/*', 29 | :lib => 'lib/{**/}*', #.rb', 30 | :ext => 'ext/{**/}extconf.rb', 31 | :doc => '*.{txt,rdoc,md,markdown,tt,textile}', 32 | :test => '{test,spec}/{**/}*.rb' 33 | } unless defined?(PATTERNS) 34 | 35 | # For which revision of indexer spec is this converter intended? 36 | REVISION = 2013 unless defined?(REVISION) 37 | 38 | # 39 | def self.gemspec 40 | new.to_gemspec 41 | end 42 | 43 | # 44 | attr :metadata 45 | 46 | # 47 | def initialize(metadata=nil) 48 | @root_check = false 49 | 50 | if metadata 51 | root_dir = metadata.delete(:root) 52 | if root_dir 53 | @root = root_dir 54 | @root_check = true 55 | end 56 | metadata = nil if metadata.empty? 57 | end 58 | 59 | @metadata = metadata || YAML.load_file(root + '.index') 60 | 61 | if @metadata['revision'].to_i != REVISION 62 | warn "This gemspec exporter was not designed for this revision of index metadata." 63 | end 64 | end 65 | 66 | # 67 | def has_root? 68 | root ? true : false 69 | end 70 | 71 | # 72 | def root 73 | return @root if @root || @root_check 74 | @root_check = true 75 | @root = find_root 76 | end 77 | 78 | # 79 | def manifest 80 | return nil unless root 81 | @manifest ||= Dir.glob(root + 'manifest{,.txt}', File::FNM_CASEFOLD).first 82 | end 83 | 84 | # 85 | def scm 86 | return nil unless root 87 | @scm ||= %w{git hg}.find{ |m| (root + ".#{m}").directory? }.to_sym 88 | end 89 | 90 | # 91 | def files 92 | return [] unless root 93 | @files ||= \ 94 | if manifest 95 | File.readlines(manifest). 96 | map{ |line| line.strip }. 97 | reject{ |line| line.empty? || line[0,1] == '#' } 98 | else 99 | list = [] 100 | Dir.chdir(root) do 101 | FILES.split(/\s+/).each do |pattern| 102 | list.concat(glob(pattern)) 103 | end 104 | OMIT.split(/\s+/).each do |pattern| 105 | list = list - glob(pattern) 106 | end 107 | end 108 | list 109 | end.select{ |path| File.file?(path) }.uniq 110 | end 111 | 112 | # 113 | def glob_files(pattern) 114 | return [] unless root 115 | Dir.chdir(root) do 116 | Dir.glob(pattern).select do |path| 117 | File.file?(path) && files.include?(path) 118 | end 119 | end 120 | end 121 | 122 | def patterns 123 | PATTERNS 124 | end 125 | 126 | def executables 127 | @executables ||= \ 128 | glob_files(patterns[:bin]).map do |path| 129 | File.basename(path) 130 | end 131 | end 132 | 133 | def extensions 134 | @extensions ||= \ 135 | glob_files(patterns[:ext]).map do |path| 136 | File.basename(path) 137 | end 138 | end 139 | 140 | def name 141 | metadata['name'] || metadata['title'].downcase.gsub(/\W+/,'_') 142 | end 143 | 144 | def homepage 145 | page = ( 146 | metadata['resources'].find{ |r| r['type'] =~ /^home/i } || 147 | metadata['resources'].find{ |r| r['name'] =~ /^home/i } || 148 | metadata['resources'].find{ |r| r['name'] =~ /^web/i } 149 | ) 150 | page ? page['uri'] : false 151 | end 152 | 153 | def licenses 154 | metadata['copyrights'].map{ |c| c['license'] }.compact 155 | end 156 | 157 | def require_paths 158 | paths = metadata['paths'] || {} 159 | paths['load'] || ['lib'] 160 | end 161 | 162 | # 163 | # Convert to gemnspec. 164 | # 165 | def to_gemspec 166 | if has_root? 167 | Gem::Specification.new do |gemspec| 168 | to_gemspec_data(gemspec) 169 | to_gemspec_paths(gemspec) 170 | end 171 | else 172 | Gem::Specification.new do |gemspec| 173 | to_gemspec_data(gemspec) 174 | to_gemspec_paths(gemspec) 175 | end 176 | end 177 | end 178 | 179 | # 180 | # Convert pure data settings. 181 | # 182 | def to_gemspec_data(gemspec) 183 | gemspec.name = name 184 | gemspec.version = metadata['version'] 185 | gemspec.summary = metadata['summary'] 186 | gemspec.description = metadata['description'] 187 | 188 | metadata['authors'].each do |author| 189 | gemspec.authors << author['name'] 190 | 191 | if author.has_key?('email') 192 | if gemspec.email 193 | gemspec.email << author['email'] 194 | else 195 | gemspec.email = [author['email']] 196 | end 197 | end 198 | end 199 | 200 | gemspec.licenses = licenses 201 | 202 | requirements = metadata['requirements'] || [] 203 | requirements.each do |req| 204 | next if req['optional'] 205 | next if req['external'] 206 | 207 | name = req['name'] 208 | groups = req['groups'] || [] 209 | 210 | version = gemify_version(req['version']) 211 | 212 | if groups.empty? or groups.include?('runtime') 213 | # populate runtime dependencies 214 | if gemspec.respond_to?(:add_runtime_dependency) 215 | gemspec.add_runtime_dependency(name,*version) 216 | else 217 | gemspec.add_dependency(name,*version) 218 | end 219 | else 220 | # populate development dependencies 221 | if gemspec.respond_to?(:add_development_dependency) 222 | gemspec.add_development_dependency(name,*version) 223 | else 224 | gemspec.add_dependency(name,*version) 225 | end 226 | end 227 | end 228 | 229 | # convert external dependencies into gemspec requirements 230 | requirements.each do |req| 231 | next unless req['external'] 232 | gemspec.requirements << ("%s-%s" % req.values_at('name', 'version')) 233 | end 234 | 235 | gemspec.homepage = homepage 236 | gemspec.require_paths = require_paths 237 | gemspec.post_install_message = metadata['install_message'] 238 | end 239 | 240 | # 241 | # Set gemspec settings that require a root directory path. 242 | # 243 | def to_gemspec_paths(gemspec) 244 | gemspec.files = files 245 | gemspec.extensions = extensions 246 | gemspec.executables = executables 247 | 248 | if Gem::VERSION < '1.7.' 249 | gemspec.default_executable = gemspec.executables.first 250 | end 251 | 252 | gemspec.test_files = glob_files(patterns[:test]) 253 | 254 | unless gemspec.files.include?('.document') 255 | gemspec.extra_rdoc_files = glob_files(patterns[:doc]) 256 | end 257 | end 258 | 259 | # 260 | # Return a copy of this file. This is used to generate a local 261 | # .gemspec file that can automatically read the index file. 262 | # 263 | def self.source_code 264 | File.read(__FILE__) 265 | end 266 | 267 | private 268 | 269 | def find_root 270 | root_files = patterns[:root] 271 | if Dir.glob(root_files).first 272 | Pathname.new(Dir.pwd) 273 | elsif Dir.glob("../#{root_files}").first 274 | Pathname.new(Dir.pwd).parent 275 | else 276 | #raise "Can't find root of project containing `#{root_files}'." 277 | warn "Can't find root of project containing `#{root_files}'." 278 | nil 279 | end 280 | end 281 | 282 | def glob(pattern) 283 | if File.directory?(pattern) 284 | Dir.glob(File.join(pattern, '**', '*')) 285 | else 286 | Dir.glob(pattern) 287 | end 288 | end 289 | 290 | def gemify_version(version) 291 | case version 292 | when /^(.*?)\+$/ 293 | ">= #{$1}" 294 | when /^(.*?)\-$/ 295 | "< #{$1}" 296 | when /^(.*?)\~$/ 297 | "~> #{$1}" 298 | else 299 | version 300 | end 301 | end 302 | 303 | end 304 | 305 | end 306 | 307 | Indexer::GemspecExporter.gemspec -------------------------------------------------------------------------------- /man/rubytest.1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | rubytest(1) - ruby test via rubytest api 7 | 44 | 45 | 52 | 53 |
54 | 55 | 65 | 66 |
    67 |
  1. rubytest(1)
  2. 68 |
  3. 69 |
  4. rubytest(1)
  5. 70 |
71 | 72 |

NAME

73 |

74 | rubytest - ruby test via rubytest api 75 |

76 | 77 |

DESCRIPTION

78 | 79 |

The rubytest command is a command line interface for running tests 80 | for RubyTest-based test frameworks.

81 | 82 |

OVERVIEW

83 | 84 |

The rubytest command-line tool follows many of the usual conventions 85 | so it's use is farily straightforward. The -h/--help option is 86 | available to detail all its options. Here is a basic example of usage.

87 | 88 |
$ rubytest -Ilib test/*_test.rb
 89 | 
90 | 91 |

This would add lib to Ruby's $LOAD_PATH and then load all the 92 | test files matching the test/*_test.rb glob.

93 | 94 |

When running tests, you need to be sure to load in your test framework 95 | or your framework's Ruby Test adapter. This is usually done via a helper 96 | script in the test files, but might also be done via command line options, 97 | e.g.

98 | 99 |
$ rubytest -r lemon -r ae test/test_*.rb
100 | 
101 | 102 |

Of course, it can become tedious having to type such a long command over and over. 103 | This can be dealt with via a configuration file. To utilize, add an etc/test.rb 104 | file to a project and add Test.run (an alias for Test.configure) entries to it.

105 | 106 |
Test.run do |r|
107 |   r.loadpath 'lib'
108 |   r.test_files << 'test/*_test.rb'
109 | end
110 | 
111 | Test.run 'coverage' do |r|
112 |   r.loadpath 'lib'
113 |   r.test_files << 'test/*_test.rb'
114 |   r.before do
115 |     require 'simplecov'
116 |     Simplecov.setup do |s|
117 |       s.filter 'test/'
118 |       s.command_name File.basename($0)
119 |       s.coverage_dir 'log/coverage'    
120 |     end
121 |     # to ensure proper coverage
122 |     require 'myapp'
123 |   end
124 | end
125 | 
126 | 127 |

Now when rubytest is used, the first configuration will apply. To use 128 | the 'coverage' configuration use -p/--profile option.

129 | 130 |
$ rubytest -p coverage
131 | 
132 | 133 |

In this manner a project can have any number of different test configurations, 134 | and it is easy to select between them.

135 | 136 |

Note that the above example could have used Test.configure instead 137 | of Test.run. They do the same thing. But do not use Test.run! because 138 | that will cause testing to be run immediately.

139 | 140 |

The configuration file can be in the config directory instead of etc, which 141 | is nice for Rails projects. But if you prefer a file in the project's root 142 | then either Testfile or .test can be also be used instead. All of these 143 | locations are supported simply because no one configuration convention has 144 | taken a solid hold in the Ruby community. However, we highly recommend using 145 | etc/test.rb. In the end that seems like the best overall convention.

146 | 147 |

USAGE

148 | 149 |
rubytest [options] [files ...]
150 | 
151 | 152 |

OPTIONS

153 | 154 |
    155 |
  • -p --profile <NAME> 156 | Use configuration profile.

  • 157 |
  • -f --format <NAME> 158 | Report format.

  • 159 |
  • y --tapy 160 | Shortcut for -f tapy.

  • 161 |
  • -j --tapj 162 | Shortcut for -f tapj.

  • 163 |
  • -t --tag <TAG> 164 | Select tests by tag.

  • 165 |
  • -u --unit <TAG> 166 | Select tests by software unit.

  • 167 |
  • -m --match <TEXT> 168 | Select tests by description.

  • 169 |
  • -A --autopath 170 | Automatically add paths to $LOAD_PATH.

  • 171 |
  • -I --loadpath <PATH> 172 | Add given path to $LOAD_PATH.

  • 173 |
  • -C --chdir <DIR> 174 | Change directory before running tests.

  • 175 |
  • -R --chroot 176 | Change to project root directory before running tests.

  • 177 |
  • -r --require <FILE> 178 | Require file.

  • 179 |
  • -c --config <FILE> 180 | Use alternate config file.

  • 181 |
  • -V --verbose 182 | Provide extra detail in reports.

  • 183 |
  • --[no-]ansi 184 | Turn on/off ANSI colors.

  • 185 |
  • --debug 186 | Turn on debugging mode.

  • 187 |
  • --about 188 | Display information about rubytest.

  • 189 |
  • --version 190 | Display rubytest version.

  • 191 |
  • -h --help 192 | Display this help message.

  • 193 |
194 | 195 | 196 |

RESOURCES

197 | 198 | 205 | 206 | 207 | 208 | 209 |

Rubytest is copyrighted open-source software.

210 | 211 |
Copyright (c) 2013 Rubyworks. All rights reserved.
212 | 
213 | 214 |

It is redistributable and modifiable in accordance with the terms of the 215 | BSD-2-Clause license.

216 | 217 |

SEE ALSO

218 | 219 |

ruby(1)

220 | 221 | 222 |
    223 |
  1. 224 |
  2. July 2014
  3. 225 |
  4. rubytest(1)
  5. 226 |
227 | 228 |
229 | 230 | 231 | --------------------------------------------------------------------------------