Coder Social home page Coder Social logo

autotest's Introduction

Standalone autotest extracted from ZenTest.

As soon as you save a file, autotest will run the matching tests.

Improvements over ZenTest

  • -c not run all tests after a failed test passes
  • -r use given config file
  • -p use parallel_tests to run tests (Test::Unit only)
  • -s use any style you want -> alias autospec2="autotest --style rspec2"
  • -b use bundle exec to run tests
  • -n notify about results (simple + experimental)
  • simplified test setup
  • simplified packaging
  • less globals
  • integration tests

Install

sudo gem uninstall ZenTest
sudo gem install autotest-standalone

Optional: Autotest for Test::Unit on Rails

sudo gem install autotest-rails-pure

Optional: ZenTest without Autotest version:

sudo gem install zentest-without-autotest

Usage

  • go to project folder with tests
  • run autotest

Options

-f, --fast-start                 Do not run full tests at start
-p, --parallel                   Run tests (Test::Unit only) in parallel -- gem install parallel_tests
-c, --no-full-after-failed       Do not run full tests after failed test passed
-v, --verbose                    Be verbose. Prints files that autotest doesn't know how to map to tests
-q, --quiet                      Be quiet.
-r, --rc CONFIG                  Path to config file. (Defaults to ~/.autotest or current_dir/.autotest)
-s, --style STYLE                Which style to use, e.g. rspec, rspec2
-b, --bundle-exec                Use bundle exec to run tests
-d, --delay SECONDS              Delay time from file change to test run
-n, --notify                     Notify about success and failure via popups
-h, --help                       Show this.

Windows needs diff.exe

TIPS

  • [RSpec] if you want to use require 'spec_helper' -> rspec --configure autotest

TODO

  • add documentation for hooks
  • remove globals from unitdiff
  • add some automatic notifications e.g. autotest -n -> use any notify library found
  • use watchr

License

Autotest was extracted from ZenTest and improved by:

ZenTest Authors

(The MIT License)

Copyright (c) 2001-2006 Ryan Davis, Eric Hodel, Zen Spider Software

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

autotest's People

Contributors

arailsdemo avatar bpo avatar drbrain avatar faisal avatar fnando avatar fonsan avatar grosser avatar jamesbebbington avatar sampierson avatar shanel avatar zenspider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

autotest's Issues

Autotest fails if test/ and spec/ folders are simultaneously in rails3 project

If I have spec/ (with real specs) and test/ (with scaffold tests) in rails project tree I got an error:

