aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit/runner.rb
Commit message (Collapse)AuthorAgeFilesLines
* Set the Rails environment from an environment variableAaron Patterson2017-12-081-4/+1
| | | | | | | | | Option parsing happens too late to have any impact on the Rails environment. Rails accesses the environment name and memoizes it too early in the boot process for a commandline option to have any impact on the database connection, so we'll change this test to set the environment from an environment variable (and ensure it still works when running tests with `ruby`)
* Fix Rails environment when running tests with RubyAaron Patterson2017-12-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | I frequently run tests with `ruby`, not with a runner like `rake` or `rails`. When running the test with just `ruby` the `RAILS_ENV` environment variable did not get set to "test", and this would cause the tests to fail (and even mutate the development database!) This commit adds integration tests for running tests with just `ruby` and ensures the environment gets defaulted to "test". I also added a test to ensure that passing an environment to `-e` actually works (and fixed that case too). An interesting / annoying thing is that Minitest picks up it's plugins by asking RubyGems for a list of files: https://github.com/seattlerb/minitest/blob/ca6a71ca901016db09a5ad466b4adea4b52a504a/lib/minitest.rb#L92-L100 This means that RubyGems needs to somehow know about the file before it can return it to Minitest. Since we are not packaging Rails as a Gem before running the integration tests on it (duh, why would you do that?), RubyGems doesn't know about the file, so it can't tell Minitest, so Minitest doesn't automatically require it. This means I had to manually require and insert the plugin in our integration test. I've left comments about that in the test as well. Ugh.
* Show minitest options in test runner helpyuuji.yaginuma2017-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #29572, minitest options are available but are no longer showed in help. This fixed to show minitest option in help as with Rails 5.1.2. **before** ``` ./bin/rails t --help You can run a single test by appending a line number to a filename: bin/rails test test/models/user_test.rb:27 You can run multiple files and directories at the same time: bin/rails test test/controllers test/integration/login_test.rb By default test failures and errors are reported inline during a run. Rails options: -w, --warnings Run with Ruby warnings enabled -e, --environment Run tests in the ENV environment -b, --backtrace Show the complete backtrace -d, --defer-output Output test failures and errors after the test run -f, --fail-fast Abort test run on first failure or error -c, --[no-]color Enable color in the output ``` **after** ``` ./bin/rails t --help You can run a single test by appending a line number to a filename: bin/rails test test/models/user_test.rb:27 You can run multiple files and directories at the same time: bin/rails test test/controllers test/integration/login_test.rb By default test failures and errors are reported inline during a run. minitest options: -h, --help Display this help. -s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake -v, --verbose Verbose. Show progress processing files. -n, --name PATTERN Filter run on /regexp/ or string. --exclude PATTERN Exclude /regexp/ or string from run. Known extensions: rails, pride -w, --warnings Run with Ruby warnings enabled -e, --environment Run tests in the ENV environment -b, --backtrace Show the complete backtrace -d, --defer-output Output test failures and errors after the test run -f, --fail-fast Abort test run on first failure or error -c, --[no-]color Enable color in the output -p, --pride Pride. Show your testing pride! ```
* Merge pull request #29926 from pawandubey:fix-test-with-absolute-pathsKasper Timm Hansen2017-07-251-1/+4
|\
| * Allow bin/rails test task to take absolute paths as argumentsPawan Dubey2017-07-251-3/+3
|/ | | | | | | | | | | | | | | | | | | Solves #29923 This regression was caused due to a wrong regex to filter out paths, introduced in commit 796a1cf0e The regex was /^\w+\// which did not accept paths with a leading slash and hence all absolute paths were filtered out. This change introduces a change in regex which allows for a leading slash and acts on the matched term accordingly. While cascading through the case block, the paths are checked for line number specification, existence of a directory at that path and if none of those match, then it is considered to be a path to the file. The regex matchers specified are filtered out via the call to `Array#compact` since they do not match any of these conditions.
* * Don't eagerly require Rails' minitest plugin.Kasper Timm Hansen2017-07-101-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
* Improve test runner's Minitest integration.Kasper Timm Hansen2015-06-041-137/+0
| | | | | | | | | | | This also adds free mix and matching of directories, files and lines filters. Like so: bin/rails test models/post_test.rb test/integration models/person_test.rb:26 You can also mix in a traditional Minitest filter: bin/rails test test/integration -n /check_it_out/
* Merge pull request #19441 from y-yagi/use_existArthur Nogueira Neves2015-03-211-1/+1
|\ | | | | use `Dir.exist?` instead of deprecated `Dir.exists?`
| * use `Dir.exist?` instead of deprecated `Dir.exists?`yuuji.yaginuma2015-03-211-1/+1
| |
* | Merge pull request #19445 from prathamesh-sonpatki/rm-ostructArthur Nogueira Neves2015-03-211-1/+0
|\ \ | | | | | | Removed requiring ostruct because its unused
| * | Removed requiring ostruct because its unusedPrathamesh Sonpatki2015-03-211-1/+0
| |/
* / Fix typos in test runner's help outputPrathamesh Sonpatki2015-03-211-2/+2
|/
* Use absolute path on find_method location for the runnerArthur Neves2015-03-191-1/+1
|
* move `ENV["BACKTRACE"]` support into the TestRunner.Yves Senn2015-03-181-1/+1
|
* `-p`, `--pattern` to run tests using a pattern.Yves Senn2015-03-181-0/+4
|
* use `bin/rails t` runner in `test_runner_test.rb`.Yves Senn2015-03-181-2/+2
|
* Fix relative dir call on test runnerArthur Neves2015-03-181-5/+10
|
* Add tests for runner#test_files methodArthur Neves2015-03-181-7/+7
|
* Run multiple files on runnerArthur Neves2015-03-181-4/+5
|
* `-e` / `--environment` for the test runner.Yves Senn2015-03-181-1/+7
|
* move argument parsing into the `Runner`.Yves Senn2015-03-181-0/+5
|
* get rid of NAMED_PATTERNS in favor of running a whole directoryYves Senn2015-03-181-7/+4
|
* document running a test by line number.Yves Senn2015-03-181-0/+7
|
* Move minitest pluginArthur Neves2015-03-181-15/+4
| | | | | | | Minitest Rails plugin should be loaded on test_help, so we report errors even when not running from the runner. Also fix the backtrace
* Move some logic to runnerArthur Neves2015-03-181-0/+10
|
* Better file:line parsing and filter method by file tooArthur Neves2015-03-181-11/+19
|
* If a nem given, use that name to filter the testArthur Neves2015-03-181-5/+1
|
* Add test run by line, and report error by lineArthur Neves2015-03-181-0/+27
|
* spike of a `OptionParser` backed test runner.Yves Senn2015-03-181-0/+83