Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ node_modules
autodeploy.properties
.ws_migrations_complete
.vagrant/
logs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already a ../log directory, maybe we don't need this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jenkins doesn't have that directory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And ruby doesn't know about the python variables that define the log directory.

15 changes: 11 additions & 4 deletions rakelib/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ def when_changed(unchanged_message, files, dirs=[])

# Runs Process.spawn, and kills the process at the end of the rake process
# Expects the same arguments as Process.spawn
def background_process(*command)
pid = Process.spawn({}, *command, {:pgroup => true})
def background_process(command, logfile=nil)
spawn_opts = {:pgroup => true}
if !logfile.nil?
puts "Running '#{command.join(' ')}', redirecting output to #{logfile}".red
spawn_opts[[:err, :out]] = [logfile, 'a']
end
pid = Process.spawn({}, *command, spawn_opts)
command = [*command]

at_exit do
puts "Ending process and children"
Expand Down Expand Up @@ -88,9 +94,10 @@ def background_process(*command)

# Runs a command as a background process, as long as no other processes
# tagged with the same tag are running
def singleton_process(*command)
def singleton_process(command, logfile=nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't assets.rake call this function, so doesn't that file need to adapt to the star/no-star change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assets.rake just uses single string commands already anyway, so there's no change in that file.

command = [*command]
if Sys::ProcTable.ps.select {|proc| proc.cmdline.include?(command.join(' '))}.empty?
background_process(*command)
background_process(command, logfile)
else
puts "Process '#{command.join(' ')} already running, skipping".blue
end
Expand Down
13 changes: 9 additions & 4 deletions rakelib/jasmine.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ PREFERRED_METHOD = PHANTOMJS_PATH.nil? ? 'browser' : 'phantomjs'
if PHANTOMJS_PATH.nil?
puts("phantomjs not found on path. Set $PHANTOMJS_PATH. Using browser for jasmine tests".blue)
end
LOGDIR = 'logs/jasmine'

CLOBBER.include(LOGDIR)

directory LOGDIR

def django_for_jasmine(system, django_reload)
if !django_reload
Expand All @@ -17,7 +22,7 @@ def django_for_jasmine(system, django_reload)
port = 10000 + rand(40000)
jasmine_url = "http://localhost:#{port}/_jasmine/"

background_process(*django_admin(system, 'jasmine', 'runserver', '-v', '0', port.to_s, reload_arg).split(' '))
background_process(django_admin(system, 'jasmine', 'runserver', '-v', '0', port.to_s, reload_arg).split(' '), "#{LOGDIR}/django.log")

up = false
start_time = Time.now
Expand Down Expand Up @@ -80,15 +85,15 @@ end
namespace :jasmine do
namespace system do
desc "Open jasmine tests for #{system} in your default browser"
task :browser => [:clean_reports_dir] do
task :browser => [:clean_reports_dir, LOGDIR] do
Rake::Task[:assets].invoke(system, 'jasmine')
django_for_jasmine(system, true) do |jasmine_url|
jasmine_browser(jasmine_url)
end
end

desc "Open jasmine tests for #{system} in your default browser, and dynamically recompile coffeescript"
task :'browser:watch' => [:clean_reports_dir, :'assets:coffee:_watch'] do
task :'browser:watch' => [:clean_reports_dir, :'assets:coffee:_watch', LOGDIR] do
django_for_jasmine(system, true) do |jasmine_url|
jasmine_browser(jasmine_url, jitter=0, wait=0)
end
Expand All @@ -97,7 +102,7 @@ end
end

desc "Use phantomjs to run jasmine tests for #{system} from the console"
task :phantomjs => [:clean_reports_dir] do
task :phantomjs => [:clean_reports_dir, LOGDIR] do
Rake::Task[:assets].invoke(system, 'jasmine')
phantomjs = ENV['PHANTOMJS_PATH'] || 'phantomjs'
django_for_jasmine(system, false) do |jasmine_url|
Expand Down