From ff2f766f2fcb17c7284b32e16fad7c15a47ca97e Mon Sep 17 00:00:00 2001 From: Gavin Laking Date: Sat, 10 Oct 2015 17:50:20 +0100 Subject: [PATCH] Update settings and documentation for various environment variables available. --- .yardopts | 1 + Guardfile | 3 +-- README.md | 54 ++++++++++++++++++++++++++++++++++++--- Rakefile | 20 ++++++++++++--- test/support/all_seeds.sh | 9 ------- test/test_helper.rb | 44 +++++++++++++++---------------- 6 files changed, 90 insertions(+), 41 deletions(-) delete mode 100755 test/support/all_seeds.sh diff --git a/.yardopts b/.yardopts index 2e2eee2e1..674c965d9 100644 --- a/.yardopts +++ b/.yardopts @@ -24,4 +24,5 @@ docs/events/menu.md docs/events/movement.md docs/events/refresh.md docs/events/system.md +docs/events/view.md docs/events/visibility.md diff --git a/Guardfile b/Guardfile index 6dbc358ac..6e56eac20 100644 --- a/Guardfile +++ b/Guardfile @@ -4,8 +4,7 @@ guard :rubocop do end guard :minitest, all_after_pass: true, - focus_on_failed: true, - env: { 'NO_SIMPLECOV' => true } do + focus_on_failed: true do watch(%r{^test/(.*)_test\.rb}) watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" } watch(%r{^test/test_helper\.rb}) { 'test' } diff --git a/README.md b/README.md index 6145f1f54..0ebc0b0e3 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,63 @@ Pull requests are very welcome! Please try to follow these simple rules if * Make sure your patches are well tested. * Update the [Yard](http://yardoc.org/) documentation. (Use `yard stats --list-undoc` to locate undocumented code) -* Update the [README](https://github.com/gavinlaking/vedeu/blob/master/README.md). +* Update the + [README](https://github.com/gavinlaking/vedeu/blob/master/README.md), + if appropriate. * Please **do not change** the version number. +Raising issues and finding bugs, updating documentation and improving + the code are all welcome contributions. I may also have left some TODO + items lying around, which you're quite welcome to and can find + with either Yard, or git: + + yard list --query '@todo' + + git grep --line-number '@todo' + + Any branch on the repository that is not `master` is probably experimental; do not rely on anything in these branches. Typically, `twerks` will be merged into `master` before a release, and branches prefixed with `spike/` are me - playing with ideas. + playing with ideas- they aren't guaranteed to work at all. -I may have left some TODO items lying around, which you can find with: +Various environment variables are available to you to help with testing, all of + which can be used in combination, prefaced to `rake`: + +- Produce statistics on the slowest performing parts of the + application/tests. Useful when used multiple times. See + `test/test_helper.rb` for configuration. + + PERFORMANCE=1 rake + +- Produce a 'SimpleCov' test coverage report in the `coverage/` + directory. + + SIMPLECOV=1 rake + +- Produces a 'SimpleCov' test coverage report with output to the + console. + + CONSOLE_COVERAGE=1 rake + +- Enable Ruby's warnings mode (this can usually be quote verbose, but + thankfully more so with gem dependencies rather than Vedeu itself). + + WARNINGS=1 rake + +- Disable Ruby's garbage collection for this test run. + + DISABLE_GC=1 rake + +- Use Rubocop to catch coding misdemeanours for this test run. (Or + use `rake rubocop`). + + RUBOCOP=1 rake + +- Build the Yard documentation for the project. (Or use `rake yard`). + + YARD=1 rake - yard list --query '@todo' ### General contribution help diff --git a/Rakefile b/Rakefile index 962112688..2cf2c5be7 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ Rake::TestTask.new(:test) do |task| task.libs.push 'test' task.pattern = 'test/**/*_test.rb' task.verbose = false - task.warning = false # set to true for Ruby warnings (ruby -w) + task.warning = true if ENV['WARNINGS'] end YARD::Rake::YardocTask.new(:yard) do |task| @@ -16,11 +16,19 @@ YARD::Rake::YardocTask.new(:yard) do |task| 'lib/**/*.rb', '-', 'docs/api.md', + 'docs/border.md', + 'docs/buffer.md', 'docs/configuration.md', + 'docs/cursor.md', 'docs/dsl.md', 'docs/events.md', + 'docs/geometry.md', 'docs/getting_started.md', + 'docs/group.md', + 'docs/interfaces.md', + 'docs/keymaps.md', 'docs/object_graph.md', + 'docs/view.md', 'docs/events/application.md', 'docs/events/document.md', 'docs/events/drb.md', @@ -32,14 +40,18 @@ YARD::Rake::YardocTask.new(:yard) do |task| 'docs/events/view.md', 'docs/events/visibility.md', ] - task.options = ['--highlight'] + task.options = ['highlight'] task.stats_options = ['--list-undoc'] end RuboCop::RakeTask.new(:rubocop) do |task| task.patterns = ['lib/**/*.rb'] - task.formatters = ['progress'] + task.formatters = ['simple'] task.fail_on_error = false end -task default: :test +tasks_to_run = [:test] +tasks_to_run << :rubocop if ENV['RUBOCOP'] +tasks_to_run << :yard if ENV['YARD'] + +task default: tasks_to_run diff --git a/test/support/all_seeds.sh b/test/support/all_seeds.sh deleted file mode 100755 index ac38f0c3e..000000000 --- a/test/support/all_seeds.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env ruby - -1.upto(99999) do |seed| - if system("rake NO_SIMPLECOV=1 SEED=#{seed} > /dev/null") - puts "SEED #{seed} successful" - else - puts "SEED #{seed} failure" - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index b23dcf73b..c05ac36a7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,17 +1,7 @@ -unless ENV['NO_SIMPLECOV'] +if ENV['SIMPLECOV'] || ENV['CONSOLE_COVERAGE'] require 'simplecov' require 'simplecov-console' if ENV['CONSOLE_COVERAGE'] -end -require 'pry' -require 'minitest/autorun' -require 'minitest/pride' unless ENV['NO_COLOR'] -require 'minitest/hell' - -# GC.disable # Uncomment to remove ~20ms from test run speed; left uncommented - # though makes tests slower over time with 'guard'. - -unless ENV['NO_SIMPLECOV'] SimpleCov.start do formatter SimpleCov::Formatter::Console if ENV['CONSOLE_COVERAGE'] command_name 'MiniTest::Spec' @@ -45,6 +35,16 @@ end end +require 'pry' +require 'minitest/autorun' +require 'minitest/pride' +require 'minitest/hell' + +# Appears to remove ~20ms from test run speed. +if ENV['DISABLE_GC'] + GC.disable +end + module VedeuMiniTestPlugin # def before_setup # # Vedeu::Repositories.reset! @@ -90,17 +90,17 @@ class << self require 'vedeu' require 'support/helpers/model_test_class' -require 'minitest/reporters' -require 'minitest/reporters/mean_time_reporter' -Minitest::Reporters.use!( - # # commented out by default (makes tests slower) - Minitest::Reporters::MeanTimeReporter.new({ - previous_runs_filename: "/tmp/durations", - report_filename: "/tmp/durations_results"}) - # Minitest::Reporters::DefaultReporter.new({ color: true, - # slow_suite_count: 15 }), - # Minitest::Reporters::SpecReporter.new -) +if ENV['PERFORMANCE'] + require 'minitest/reporters' + require 'minitest/reporters/mean_time_reporter' + + Minitest::Reporters.use!( + Minitest::Reporters::MeanTimeReporter.new({ + previous_runs_filename: "/tmp/durations", + report_filename: "/tmp/durations_results" + }) + ) +end def test_configuration Vedeu::Configuration.reset!