summaryrefslogtreecommitdiff
path: root/lib
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 /lib
parente4990b66df64f2e23502d161f411335c9a771a43 (diff)
downloadgitlab-ce-2f0d2ab55b6deac79f81834f6724a676ceae94ae.tar.gz
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/lint.rake43
1 files changed, 32 insertions, 11 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