mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add rubocop to our build. (#5004)
This commit is contained in:
@@ -16,7 +16,7 @@ class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
||||
def start(example_count)
|
||||
super
|
||||
File.delete(RSPEC_RESULT) if File.exists?(RSPEC_RESULT)
|
||||
@fail_file = File.open(RSPEC_RESULT,"w")
|
||||
@fail_file = File.open(RSPEC_RESULT, "w")
|
||||
end
|
||||
|
||||
def example_passed(_notification)
|
||||
|
@@ -9,7 +9,7 @@ module Autospec; end
|
||||
|
||||
class Autospec::Manager
|
||||
|
||||
def self.run(opts={})
|
||||
def self.run(opts = {})
|
||||
self.new(opts).run
|
||||
end
|
||||
|
||||
@@ -66,10 +66,10 @@ class Autospec::Manager
|
||||
Autospec::QunitRunner.new
|
||||
end
|
||||
|
||||
def ensure_all_specs_will_run(current_runner=nil)
|
||||
def ensure_all_specs_will_run(current_runner = nil)
|
||||
puts "@@@@@@@@@@@@ ensure_all_specs_will_run" if @debug
|
||||
|
||||
@queue.reject!{|_,s,_| s == "spec"}
|
||||
@queue.reject! { |_, s, _| s == "spec" }
|
||||
|
||||
if current_runner
|
||||
@queue.concat [['spec', 'spec', current_runner]]
|
||||
@@ -151,14 +151,14 @@ class Autospec::Manager
|
||||
|
||||
# try focus tag
|
||||
if failed_specs.length > 0
|
||||
filename,_ = failed_specs[0].split(":")
|
||||
filename, _ = failed_specs[0].split(":")
|
||||
if filename && File.exist?(filename) && !File.directory?(filename)
|
||||
spec = File.read(filename)
|
||||
start,_ = spec.split(/\S*#focus\S*$/)
|
||||
start, _ = spec.split(/\S*#focus\S*$/)
|
||||
if start.length < spec.length
|
||||
line = start.scan(/\n/).length + 1
|
||||
puts "Found #focus tag on line #{line}!"
|
||||
failed_specs = ["#{filename}:#{line+1}"]
|
||||
failed_specs = ["#{filename}:#{line + 1}"]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -188,7 +188,7 @@ class Autospec::Manager
|
||||
FileUtils.rm_f(socket_path)
|
||||
server = SocketServer.new(socket_path)
|
||||
server.start do |line|
|
||||
file,line = line.split(' ')
|
||||
file, line = line.split(' ')
|
||||
file = file.sub(Rails.root.to_s << "/", "")
|
||||
# process_change can aquire a mutex and block
|
||||
# the acceptor
|
||||
@@ -196,7 +196,7 @@ class Autospec::Manager
|
||||
if file =~ /(es6|js)$/
|
||||
process_change([[file]])
|
||||
else
|
||||
process_change([[file,line]])
|
||||
process_change([[file, line]])
|
||||
end
|
||||
end
|
||||
"OK"
|
||||
@@ -213,7 +213,7 @@ class Autospec::Manager
|
||||
listener = Listen.to("#{path}/#{watch}", options) do |modified, added, _|
|
||||
paths = [modified, added].flatten
|
||||
paths.compact!
|
||||
paths.map!{|long| long[(path.length+1)..-1]}
|
||||
paths.map! { |long| long[(path.length + 1)..-1] }
|
||||
process_change(paths)
|
||||
end
|
||||
listener.start
|
||||
@@ -246,7 +246,7 @@ class Autospec::Manager
|
||||
end
|
||||
end
|
||||
# watchers
|
||||
runner.watchers.each do |k,v|
|
||||
runner.watchers.each do |k, v|
|
||||
if m = k.match(file)
|
||||
puts "@@@@@@@@@@@@ #{file} matched a watcher for #{runner}" if @debug
|
||||
hit = true
|
||||
|
@@ -144,7 +144,7 @@ module Autospec
|
||||
end
|
||||
|
||||
def try_to_find_module_name(file)
|
||||
file,_ = file.split(/:\d+$/)
|
||||
file, _ = file.split(/:\d+$/)
|
||||
return unless File.exists?(file)
|
||||
File.open(file, "r").each_line do |line|
|
||||
if m = /module\(['"]([^'"]+)/i.match(line)
|
||||
|
@@ -19,8 +19,8 @@ module Autospec
|
||||
|
||||
watch(%r{^spec/fabricators/.+_fabricator\.rb$}) { "spec" }
|
||||
|
||||
watch(%r{^app/assets/javascripts/pretty-text/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb"}
|
||||
watch(%r{^plugins/.*/discourse-markdown/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb"}
|
||||
watch(%r{^app/assets/javascripts/pretty-text/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb" }
|
||||
watch(%r{^plugins/.*/discourse-markdown/.*\.js\.es6$}) { "spec/components/pretty_text_spec.rb" }
|
||||
|
||||
watch(%r{^plugins/.*/spec/.*\.rb})
|
||||
|
||||
|
@@ -13,8 +13,8 @@ module Autospec
|
||||
"-f", "Autospec::Formatter", specs.split].flatten.join(" ")
|
||||
# launch rspec
|
||||
Dir.chdir(Rails.root) do
|
||||
env = {"RAILS_ENV" => "test"}
|
||||
if specs.split(' ').any?{|s| s =~ /^(.\/)?plugins/}
|
||||
env = { "RAILS_ENV" => "test" }
|
||||
if specs.split(' ').any? { |s| s =~ /^(.\/)?plugins/ }
|
||||
env["LOAD_PLUGINS"] = "1"
|
||||
puts "Loading plugins while running specs"
|
||||
end
|
||||
|
@@ -30,7 +30,7 @@ module Autospec
|
||||
def run(specs)
|
||||
args = ["-r", "#{File.dirname(__FILE__)}/formatter.rb",
|
||||
"-f", "Autospec::Formatter", specs.split].flatten
|
||||
spork_service.run(args,$stderr,$stdout)
|
||||
spork_service.run(args, $stderr, $stdout)
|
||||
end
|
||||
|
||||
def reload
|
||||
@@ -66,7 +66,7 @@ module Autospec
|
||||
|
||||
def write_pid_file(file, pid)
|
||||
FileUtils.mkdir_p(Rails.root + "tmp/pids")
|
||||
File.open(file,'w') do |f|
|
||||
File.open(file, 'w') do |f|
|
||||
f.write(pid)
|
||||
end
|
||||
end
|
||||
@@ -95,7 +95,7 @@ module Autospec
|
||||
sleep 1
|
||||
end
|
||||
|
||||
@spork_pid = Process.spawn({'RAILS_ENV' => 'test'}, "bundle exec spork")
|
||||
@spork_pid = Process.spawn({ 'RAILS_ENV' => 'test' }, "bundle exec spork")
|
||||
write_pid_file(spork_pid_file, @spork_pid)
|
||||
|
||||
running = false
|
||||
|
Reference in New Issue
Block a user