-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
52 lines (41 loc) · 1.36 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
desc "Build and run the program in the specified languages/ directory"
task :run, :arg1 do |t, args|
language_glob = args[:arg1] || '*'
language_glob_desc = args[:arg1] || 'all languages'
puts "Building #{language_glob_desc}..."
Dir["languages/#{language_glob}/Rakefile"].sort.each do |path_to_rakefile|
base_path, language, _ = path_to_rakefile.split('/')
language_path = "#{base_path}/#{language}"
puts " * Entering directory '#{language_path}'"
load path_to_rakefile
begin
clean_task_name = "#{language}:clean"
print " * Running task '#{clean_task_name}'... "
clean_task = Rake::application.tasks.detect {|t| t.name == clean_task_name }
if clean_task
clean_task.invoke
puts "done."
else
puts "not found."
end
build_task_name = "#{language}:build"
print " * Running task '#{build_task_name}'... "
Rake::Task[build_task_name].invoke
puts "done."
ruby_exec = `which ruby`.chomp
print " * Running tests..."
test_output = `LANGUAGE_PATH="./#{language_path}" "#{ruby_exec}" ./test/unscramble_test.rb`
puts test_output
if $?.success?
puts "done."
else
puts "failed."
# puts test_output
end
rescue => e
puts "failed."
puts " #{e.message}"
end
end
end
task :default => :run