�[f/usr/lib/ruby/gems/svn/gems/rspec-rails-2.0.0.beta.8/lib/autotest/rails_rspec2.rb:36:in block (2 levels) in <top (required)>': undefined methodsingularize' for "companies":String (NoMethodError)
from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:529:in call' from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:529:intest_files_for'
from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:401:in block in find_files_to_test' from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:401:ineach'
from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:401:in map' from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:401:infind_files_to_test'
from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:256:in run_tests' from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:245:inget_to_green'
from /usr/lib/ruby/gems/svn/gems/cucumber-0.7.2/lib/autotest/cucumber_mixin.rb:54:in get_to_green' from /usr/lib/ruby/gems/svn/gems/cucumber-0.7.2/lib/autotest/cucumber_mixin.rb:28:inblock in run'
from /usr/lib/ruby/gems/svn/gems/cucumber-0.7.2/lib/autotest/cucumber_mixin.rb:26:in loop' from /usr/lib/ruby/gems/svn/gems/cucumber-0.7.2/lib/autotest/cucumber_mixin.rb:26:inrun'
from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/lib/autotest.rb:135:in run' from /usr/lib/ruby/gems/svn/gems/autotest-4.2.10/bin/autotest:54:in<top (required)>'
from /usr/bin/autotest:19:in load' from /usr/bin/autotest:19:in'

But if I move test/ to test2/ all is ok.

My system settings:
Arch Linux x86_64
ruby 1.9.3dev (2010-05-08 trunk 27674) x86_64-linux
Rails 3.0.0.beta.3

# gem-svn list | grep rspec
rspec (2.0.0.beta.8)
rspec-core (2.0.0.beta.8)
rspec-expectations (2.0.0.beta.8)
rspec-mocks (2.0.0.beta.8)
rspec-rails (2.0.0.beta.8)

gem-svn list | grep autotest

autotest (4.2.10)
autotest-growl (0.2.4)
autotest-rails-pure (4.1.0)

Gemfile:


source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'devise', '1.1.rc1'
gem 'mysql'
group :test do
gem 'database_cleaner'
gem 'rspec-rails', '>=2.0.0.beta.8'
gem 'rspec', '>=2.0.0.beta.8'

gem 'test-unit'

gem 'cucumber', '0.7.2'
gem 'cucumber-rails', '0.3.1'#, :git => 'git://github.com/aslakhellesoy/cucumber-rails.git'
gem 'capybara'

gem 'autotest'

gem 'autotest-rails-pure'
gem 'autotest-growl'
gem 'machinist'
end

Autotest / spork ?

Is it possible to run autotest with spork ? I'm using test:unit not rspec, and have both spork and autotest running independently.

No tests matched ...(every test)...

Hello,
Attempting to add autotest to a Rails 3.2, Ruby 1.9.3, Postgres project on Mac OS X 10.8.5. We use Test::Unit and parallel_tests.

When I run autotest nothing appears. Running autotest -v shows "No tests matched" for, basically, every file under our \test directory (recursively).

Contents of .autotest

require 'autotest/fsevent'

Contents of /autotest/discover.rb

Autotest.add_discovery { "rails" }

Not sure what is going on... Perhaps it is thinking we are using rspec? Is there a way to force it to use test:unit? Naturally, changing a model in our projects does nothing - Autotest just sits there.

Installation was via sudo gem install autotest-standalone and then sudo gem install autotest-rails-pure

Any help would be appreciated!

Autotest and bundler don't get along

When I try to run autotest under Rails 3.0.0.beta3/Rspec 2.0.0.beta8, I get:

$ autotest
(Not running features.  To run features in autotest, set AUTOFEATURE=true.)
loading autotest/rails_rspec2
Error loading Autotest style autotest/rails_rspec2 (no such file to load -- autotest/rails_rspec2). Aborting.

My rspec-rails gem is bundled (in ~/.bundle) rather than installed through rubygems. As a result, autotest doesn't find 'autotest/rails_rspec2' in its load path.

I am debating two solutions:

  1. Install rspec2.0.0.beta8 and related gems on my system
  2. Patch autotest to use Bundler when a Gemfile exists (c.f. config/boot.rb in Rails 3)

For now I'm using the first approach, despite not wanting to cloud my system with prerelease gems. I think the second approach is cleaner but I haven't been able to get it to work yet. It appears that calling Bundler.setup blows away the rubygems load path, causing other issues.

Hopefully this saves someone else some time. I had followed the instructions in gist.github.com/365816 and was still having problems since the gems were in ~/.bundle and not in my rubygems install dir.

autotest couldn't see the rspec2

I can't force autotest to use rspec2 tests instead of test/unit.

# autotest
loading autotest/cucumber_rails
style: CucumberRails
�[f/usr/bin/ruby-svn -I.:lib:test -rubygems -e "['test/unit', 'test/unit/helpers/companies_helper_test.rb', 'test/unit/user_test.rb', 'test/unit/company_test.rb', 'test/functional/companies_controller_test.rb'].each { |f| require f }" | /usr/lib/ruby/gems/svn/gems/autotest-4.2.9/bin/unit_diff -u

But rspec spec/ works fine. And autotest/discover.rb have rspec2 line:

# cat autotest/discover.rb
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }

Arch Linux x86_64
ruby 1.9.3dev (2010-05-08 trunk 27674) x86_64-linux
Rails 3.0.0.beta.3

# gem-svn list | grep rspec
rspec (2.0.0.beta.8)
rspec-core (2.0.0.beta.8)
rspec-expectations (2.0.0.beta.8)
rspec-mocks (2.0.0.beta.8)
rspec-rails (2.0.0.beta.8)

gem-svn list | grep autotest

autotest (4.2.9)
autotest-growl (0.2.4)
autotest-rails-pure (4.1.0)

Gemfile:


source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'devise', '1.1.rc1'
gem 'mysql'
group :test do
gem 'database_cleaner'
gem 'rspec-rails', '>=2.0.0.beta.8'
gem 'rspec', '>=2.0.0.beta.8'

gem 'test-unit'

gem 'cucumber', '0.7.2'
gem 'cucumber-rails', '0.3.1'#, :git => 'git://github.com/aslakhellesoy/cucumber-rails.git'
gem 'capybara'

gem 'autotest'

gem 'autotest-rails-pure'
gem 'autotest-growl'
gem 'machinist'
end


cat /home/petrushka/.autotest

require 'autotest/growl'

cat .autotest

Autotest.add_hook :initialize do |at|
at.add_exception 'tmp'
at.add_exception 'rerun.txt'
at.add_exception 'vendor'
at.add_exception '.git'
end

Does not run model tests!

With autotest

C:\ruby200\bin\ruby -I.;lib;test -rubygems -e "['test/unit', 'test/controllers/admin_controller_test.rb', 'test/controllers/votes_controller_test.rb', 'test/integration/integration_helper.rb', 'test/helpers/posts_helper_test.rb', 'test/integration/comment_integration_test.rb', 'test/controllers/index_controller_test.rb', 'test/controllers/users_controller_test.rb', 'test/controllers/bitcoin_gateway_test.rb', 'test/helpers/comments_helper_test.rb', 'test/helpers/admin_helper_test.rb', 'test/controllers/comments_controller_test.rb', 'test/helpers/votes_helper_test.rb', 'test/integration/user_flows_test.rb', 'test/controllers/tags_controller_test.rb', 'test/helpers/user_helper_test.rb', 'test/helpers/tags_helper_test.rb', 'test/helpers/index_helper_test.rb', 'test/integration/post_integration_test.rb', 'test/controllers/posts_controller_test.rb'].each { |f| require f }" | ruby C:/ruby200/lib/ruby/gems/2.0.0/gems/autotest-standalone-4.5.11/bin/unit_diff -u
62 tests, 187 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]

