da3mon / especial

an attempt at BDD in erlang

especial / Rakefile
100644 32 lines (27 sloc) 1.046 kb
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
%w(rake/clean rubygems colored).each { |f| require f }
 
INCLUDE = "include"
ERLC_FLAGS = "-I#{INCLUDE} +warn_unused_vars +warn_unused_import"
SRC = FileList['src/*.erl']
TEST = FileList['test/*.erl']
OBJ = SRC.pathmap("%{^src$,ebin}X.beam")
TESTS = TEST.pathmap("%{^test$,ebin}X.beam")
CLEAN.include("ebin/*.beam", "tests/*.beam", "erl_crash.dump")
 
directory 'ebin'
directory 'tests'
 
rule ".beam" => ["%{ebin,src;ebin,test}X.erl"] do |t|
  sh "erlc -D EUNIT -pa ebin -pz /Users/da3mon/hack/erlang/eunit/ebin -W #{ERLC_FLAGS} -o ebin #{t.source}"
end
 
task :compile => ['ebin'] + OBJ + TESTS
task :default => [:clean, :test]
 
task :test => :compile do
  puts "Modules under test:".cyan
  TESTS.each do |test|
    test[%r{.*/(test_.*).beam}]
    next if $1.nil?
    file_under_test = $1
    puts "Testing " + "#{$1.gsub(/test_/, '')}".green_on_black
    puts "erl -pa ebin -run #{file_under_test} test -run init stop".red if ENV['DEBUG']
    test_output = `erl -pa ebin -run #{file_under_test} test -run init stop`
    puts test_output
  end
end