Permalink
Browse files

Make index tests more robust against non-deterministic results

The #select_value method returns a value of one randomly chosen column,
which can sometimes be a NULL value even if the row itself exist.
  • Loading branch information...
1 parent 50bb1bf commit 64d27ad37924fcde981e3718ca0f8dd3c3b67c65 @grobie committed Mar 25, 2012
Showing with 9 additions and 4 deletions.
  1. +7 −3 bin/lhm-test-all.sh
  2. +2 −1 spec/integration/integration_helper.rb
View
@@ -1,6 +1,10 @@
#!/bin/sh
-for gemfile in gemfiles/*.gemfile; do
- BUNDLE_GEMFILE=$gemfile bundle install
- BUNDLE_GEMFILE=$gemfile bundle exec rake
+for gemfile in gemfiles/*.gemfile
+do
+ if !(BUNDLE_GEMFILE=$gemfile bundle install &&
+ BUNDLE_GEMFILE=$gemfile bundle exec rake)
+ then
+ exit 1
+ fi
done
@@ -53,6 +53,7 @@ def execute(*args)
connection.execute(*args)
rescue ActiveRecord::StatementInvalid => e
if (retries -= 1) > 0 && e.message =~ /Table '.*?' doesn't exist/
+ sleep 0.1
retry
else
raise
@@ -122,7 +123,7 @@ def index_on_columns?(table_name, cols, type = :non_unique)
def index?(table_name, key_name, type = :non_unique)
non_unique = type == :non_unique ? 1 : 0
- !!select_value(%Q<
+ !!select_one(%Q<
show indexes in #{ table_name }
where key_name = '#{ key_name }'
and non_unique = #{ non_unique }

0 comments on commit 64d27ad

Please sign in to comment.