Skip to content

Commit 4afe17f

Browse files
committed
Merge pull request #452 from sodabrew/task_prereqs
Define rake tasks first that will have dependencies added later
2 parents 84d78eb + bffb9a3 commit 4afe17f

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ matrix:
1313
env: RBXOPT=-Xgc.honor_start=true
1414
bundler_args: --without benchmarks
1515
script:
16-
- bundle exec rake
17-
- bundle exec rspec
16+
- bundle exec rake spec

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ group :development do
1616
end
1717

1818
platforms :rbx do
19-
gem 'rubysl'
19+
gem 'rubysl-rake'
20+
gem 'rubysl-drb'
21+
gem 'rubysl-bigdecimal'
2022
end

Rakefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# encoding: UTF-8
22
require 'rake'
33

4-
# Load custom tasks
5-
Dir['tasks/*.rake'].sort.each { |f| load f }
4+
# Load custom tasks (careful attention to define tasks before prerequisites)
5+
load 'tasks/rspec.rake'
6+
load 'tasks/compile.rake'
7+
load 'tasks/generate.rake'
8+
load 'tasks/benchmarks.rake'
9+
load 'tasks/vendor_mysql.rake'
10+
11+
task :default => :spec

spec/mysql2/client_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def connect *args
106106

107107
it "should not leave dangling connections after garbage collection" do
108108
GC.start
109+
sleep 1 if defined? Rubinius # Let the rbx GC thread do its work
109110
client = Mysql2::Client.new(DatabaseCredentials['root'])
110111
before_count = client.query("SHOW STATUS LIKE 'Threads_connected'").first['Value'].to_i
111112

@@ -116,9 +117,9 @@ def connect *args
116117
after_count.should == before_count + 10
117118

118119
GC.start
120+
sleep 1 if defined? Rubinius # Let the rbx GC thread do its work
119121
final_count = client.query("SHOW STATUS LIKE 'Threads_connected'").first['Value'].to_i
120-
final_count.should == before_count if !defined? Rubinius
121-
final_count.should < before_count + 5 if defined? Rubinius # Cut GC some slack
122+
final_count.should == before_count
122123
end
123124

124125
it "should be able to connect to database with numeric-only name" do

tasks/rspec.rake

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ begin
2626
RSpec::Core::RakeTask.new('spec') do |t|
2727
t.verbose = true
2828
end
29-
30-
task :default => :spec
3129
rescue LoadError
3230
puts "rspec, or one of its dependencies, is not available. Install it with: sudo gem install rspec"
3331
end
@@ -37,9 +35,8 @@ file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
3735
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
3836
dst_path = File.expand_path("../../#{task.name}", __FILE__)
3937

40-
dst_file = File.open(dst_path, 'w')
41-
File.open(src_path) do |f|
42-
f.each_line do |line|
38+
File.open(dst_path, 'w') do |dst_file|
39+
File.open(src_path).each_line do |line|
4340
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
4441
end
4542
end
@@ -50,9 +47,8 @@ file 'spec/my.cnf' => 'spec/my.cnf.example' do |task|
5047
src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
5148
dst_path = File.expand_path("../../#{task.name}", __FILE__)
5249

53-
dst_file = File.open(dst_path, 'w')
54-
File.open(src_path) do |f|
55-
f.each_line do |line|
50+
File.open(dst_path, 'w') do |dst_file|
51+
File.open(src_path).each_line do |line|
5652
dst_file.write line.gsub(/LOCALUSERNAME/, ENV['USER'])
5753
end
5854
end

0 commit comments

Comments
 (0)