With rake test

Finished tests in 26.777545s, 2.6515 tests/s, 7.4689 assertions/s.
71 tests, 200 assertions, 0 failures, 0 errors, 0 skips

All the tests under test/models/ are missing!

*** LOCAL GEMS ***
autotest-rails-pure (4.1.2)
autotest-standalone (4.5.11)

Autotest doesn't work with the new way to require spec_helper in RSpec specs

Since Rspec 1.2.9 it's possible to require the spec_helper.rb file with just "require 'spec_helper" instead of "require File.dirname(FILE) + '/spec_helper'" (see https://rspec.lighthouseapp.com/projects/5645/tickets/733-figure-out-some-what-to-just-require-spec_helper).

But if you do this autotest doesn't work (The specs fail with "no such file to load -- spec_helper (MissingSourceFile").

It can be fixed by adding "spec" to the -I parameter of the ruby command that autotest calls.

Autotest doesn't run any tests

First, thanks so much for working on this project for everybody! But I can't get it to work for some reason.

running either
$autotest
or
$autotest -f
gets the same result:

Waiting since ...

$ rspec /spec works ok. This is on Ubuntu 9.04, Ruby 1.9.2, Rails 3, autotest 4.3.2, autotest-rails 4.1.0, and rspec 2.0.0.beta.20.

