-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathRakefile
99 lines (84 loc) · 2.44 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#require 'rdiscount'
require 'yaml'
$: << './lib'
require 'course'
here = File.expand_path(File.dirname __FILE__)
def course
Course.new(ENV['course'] || "learn_ruby")
end
desc "list all the lab dirs in the course dir in YAML, for help making new course.yaml files"
task :list_labs do
puts Course.all_lab_names(course.curriculum_name).to_yaml
end
desc "build the course into its repo dir (default: course=learn_ruby)"
task :build do
course.build
puts "Built #{course.course_name} into #{course.repo_dir}"
download_dir = "#{here}/download"
course.build_tarball download_dir
puts "Built tarball into #{download_dir}"
end
desc "build the course into its repo dir and push it to github (default: course=learn_ruby)"
task :push do
c = course
c.create_repo
Rake::Task[:build].invoke
c.push_repo # todo: exit on failure
puts "Pushed #{course.course_name}"
end
require 'rspec/core/rake_task'
desc "run tests and specs of the framework"
task :test => :spec do
Dir.glob("#{here}/test/*_test.rb") do |f|
require f
end
end
desc "run tests of the framework"
RSpec::Core::RakeTask.new(:spec) do |task|
task.pattern = "spec/*_spec.rb"
end
task :default => :course
desc "run tests, exercises, and build the course (default: course=learn_ruby)"
task :course => :test do
# run all exercises in all labs
failed_labs = []
# todo: use Course/Lab objects
lab_dirs = FileList['learn_ruby/*'].select{|path| File.directory?(path)}
lab_dirs.each do |lab|
result = Dir.chdir(lab) do
system "rake"
end
puts "#{lab} " + (result ? "passed" : "FAILED")
puts ""
failed_labs << lab if result == false
end
something_failed = (not failed_labs.empty?)
if something_failed
puts "#{failed_labs.size} of #{lab_dirs.size} failed labs"
puts failed_labs.map{|c| "\t#{c}"}.join("\n")
end
exit 1 if something_failed
# make the package
# Rake::Task[:build].invoke
end
desc "launch the testfirst.org website on http://localhost:9292"
task :run do
# system 'rerun "foreman start"'
system 'rerun -- rackup -s thin'
end
desc "move index.md into test file"
task :unindex do
require 'course'
area = 'learn_ruby'
Course.all_labs(area).each do |lab|
begin
notes = File.read(lab.notes_file)
commented_notes = notes.gsub(/^/, '# ')
tests = File.read(lab.test_file)
# File.write(lab.test_file, tests)
File.write(lab.test_file, commented_notes + "\n" + tests)
rescue => e
p e
end
end
end