summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-02-12 18:34:07 +0100
committerRémy Coutable <remy@rymai.me>2018-02-14 17:34:34 +0100
commit2f0d2ab55b6deac79f81834f6724a676ceae94ae (patch)
treef4aa6c1946ceb13933c5ad378813c47312f2d5a0
parente4990b66df64f2e23502d161f411335c9a771a43 (diff)
downloadgitlab-ce-2f0d2ab55b6deac79f81834f6724a676ceae94ae.tar.gz
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--lib/tasks/lint.rake43
-rwxr-xr-xscripts/static-analysis4
2 files changed, 34 insertions, 13 deletions
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index e7812ff3568..fe5032cae18 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -20,7 +20,6 @@ unless Rails.env.production?
desc "GitLab | lint | Run several lint checks"
task :all do
status = 0
- original_stdout = $stdout
%w[
config_lint
@@ -30,19 +29,41 @@ unless Rails.env.production?
gettext:lint
lint:static_verification
].each do |task|
- begin
- $stdout = StringIO.new
- Rake::Task[task].invoke
- rescue RuntimeError, SystemExit => ex
- raise ex if ex.is_a?(RuntimeError) && task != 'haml_lint'
- original_stdout << $stdout.string
- status = 1
- ensure
- $stdout = original_stdout
+ pid = Process.fork do
+ rd, wr = IO.pipe
+ stdout = $stdout.dup
+ stderr = $stderr.dup
+ $stdout.reopen(wr)
+ $stderr.reopen(wr)
+
+ begin
+ begin
+ Rake::Task[task].invoke
+ rescue RuntimeError # The haml_lint tasks raise a RuntimeError
+ exit(1)
+ end
+ rescue SystemExit => ex
+ msg = "*** Rake task #{task} failed with the following error(s):"
+ raise ex
+ ensure
+ $stdout.reopen(stdout)
+ $stderr.reopen(stderr)
+ wr.close
+
+ if msg
+ warn "\n#{msg}\n\n"
+ IO.copy_stream(rd, $stderr)
+ else
+ IO.copy_stream(rd, $stdout)
+ end
+ end
end
+
+ Process.waitpid(pid)
+ status += $?.exitstatus
end
- exit status
+ exit(status)
end
end
end
diff --git a/scripts/static-analysis b/scripts/static-analysis
index db4df4ee6cb..0e67eabfec1 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -7,7 +7,7 @@ require_relative '../lib/gitlab/popen/runner'
def emit_warnings(static_analysis)
static_analysis.warned_results.each do |result|
puts
- puts "**** #{result.cmd.join(' ')} had the following warnings:"
+ puts "**** #{result.cmd.join(' ')} had the following warning(s):"
puts
puts result.stderr
puts
@@ -17,7 +17,7 @@ end
def emit_errors(static_analysis)
static_analysis.failed_results.each do |result|
puts
- puts "**** #{result.cmd.join(' ')} failed with the following error:"
+ puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
puts
puts result.stdout
puts result.stderr