Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 2, 2019. It is now read-only.

Commit 58a5460

Browse filesBrowse files
committed
Merge branch 'parallel_test'
2 parents 88c662f + 9bb32f5 commit 58a5460
Copy full SHA for 58a5460

2 files changed

+89-51Lines changed: 89 additions & 51 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Gemfile‎

Copy file name to clipboardExpand all lines: Gemfile
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
22

33
gem 'maruku', '0.6.1'
44
gem 'redcarpet'
5-
gem 'rdiscount'
5+
gem 'parallel'
Collapse file

‎Rakefile‎

Copy file name to clipboardExpand all lines: Rakefile
+88-50Lines changed: 88 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,95 @@ namespace :pdf do
160160
end
161161

162162
class StderrDecorator
163+
def initialize(out)
164+
@out = out
165+
end
166+
163167
def <<(x)
164-
$stderr<< "#{x}"
168+
@out << "#{x}"
165169
if x.match /REXML/
166170
raise ""
167171
end
168172
end
169173
end
170174

175+
def test_lang(lang, out)
176+
error_code = false
177+
chapter_figure = {
178+
"01-introduction" => 7,
179+
"02-git-basics" => 2,
180+
"03-git-branching" => 39,
181+
"04-git-server" => 15,
182+
"05-distributed-git" => 27,
183+
"06-git-tools" => 1,
184+
"07-customizing-git" => 3,
185+
"08-git-and-other-scms" => 0,
186+
"09-git-internals" => 4}
187+
source_files = FileList.new(File.join(lang, '0*', '*.markdown')).sort
188+
source_files.each do |mk_filename|
189+
src_file = File.open(mk_filename, 'r')
190+
figure_count = 0
191+
until src_file.eof?
192+
line = src_file.readline
193+
matches = line.match /^#/
194+
if matches
195+
if line.match /^(#+).*#[[:blank:]]+$/
196+
out<< "\nBadly formatted title in #{mk_filename}: #{line}\n"
197+
error_code = true
198+
end
199+
end
200+
if line.match /^\s*Insert\s(.*)/
201+
figure_count = figure_count + 1
202+
end
203+
end
204+
# This extraction is a bit contorted, because the pl translation renamed
205+
# the files, so the match is done on the directories.
206+
tab_fig_count = chapter_figure[File.basename(File.dirname(mk_filename))]
207+
expected_figure_count = tab_fig_count ? tab_fig_count:0
208+
if figure_count > expected_figure_count
209+
out << "\nToo many figures declared in #{mk_filename}\n"
210+
error_code = true
211+
end
212+
end
213+
begin
214+
mark = (source_files.map{|mk_filename| File.open(mk_filename, 'r'){
215+
|mk| mk.read.encode("UTF-8")}}).join('\n\n')
216+
require 'maruku'
217+
code = Maruku.new(mark, :on_error => :raise, :error_stream => StderrDecorator.new(out))
218+
rescue
219+
print $!
220+
error_code = true
221+
end
222+
error_code
223+
end
224+
225+
$out = $stdout
226+
171227
namespace :ci do
228+
desc "Parallel Continuous integration"
229+
task :parallel_check do
230+
require 'parallel'
231+
langs = FileList.new('??')+FileList.new('??-??')
232+
results = Parallel.map(langs) do |lang|
233+
error_code = test_lang(lang, $out)
234+
if error_code
235+
print "processing #{lang} KO\n"
236+
else
237+
print "processing #{lang} OK\n"
238+
end
239+
error_code
240+
end
241+
fail "At least one language conversion failed" if results.any?
242+
end
243+
244+
(FileList.new('??')+FileList.new('??-??')).each do |lang|
245+
desc "testing " + lang
246+
task (lang+"_check").to_sym do
247+
error_code = test_lang(lang, $out)
248+
fail "processing #{lang} KO\n" if error_code
249+
print "processing #{lang} OK\n"
250+
end
251+
end
172252

173253
desc "Continuous Integration"
174254
task :check do
@@ -184,59 +264,17 @@ namespace :ci do
184264
end
185265
langs -= excluded_langs
186266
end
187-
error_code = false
188-
chapter_figure = {
189-
"01-introduction" => 7,
190-
"02-git-basics" => 2,
191-
"03-git-branching" => 39,
192-
"04-git-server" => 15,
193-
"05-distributed-git" => 27,
194-
"06-git-tools" => 1,
195-
"07-customizing-git" => 3,
196-
"08-git-and-other-scms" => 0,
197-
"09-git-internals" => 4}
198-
langs.each do |lang|
267+
errors = langs.each do |lang|
199268
print "processing #{lang} "
200-
mark = ''
201-
source_files = FileList.new(File.join(lang, '0*', '*.markdown')).sort
202-
source_files.each do |mk_filename|
203-
mk_file = File.open(mk_filename, 'r') do |mk|
204-
mark+= mk.read.encode("UTF-8")
205-
end
206-
src_file = File.open(mk_filename, 'r')
207-
figure_count = 0
208-
until src_file.eof?
209-
line = src_file.readline
210-
matches = line.match /^#/
211-
if matches
212-
if line.match /^(#+).*#[[:blank:]]+$/
213-
print "\nBadly formatted title in #{mk_filename}: #{line}\n"
214-
error_code = true
215-
end
216-
end
217-
if line.match /^\s*Insert\s(.*)/
218-
figure_count = figure_count + 1
219-
end
220-
end
221-
# This extraction is a bit contorted, because the pl translation renamed
222-
# the files, so the match is done on the directories.
223-
tab_fig_count = chapter_figure[File.basename(File.dirname(mk_filename))]
224-
expected_figure_count = tab_fig_count ? tab_fig_count:0
225-
if figure_count > expected_figure_count
226-
print "\nToo many figures declared in #{mk_filename}\n"
227-
error_code = true
228-
end
229-
end
230-
begin
231-
code = Maruku.new(mark, :on_error => :raise, :error_stream => StderrDecorator.new)
232-
print "OK\n"
233-
rescue
269+
error_code=test_lang(lang, $out)
270+
if error_code
234271
print "KO\n"
235-
print $!
236-
error_code = true
272+
else
273+
print "OK\n"
237274
end
275+
error_code
238276
end
239-
fail "At least one language conversion failed" if error_code
277+
fail "At least one language conversion failed" if errors.any?
240278
end
241279

242280
end

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.