Add "make check" rule

The make check rule prepares test database and runs all tests found
to succeed on my personal local deploy. This is a fraction of all
available tests. The list of run tests should grow over time.

In addition to the "check" rule, which does both db preparation and
test run, there's a "check-prepared" rule that assumes a test
database was already prepared and a "prepare-test-db" which only
prepares the database.
pull/243/head
Sandro Santilli 11 years ago
parent 041c561593
commit 03f598edd9

@ -0,0 +1,19 @@
WORKING_SPECS = \
spec/lib \
spec/models/layer_spec.rb \
spec/models/tag_spec.rb \
$(NULL)
all:
@echo "Try make check"
prepare-test-db:
# TODO skip this if db already exists ?
bundle exec rake db:test:prepare
check-prepared:
bundle exec rspec $(WORKING_SPECS)
check: prepare-test-db check-prepared

@ -1,6 +1,14 @@
Testing CartoDB
===============
Easy way
--------
Just run "make check".
Detailed way
------------
CartoDB tests are based on [Ruby Spec](http://rspec.info/).
The procedure to run them is as follows:
@ -24,7 +32,8 @@ Common system configuration issues are reported in this section.
Make sure test.port in config/database.yml is not pointing to
pg_bouncer, as dynamically created database roles aren't easily
supported by it (you need to explicitly list allowed usernames).
supported by it (you'd need to explicitly list allowed usernames,
and over 70 new users are created during a full testsuite run).
Speeding up test runs
---------------------

@ -57,6 +57,7 @@ RSpec::Matchers.define :pass_sql_tests do
Dir.glob(glob).each do |f|
testname = File.basename(f)
tname = File.basename(f, '.sql')
puts "Testing #{tname}"
expfile = File.dirname(f) + '/' + tname + '_expect'
cmd = "#{env} psql -X -tA < #{f} #{actual.database_name} 2>&1 | diff -U2 #{expfile} - 2>&1"
result = `#{cmd}`

Loading…
Cancel
Save