Hello community, here is the log from the commit of package rubygem-spring for openSUSE:Factory checked in at 2016-04-28 16:53:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-spring (Old) and /work/SRC/openSUSE:Factory/.rubygem-spring.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-spring" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-spring/rubygem-spring.changes 2015-12-14 10:14:03.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-spring.new/rubygem-spring.changes 2016-04-28 16:56:44.000000000 +0200 @@ -1,0 +2,36 @@ +Tue Apr 12 04:32:48 UTC 2016 - coolo@suse.com + +- updated to version 1.7.1 + no changelog found + +------------------------------------------------------------------- +Mon Apr 11 04:36:47 UTC 2016 - coolo@suse.com + +- updated to version 1.7.0 + no changelog found + +------------------------------------------------------------------- +Sat Feb 27 05:54:01 UTC 2016 - coolo@suse.com + +- updated to version 1.6.4 + no changelog found + +------------------------------------------------------------------- +Fri Feb 5 05:44:28 UTC 2016 - coolo@suse.com + +- updated to version 1.6.3 + no changelog found + +------------------------------------------------------------------- +Thu Jan 21 05:49:49 UTC 2016 - coolo@suse.com + +- updated to version 1.6.2 + no changelog found + +------------------------------------------------------------------- +Tue Dec 15 05:33:53 UTC 2015 - coolo@suse.com + +- updated to version 1.6.0 + no changelog found + +------------------------------------------------------------------- Old: ---- spring-1.5.0.gem New: ---- spring-1.7.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-spring.spec ++++++ --- /var/tmp/diff_new_pack.DwdTmk/_old 2016-04-28 16:56:45.000000000 +0200 +++ /var/tmp/diff_new_pack.DwdTmk/_new 2016-04-28 16:56:45.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-spring # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-spring -Version: 1.5.0 +Version: 1.7.1 Release: 0 %define mod_name spring %define mod_full_name %{mod_name}-%{version} ++++++ spring-1.5.0.gem -> spring-1.7.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/LICENSE.txt new/LICENSE.txt --- old/LICENSE.txt 2015-11-30 17:32:44.000000000 +0100 +++ new/LICENSE.txt 2016-04-11 15:53:04.000000000 +0200 @@ -1,4 +1,4 @@ -Copyright (c) 2012 Jon Leighton +Copyright (c) 2012-2016 Jon Leighton MIT License @@ -19,4 +19,4 @@ 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. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2015-11-30 17:32:44.000000000 +0100 +++ new/README.md 2016-04-11 15:53:04.000000000 +0200 @@ -16,7 +16,7 @@ ## Compatibility -* Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1 +* Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2 * Rails versions: 4.0+ (in Rails 4.1 and up Spring is included by default) Spring makes extensive use of `Process.fork`, so won't be able to @@ -73,6 +73,7 @@ ``` $ time bin/rake test test/controllers/posts_controller_test.rb +Running via Spring preloader in process 2734 Run options: # Running tests: @@ -103,6 +104,7 @@ ``` $ time bin/rake test test/controllers/posts_controller_test.rb +Running via Spring preloader in process 8352 Run options: # Running tests: @@ -147,6 +149,7 @@ ``` $ bin/rake routes +Running via Spring preloader in process 2363 posts GET /posts(.:format) posts#index POST /posts(.:format) posts#create new_post GET /posts/new(.:format) posts#new @@ -287,6 +290,13 @@ So to avoid this problem, don't save off references to application constants in your initialization code. +## Using Spring with a containerized development environment + +As of Spring 1.7, there is some support for doing this. See [this +example +repository](https://github.com/jonleighton/spring-docker-example) for +information about how to do it with [Docker](https://www.docker.com/). + ## Configuration Spring will read `~/.spring.rb` and `config/spring.rb` for custom @@ -353,13 +363,51 @@ [spring-watcher-listen](https://github.com/jonleighton/spring-watcher-listen) gem. +### Quiet output + +To disable the "Running via Spring preloader" message which is shown each time +a command runs: + +``` ruby +Spring.quiet = true +``` + +### Environment variables + +The following environment variables are used by Spring: + +* `DISABLE_SPRING` - If set, Spring will be bypassed and your + application will boot in a foreground process +* `SPRING_LOG` - The path to a file which Spring will write log messages + to. +* `SPRING_TMP_PATH` - The directory where Spring should write its temporary + files (a pidfile and a socket). By default we use the + `XDG_RUNTIME_DIR` environment variable, or else `Dir.tmpdir`, and then + create a directory in that named `spring-$UID`. We don't use your + Rails application's `tmp/` directory because that may be on a + filesystem which doesn't support UNIX sockets. +* `SPRING_APPLICATION_ID` - Used to identify distinct Rails + applications. By default it is an MD5 hash of the current + `RUBY_VERSION`, and the path to your Rails project root. +* `SPRING_SOCKET` - The path which should be used for the UNIX socket + which Spring uses to communicate with the long-running Spring server + process. By default this is `SPRING_TMP_PATH/SPRING_APPLICATION_ID`. +* `SPRING_PIDFILE` - The path which should be used to store the pid of + the long-running Spring server process. By default this is related to + the socket path; if the socket path is `/foo/bar/spring.sock` the + pidfile will be `/foo/bar/spring.pid`. +* `SPRING_SERVER_COMMAND` - The command to run to start up the spring + server when it is not already running. Defaults to `spring _[version]_ + server --background`. + ## Troubleshooting If you want to get more information about what spring is doing, you can -specify a log file with the `SPRING_LOG` environment variable: +run spring explicitly in a separate terminal: ``` -spring stop # if spring is already running -export SPRING_LOG=/tmp/spring.log -spring rake -T +$ spring server ``` + +Logging output will be printed to stdout. You can also send log output +to a file with the `SPRING_LOG` environment variable. Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/application/boot.rb new/lib/spring/application/boot.rb --- old/lib/spring/application/boot.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/application/boot.rb 2016-04-11 15:53:04.000000000 +0200 @@ -5,7 +5,8 @@ app = Spring::Application.new( UNIXSocket.for_fd(3), - Spring::JSON.load(ENV.delete("SPRING_ORIGINAL_ENV").dup) + Spring::JSON.load(ENV.delete("SPRING_ORIGINAL_ENV").dup), + Spring::Env.new(log_file: IO.for_fd(4)) ) Signal.trap("TERM") { app.terminate } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/application.rb new/lib/spring/application.rb --- old/lib/spring/application.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/application.rb 2016-04-11 15:53:04.000000000 +0200 @@ -6,10 +6,10 @@ class Application attr_reader :manager, :watcher, :spring_env, :original_env - def initialize(manager, original_env) + def initialize(manager, original_env, spring_env = Env.new) @manager = manager @original_env = original_env - @spring_env = Env.new + @spring_env = spring_env @mutex = Mutex.new @waiting = Set.new @preloaded = false @@ -99,7 +99,7 @@ @preloaded = :success rescue Exception => e @preloaded = :failure - watcher.add e.backtrace.map { |line| line.match(/^(.*)\:\d+\:in /)[1] } + watcher.add e.backtrace.map { |line| line[/^(.*)\:\d+/, 1] } raise e unless initialized? ensure watcher.add loaded_application_features @@ -149,14 +149,22 @@ setup command if Rails.application.reloaders.any?(&:updated?) - ActionDispatch::Reloader.cleanup! - ActionDispatch::Reloader.prepare! + # Rails 5.1 forward-compat. AD::R is deprecated to AS::R in Rails 5. + if defined? ActiveSupport::Reloader + Rails.application.reloader.reload! + else + ActionDispatch::Reloader.cleanup! + ActionDispatch::Reloader.prepare! + end end pid = fork { + Process.setsid IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") } trap("TERM", "DEFAULT") + STDERR.puts "Running via Spring preloader in process #{Process.pid}" unless Spring.quiet + ARGV.replace(args) $0 = command.exec_name @@ -311,6 +319,17 @@ exit_if_finished end } + + Thread.new { + while signal = client.gets.chomp + begin + Process.kill(signal, -Process.getpgid(pid)) + client.puts(0) + rescue Errno::ESRCH + client.puts(1) + end + end + } end private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/application_manager.rb new/lib/spring/application_manager.rb --- old/lib/spring/application_manager.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/application_manager.rb 2016-04-11 15:53:04.000000000 +0200 @@ -2,9 +2,9 @@ class ApplicationManager attr_reader :pid, :child, :app_env, :spring_env, :status - def initialize(app_env) + def initialize(app_env, spring_env) @app_env = app_env - @spring_env = Env.new + @spring_env = spring_env @mutex = Mutex.new @state = :running end @@ -101,9 +101,11 @@ "SPRING_PRELOAD" => preload ? "1" : "0" }, "ruby", + "-I", File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first), "-I", File.expand_path("../..", __FILE__), "-e", "require 'spring/application/boot'", - 3 => child_socket + 3 => child_socket, + 4 => spring_env.log_file, ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/client/binstub.rb new/lib/spring/client/binstub.rb --- old/lib/spring/client/binstub.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/client/binstub.rb 2016-04-11 15:53:04.000000000 +0200 @@ -38,7 +38,7 @@ require 'bundler' if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) - Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq } + Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } gem 'spring', match[1] require 'spring/binstub' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/client/run.rb new/lib/spring/client/run.rb --- old/lib/spring/client/run.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/client/run.rb 2016-04-11 15:53:04.000000000 +0200 @@ -6,31 +6,36 @@ module Client class Run < Command FORWARDED_SIGNALS = %w(INT QUIT USR1 USR2 INFO WINCH) & Signal.list.keys - TIMEOUT = 1 + CONNECT_TIMEOUT = 1 + BOOT_TIMEOUT = 10 + + attr_reader :server def initialize(args) super - @signal_queue = [] + + @signal_queue = [] + @server_booted = false end def log(message) env.log "[client] #{message}" end - def server - @server ||= UNIXSocket.open(env.socket_name) + def connect + @server = UNIXSocket.open(env.socket_name) end def call - if env.server_running? - warm_run - else + begin + connect + rescue Errno::ENOENT, Errno::ECONNRESET, Errno::ECONNREFUSED cold_run + else + warm_run end - rescue Errno::ECONNRESET - exit 1 ensure - server.close if @server + server.close if server end def warm_run @@ -49,6 +54,7 @@ def cold_run boot_server + connect run end @@ -60,24 +66,37 @@ queue_signals connect_to_application(client) run_command(client, application) + rescue Errno::ECONNRESET + exit 1 end def boot_server env.socket_path.unlink if env.socket_path.exist? - pid = Process.spawn( - gem_env, - "ruby", - "-e", "gem 'spring', '#{Spring::VERSION}'; require 'spring/server'; Spring::Server.boot" - ) + pid = Process.spawn(gem_env, env.server_command, out: File::NULL) + timeout = Time.now + BOOT_TIMEOUT + + @server_booted = true until env.socket_path.exist? _, status = Process.waitpid2(pid, Process::WNOHANG) - exit status.exitstatus if status + + if status + exit status.exitstatus + elsif Time.now > timeout + $stderr.puts "Starting Spring server with `#{env.server_command}` " \ + "timed out after #{BOOT_TIMEOUT} seconds" + exit 1 + end + sleep 0.1 end end + def server_booted? + @server_booted + end + def gem_env bundle = Bundler.bundle_path.to_s paths = Gem.path + ENV["GEM_PATH"].to_s.split(File::PATH_SEPARATOR) @@ -97,13 +116,17 @@ def verify_server_version server_version = server.gets.chomp if server_version != env.version - $stderr.puts <<-ERROR -There is a version mismatch between the spring client and the server. -You should restart the server and make sure to use the same version. + $stderr.puts "There is a version mismatch between the spring client " \ + "(#{env.version}) and the server (#{server_version})." -CLIENT: #{env.version}, SERVER: #{server_version} -ERROR - exit 1 + if server_booted? + $stderr.puts "We already tried to reboot the server, but the mismatch is still present." + exit 1 + else + $stderr.puts "Restarting to resolve." + stop_server + cold_run + end end end @@ -111,7 +134,7 @@ server.send_io client send_json server, "args" => args, "default_rails_env" => default_rails_env - if IO.select([server], [], [], TIMEOUT) + if IO.select([server], [], [], CONNECT_TIMEOUT) server.gets or raise CommandNotFound else raise "Error connecting to Spring server" @@ -138,7 +161,7 @@ if pid && !pid.empty? log "got pid: #{pid}" - forward_signals(pid.to_i) + forward_signals(application) status = application.read.to_i log "got exit status #{status}" @@ -158,26 +181,26 @@ end end - def forward_signals(pid) - @signal_queue.each { |sig| kill sig, pid } + def forward_signals(application) + @signal_queue.each { |sig| kill sig, application } FORWARDED_SIGNALS.each do |sig| - trap(sig) { forward_signal sig, pid } + trap(sig) { forward_signal sig, application } end - rescue Errno::ESRCH end - def forward_signal(sig, pid) - kill(sig, pid) - rescue Errno::ESRCH - # If the application process is gone, then don't block the - # signal on this process. - trap(sig, 'DEFAULT') - Process.kill(sig, Process.pid) + def forward_signal(sig, application) + if kill(sig, application) != 0 + # If the application process is gone, then don't block the + # signal on this process. + trap(sig, 'DEFAULT') + Process.kill(sig, Process.pid) + end end - def kill(sig, pid) - Process.kill(sig, -Process.getpgid(pid)) + def kill(sig, application) + application.puts(sig) + application.gets.to_i end def send_json(socket, data) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/client/server.rb new/lib/spring/client/server.rb --- old/lib/spring/client/server.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/spring/client/server.rb 2016-04-11 15:53:04.000000000 +0200 @@ -0,0 +1,18 @@ +module Spring + module Client + class Server < Command + def self.description + "Explicitly start a Spring server in the foreground" + end + + def call + require "spring/server" + Spring::Server.boot(foreground: foreground?) + end + + def foreground? + !args.include?("--background") + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/client.rb new/lib/spring/client.rb --- old/lib/spring/client.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/client.rb 2016-04-11 15:53:04.000000000 +0200 @@ -9,6 +9,7 @@ require "spring/client/status" require "spring/client/rails" require "spring/client/version" +require "spring/client/server" module Spring module Client @@ -22,6 +23,7 @@ "rails" => Client::Rails, "-v" => Client::Version, "--version" => Client::Version, + "server" => Client::Server, } def self.run(args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/configuration.rb new/lib/spring/configuration.rb --- old/lib/spring/configuration.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/configuration.rb 2016-04-11 15:53:04.000000000 +0200 @@ -2,7 +2,7 @@ module Spring class << self - attr_accessor :application_root + attr_accessor :application_root, :quiet def gemfile ENV['BUNDLE_GEMFILE'] || "Gemfile" @@ -49,4 +49,6 @@ end end end + + self.quiet = false end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/env.rb new/lib/spring/env.rb --- old/lib/spring/env.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/env.rb 2016-04-11 15:53:04.000000000 +0200 @@ -14,10 +14,10 @@ class Env attr_reader :log_file - def initialize(root = nil) - @root = root - @project_root = root - @log_file = File.open(ENV["SPRING_LOG"] || File::NULL, "a") + def initialize(options = {}) + @root = options[:root] + @project_root = options[:root] + @log_file = options[:log_file] || File.open(ENV["SPRING_LOG"] || File::NULL, "a") end def root @@ -33,17 +33,20 @@ end def tmp_path - path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}")) + path = Pathname.new( + ENV["SPRING_TMP_PATH"] || + File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}") + ) FileUtils.mkdir_p(path) unless path.exist? path end def application_id - Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s) + ENV["SPRING_APPLICATION_ID"] || Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s) end def socket_path - tmp_path.join(application_id) + Pathname.new(ENV["SPRING_SOCKET"] || tmp_path.join(application_id)) end def socket_name @@ -51,7 +54,7 @@ end def pidfile_path - tmp_path.join("#{application_id}.pid") + Pathname.new(ENV["SPRING_PIDFILE"] || socket_path.dirname.join("#{socket_path.basename(".*")}.pid")) end def pid @@ -105,5 +108,9 @@ rescue Errno::ESRCH # already dead end + + def server_command + ENV["SPRING_SERVER_COMMAND"] || "#{File.expand_path("../../../bin/spring", __FILE__)} server --background" + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/server.rb new/lib/spring/server.rb --- old/lib/spring/server.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/server.rb 2016-04-11 15:53:04.000000000 +0200 @@ -10,19 +10,24 @@ module Spring class Server - def self.boot - new.boot + def self.boot(options = {}) + new(options).boot end attr_reader :env - def initialize(env = Env.new) - @env = env - @applications = Hash.new { |h, k| h[k] = ApplicationManager.new(k) } + def initialize(options = {}) + @foreground = options.fetch(:foreground, false) + @env = options[:env] || default_env + @applications = Hash.new { |h, k| h[k] = ApplicationManager.new(k, env) } @pidfile = env.pidfile_path.open('a') @mutex = Mutex.new end + def foreground? + @foreground + end + def log(message) env.log "[server] #{message}" end @@ -31,8 +36,8 @@ Spring.verify_environment write_pidfile - set_pgid - ignore_signals + set_pgid unless foreground? + ignore_signals unless foreground? set_exit_hook set_process_title start_server @@ -42,6 +47,7 @@ server = UNIXServer.open(env.socket_name) log "started on #{env.socket_name}" loop { serve server.accept } + rescue Interrupt end def serve(client) @@ -126,5 +132,19 @@ "spring server | #{env.app_name} | started #{distance} ago" } end + + private + + def default_env + Env.new(log_file: default_log_file) + end + + def default_log_file + if foreground? && !ENV["SPRING_LOG"] + $stdout + else + nil + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/test/acceptance_test.rb new/lib/spring/test/acceptance_test.rb --- old/lib/spring/test/acceptance_test.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/test/acceptance_test.rb 2016-04-11 15:53:04.000000000 +0200 @@ -28,6 +28,10 @@ @app ||= Spring::Test::Application.new("#{Spring::Test.root}/apps/tmp") end + def spring_env + app.spring_env + end + def assert_output(artifacts, expected) expected.each do |stream, output| assert artifacts[stream].include?(output), @@ -47,6 +51,14 @@ assert_output artifacts, expected_output if expected_output end + def refute_output_includes(command, not_expected) + artifacts = app.run(*Array(command)) + not_expected.each do |stream, output| + assert !artifacts[stream].include?(output), + "expected #{stream} to not include '#{output}'.\n\n#{app.debug(artifacts)}" + end + end + def assert_speedup(ratio = DEFAULT_SPEEDUP) if ENV['CI'] yield @@ -84,14 +96,25 @@ test "help message when called without arguments" do assert_success "bin/spring", stdout: 'Usage: spring COMMAND [ARGS]' - assert app.spring_env.server_running? + assert spring_env.server_running? end test "shows help" do assert_success "bin/spring help", stdout: 'Usage: spring COMMAND [ARGS]' assert_success "bin/spring -h", stdout: 'Usage: spring COMMAND [ARGS]' assert_success "bin/spring --help", stdout: 'Usage: spring COMMAND [ARGS]' - refute app.spring_env.server_running? + refute spring_env.server_running? + end + + test "tells the user that spring is being used when used automatically via binstubs" do + assert_success "bin/rails runner ''", stderr: "Running via Spring preloader in process" + assert_success app.spring_test_command, stderr: "Running via Spring preloader in process" + end + + test "does not tell the user that spring is being used when used automatically via binstubs but quiet is enabled" do + File.write("#{app.user_home}/.spring.rb", "Spring.quiet = true") + assert_success "bin/rails runner ''" + refute_output_includes "bin/rails runner ''", stderr: 'Running via Spring preloader in process' end test "test changes are picked up" do @@ -165,10 +188,10 @@ test "stop command kills server" do app.run app.spring_test_command - assert app.spring_env.server_running?, "The server should be running but it isn't" + assert spring_env.server_running?, "The server should be running but it isn't" assert_success "bin/spring stop" - assert !app.spring_env.server_running?, "The server should not be running but it is" + assert !spring_env.server_running?, "The server should not be running but it is" end test "custom commands" do @@ -381,7 +404,7 @@ end test "can define client tasks" do - File.write("#{app.spring_config.sub('.rb', '_client.rb')}", <<-RUBY) + File.write("#{app.spring_client_config}", <<-RUBY) Spring::Client::COMMANDS["foo"] = lambda { |args| puts "bar -- \#{args.inspect}" } RUBY assert_success "bin/spring foo --baz", stdout: "bar -- [\"foo\", \"--baz\"]\n" @@ -447,7 +470,7 @@ system(#{app.env.inspect}, "bundle install") end output = `\#{Rails.root.join('bin/rails')} runner 'require "devise"; puts "done";'` - exit output == "done\n" + exit output.include? "done\n" RUBY assert_success [%(bin/rails runner 'load Rails.root.join("script.rb")'), timeout: 60] @@ -476,6 +499,41 @@ expr = "p Kernel.private_instance_methods.include?(:raise)" assert_success %(bin/rails runner '#{expr}'), stdout: "true" end + + test "custom bundle path" do + bundle_path = app.path(".bundle/#{Bundler.ruby_scope}") + bundle_path.dirname.mkpath + + FileUtils.cp_r "#{app.gem_home}/", bundle_path.to_s + + app.run! "bundle install --path .bundle --clean --local" + + assert_speedup do + 2.times { assert_success "bundle exec rails runner ''" } + end + end + + test "booting a foreground server" do + FileUtils.cd(app.root) do + assert !spring_env.server_running? + app.run "spring server &" + + Timeout.timeout(1) do + sleep 0.1 until spring_env.server_running? + end + + assert_success app.spring_test_command + end + end + + test "server boot timeout" do + app.env["SPRING_SERVER_COMMAND"] = "sleep 1" + File.write("#{app.spring_client_config}", %( + Spring::Client::Run.const_set(:BOOT_TIMEOUT, 0.1) + )) + + assert_failure "bin/rails runner ''", stderr: "timed out" + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/test/application.rb new/lib/spring/test/application.rb --- old/lib/spring/test/application.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/test/application.rb 2016-04-11 15:53:04.000000000 +0200 @@ -9,7 +9,7 @@ def initialize(root) @root = Pathname.new(root) - @spring_env = Spring::Env.new(root) + @spring_env = Spring::Env.new(root: root) end def exists? @@ -88,6 +88,10 @@ path "config/spring.rb" end + def spring_client_config + path "config/spring_client.rb" + end + def run(command, opts = {}) start_time = Time.now @@ -117,7 +121,7 @@ output.merge(status: status, command: command) rescue Timeout::Error => e - raise e, "Output:\n\n#{dump_streams(command, read_streams)}" + raise Timeout::Error, "While running command:\n\n#{dump_streams(command, read_streams)}" end def with_timing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/test/application_generator.rb new/lib/spring/test/application_generator.rb --- old/lib/spring/test/application_generator.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/test/application_generator.rb 2016-04-11 15:53:04.000000000 +0200 @@ -58,6 +58,10 @@ append_to_file(application.gemfile, "gem 'spring-commands-testunit'") end + if RUBY_VERSION == "1.9.3" + append_to_file(application.gemfile, "gem 'mime-types', '~> 2'") + end + rewrite_file(application.gemfile) do |c| c.sub!("https://rubygems.org", "http://rubygems.org") c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1") @@ -112,7 +116,7 @@ system("gem build #{name}.gemspec 2>&1") end - application.run! "gem install #{spec.gem_dir}/#{name}-*.gem", timeout: nil + application.run! "gem install #{spec.gem_dir}/#{name}-*.gem --no-ri --no-rdoc", timeout: nil end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/spring/version.rb new/lib/spring/version.rb --- old/lib/spring/version.rb 2015-11-30 17:32:44.000000000 +0100 +++ new/lib/spring/version.rb 2016-04-11 15:53:04.000000000 +0200 @@ -1,3 +1,3 @@ module Spring - VERSION = "1.5.0" + VERSION = "1.7.1" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-11-30 17:32:44.000000000 +0100 +++ new/metadata 2016-04-11 15:53:04.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: spring version: !ruby/object:Gem::Version - version: 1.5.0 + version: 1.7.1 platform: ruby authors: - Jon Leighton autorequire: bindir: bin cert_chain: [] -date: 2015-11-30 00:00:00.000000000 Z +date: 2016-04-11 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: activesupport @@ -75,6 +75,7 @@ - lib/spring/client/help.rb - lib/spring/client/rails.rb - lib/spring/client/run.rb +- lib/spring/client/server.rb - lib/spring/client/status.rb - lib/spring/client/stop.rb - lib/spring/client/version.rb @@ -119,7 +120,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.5.1 +rubygems_version: 2.5.1 signing_key: specification_version: 4 summary: Rails application preloader