If I run $autotest -v, it finds my one controller spec file (or at least doesn't say that no tests match it), gives me the "# Waiting..." line, and then if I change anything in the controller or the spec, I get a hash of {[changed file] => [timestamp]}, displayed twice.

History.txt not updated.

Just updated from 4.5.6 to 4.5.8, but how do I find out what the changes are ? History.txt seems out of date.

Start parallel_test from curent directory

Hi
"autotest -p" tries to start parallel_test like this
parallel_test 'test/unit/user_test.rb'
But it cannot find the test files this way. Instead it should do something like this, starting rom the current directory:
parallel_test './test/unit/user_test.rb'

This is on Ruby 1.9.2

rails3 ruby1.9.2-p0 errors

when i use rails3+ruby1.9.2 and autotest ,i got erros as:
internal:lib/rubygems/custom_require:29: warning: loading in progress, circular require considered harmful

but when i use rails3.0RC and ruby1.9.2-rc2, it works well??

Doesn't work in Windows...

I have a rails3 project with Rspec 2, my ruby version is 1.9.2. I have only windows 7 x64 at work, and I can't run autotest.

My console log:

C:\Ruby192\web\app>autotest
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ZenTest-4.5.0/lib/autotest.rb:226.
NOTE: Gem::SourceIndex#gems is deprecated with no replacement. It will be removed on or after 2011-1
1-01.
Gem::SourceIndex#gems called from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ZenTest-4.5.0/lib/autotest.rb:
226.
loading autotest/rails_rspec2
C:\Ruby192\bin\ruby -rrubygems -S C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.0/bin/rspec --t
ty 'C:/Ruby192/web/app/spec/news_controller_spec.rb'
C:\Ruby192\bin\ruby: No such file or directory -- C:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.0/bin/rspec (LoadError)

I have checked ..gems/rspec-core-2.7.0/bin/ - this folder doesn't exists in windows. There is only 'exe' folder. How can I fix it?

Autotest delays a little bit with fsevent

Guard executes from filesave to running the test pretty quick. Autotest initialize sets sleep=1 by default. Why is this? I looked at Activity Monitor while setting sleep to 0 and didn't see much impact. With polling, cpu is very obvious 10-20% on a core.

In my .autotest file:

# tighten up the time before the test is run
ObjectSpace.each_object(Autotest).first.sleep = 0

Which makes it run a bit like Guard. Is this terrible? I don't know what can be done. It's not a singleton, maybe Autotest should be? Maybe nothing needs to be changed but just documenting the workaround.

*** LOCAL GEMS ***
autotest-fsevent (0.2.8)
autotest-rails-pure (4.1.2)
autotest-standalone (4.5.9)

Tests get run twice

When tests passes right after failing, tests get run twice. Any idea why?

autotest 4.4.6
rails 3.0.0
rspec 2.5.0
Ubuntu 10.04

autotest-rails-pure should require autotest

There is no issue tracking on autotest-rails-pure so I'm reporting this here... I noticed that autotest-rails-pure does not list autotest as a dependency. I don't see a reason you'd install this gem and not want autotest. It would also simplify the Rails Gemfile slightly when using autotest-rails-pure.

Specifying the -n option on mac 10.6.6

fonsan$ autotest -f -n
loading autotest/rails
Enter a notification description, followed by newline, followed by Ctrl-D (End of File). To cancel, press Ctrl-C.

fonsan$ growlnotify --help
Usage: growlnotify [-hsvuwc] [-i ext] [-I filepath] [--image filepath]
[-a appname] [-p priority] [-H host] [-P password]
[--port port] [-n name] [-A method] [--progress value]
[--html] [-m message] [-t] [title]
Options:
-h,--help Display this help
-v,--version Display version number
-n,--name Set the name of the application that sends the notification
[Default: growlnotify]
-s,--sticky Make the notification sticky
-a,--appIcon Specify an application name to take the icon from
-i,--icon Specify a file type or extension to look up for the
notification icon
-I,--iconpath Specify a file whose icon will be the notification icon
--image Specify an image file to be used for the notification icon
-m,--message Sets the message to be used instead of using stdin
Passing - as the argument means read from stdin
-p,--priority Specify an int or named key (default is 0)
-d,--identifier Specify a notification identifier (used for coalescing)
-H,--host Specify a hostname to which to send a remote notification.
-P,--password Password used for remote notifications.
-u,--udp Use UDP instead of DO to send a remote notification.
--port Port number for UDP notifications.
-A,--auth Specify digest algorithm for UDP authentication.
Either MD5 [Default], SHA256 or NONE.
-c,--crypt Encrypt UDP notifications.
-w,--wait Wait until the notification has been dismissed.
--progress Set a progress value for this notification.

Display a notification using the title given on the command-line and the
message given in the standard input.

Priority can be one of the following named keys: Very Low, Moderate, Normal,
High, Emergency. It can also be an int between -2 and 2.

To be compatible with gNotify the following switch is accepted:
-t,--title Does nothing. Any text following will be treated as the
title because that's the default argument behaviour

therefore it should be a simple fix for now to change the -t option to a -m

Autotest doesn't respond to Ctrl-C

Ubuntu 11.04 beta and 10.10 (these are the two machines I've reproduced this on).

Autotest has stopped responding to Ctrl-C on these machines. I've tried autotest 4.4.6 and autotest-standaline 4.5.5. If I type Ctrl-C, then Ctrl-Z to background autotest, then fg to bring it back, it will see the Ctrl-C I have typed. Also, if I use strace to connect to a "hung" autotest process, I see a constant string of "sched_yield() =0" calls. What's kinda weird is that once strace is running, I can go to the terminal running autotest, and Ctrl-C works.

Tests run fine... I just can't kill autotest or force a retest with Ctrl-C.

Encoding UTF-8 Error

Using rvm, I received this error:
~/.rvm/gems/ruby-1.9.2-p0@bvo/gems/ZenTest-4.4.2/lib/unit_diff.rb:74:in `===': invalid byte sequence in US-ASCII (ArgumentError)

All my files have the encoding utf-8 in top.
note: using the command $ rake test my tests passes

Working with Rails setup unclear

It appears autotest doesn't work with rails out of the box. Instead I have to install autotest-rails. However, that has a dependency on ZenTest (which kinda defeats the point of using autotest instead). Since I don't want ZenTest, I try to uninstall it & of course get the dependency warning: autotest-rails-4.1.0 depends on [ZenTest (>= 0)]. If I go ahead with uninstalling ZenTest & then try to run autotest I get

loading autotest/rails
Autotest style autotest/rails doesn't seem to exist. Aborting.

My only way to have a working setup was clear all autotest/ZenTest gems. Install autotest-rails (which also installs ZenTest). Then install autotest, then autotest-growl, autotest-fsevent. While this seems to work, I still had to install ZenTest & leave it installed. Is there an easier way that can be more reliably applied to other machines?

Autotest doesn't works if config.generators and rspec:install

I tried to follow the guidelines of issue no. 6 to get autotest with rspec 2 , rails 3 and ruby 1.9 working, but found out the following issue:

If rails's test_framework is set to rspec, and if you run rails g rspec:install, then autospec won't work. It gives no erros message ( even with -v ), it just exits withouth a word.

Here's the minimal procedure for reproduction:

$rails auto_test

$vim Gemfile

source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'sqlite3'
group :test do
  gem 'rspec-rails', '>=2.0.0.beta.8'
  gem 'rspec', '>=2.0.0.beta.8'
  gem 'autotest-rails-pure'
  gem 'autotest-growl'
end

$vim config/application.rb

require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require :default, Rails.env
module AutoTest
  class Application < Rails::Application
    config.generators do |g|
      g.test_framework  :rspec, :fixture => true
    end
    config.filter_parameters << :password
  end
end

$rails g rspec:install

$rails g model User

$autotest

To make it work, you could remove spec folder, comment g.test_framework on config/application, and run rails g rspec:install again.

This was tested with ruby 1.9.1p376, on a Ubuntu 10.04.

This may be an issue with rspec, but since its repercussion seems to be only on autotest, i thought to open the issue here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.