Added a watch subcommand. Watching a project can now by done with: compass watch

This commit is contained in:
Chris Eppstein 2009-10-25 00:45:34 -07:00
parent 58cc6c0aab
commit 3e99fedab0
4 changed files with 77 additions and 1 deletions

View File

@ -144,3 +144,13 @@ Feature: Command Line
And a sass file sass/print.sass is reported unchanged
And a sass file sass/reset.sass is reported unchanged
And a sass file sass/utilities.sass is reported unchanged
Scenario: Watching a project for changes
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass compile
And I run in a separate process: compass watch
And I wait 1 second
And I touch sass/layout.sass
And I wait 2 seconds
And I shutdown the other process
And a css file tmp/layout.css is reported identical

35
features/env.rb Normal file
View File

@ -0,0 +1,35 @@
require 'cucumber/ast/step_invocation'
module Cucumber
module Ast
class StepInvocation #:nodoc:
def invoke(step_mother, options)
find_step_match!(step_mother)
unless @skip_invoke || options[:dry_run] || @exception || @step_collection.exception
@skip_invoke = true
begin
@step_match.invoke(@multiline_arg)
step_mother.after_step
status!(:passed)
rescue Pending => e
failed(options, e, false)
status!(:pending)
rescue Undefined => e
failed(options, e, false)
status!(:undefined)
rescue Cucumber::Ast::Table::Different => e
@different_table = e.table
failed(options, e, false)
status!(:failed)
rescue SystemExit => e
raise
rescue Exception => e
failed(options, e, false)
status!(:failed)
end
end
end
end
end
end

View File

@ -42,6 +42,35 @@ When /^I run: compass ([^\s]+) ?(.+)?$/ do |command, args|
compass command, *(args || '').split
end
When /^I run in a separate process: compass ([^\s]+) ?(.+)?$/ do |command, args|
unless @other_process = fork
@last_result = ''
@last_error = ''
Signal.trap("HUP") do
open('/tmp/last_result.compass_test.txt', 'w') do |file|
file.puts $stdout.string
end
open('/tmp/last_error.compass_test.txt', 'w') do |file|
file.puts @stderr.string
end
exit # This doesn't exit
end
# this command will run forever
# we kill it with a HUP signal from the parent process.
args = (args || '').split
args << { :wait => 5 }
compass command, *args
exit
end
end
When /^I shutdown the other process$/ do
Process.kill("HUP", @other_process)
Process.wait
@last_result = File.read('/tmp/last_result.compass_test.txt')
@last_error = File.read('/tmp/last_error.compass_test.txt')
end
When /^I touch ([^\s]+)$/ do |filename|
FileUtils.touch filename
end

View File

@ -7,6 +7,8 @@ module Compass
module Commands
class WatchProject < UpdateProject
register :watch
attr_accessor :last_update_time, :last_sass_files
def perform