Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 126 lines (102 sloc) 3.069 kB
9627f18 @christophsturm run specs with bundler
christophsturm authored
1
dbbfb83 Initial commit.
Brenden Grace authored
2 require 'rake'
f05c788 Fix to play nice with bundler on 1.9
Peter Kieltyka authored
3 require 'rake/gempackagetask'
dbbfb83 Initial commit.
Brenden Grace authored
4
5 require 'spec/rake/spectask'
6 require 'fileutils'
0b83b08 @bcg New MongoRunner.
bcg authored
7 require 'tmpdir'
dbbfb83 Initial commit.
Brenden Grace authored
8
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
9 def em_mongo_version
10 File.read("VERSION").strip
11 end
12
13 def root_dir
14 File.dirname(__FILE__)
15 end
16
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
17 task :default => 'spec:integration:default'
66a35ed @gaffneyc Use BSON::ObjectID for _id instead of String
gaffneyc authored
18
dbbfb83 Initial commit.
Brenden Grace authored
19 class MongoRunner
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
20 def self.run(options={})
21 auth = "--auth" if options[:auth]
0b83b08 @bcg New MongoRunner.
bcg authored
22 dir = Dir.tmpdir
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
23 FileUtils.rm_r Dir.glob("#{dir}/*") unless options[:noclean]
0b83b08 @bcg New MongoRunner.
bcg authored
24 pidf = "#{dir}/mongod.pid"
25 logf = "#{dir}/mongo.log"
26 begin
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
27 #puts "mongod run #{auth} --fork -vvvvvvv --dbpath #{dir} --pidfilepath #{pidf} --logpath #{logf} >> /dev/null "
28 system "mongod run #{auth} --fork -vvvvvvv --dbpath #{dir} --pidfilepath #{pidf} --logpath #{logf} >> /dev/null "
0b83b08 @bcg New MongoRunner.
bcg authored
29 yield if block_given?
30 ensure
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
31 if File.exists?(pidf) and File.read(pidf).to_i != 0
32 Process.kill("KILL", File.read(pidf).to_i)
33 FileUtils.rm_r Dir.glob("#{dir}/*") unless options[:noclean]
34 end
0b83b08 @bcg New MongoRunner.
bcg authored
35 end
dbbfb83 Initial commit.
Brenden Grace authored
36 end
37 end
38
f05c788 Fix to play nice with bundler on 1.9
Peter Kieltyka authored
39 spec = eval(File.read('em-mongo.gemspec'))
0b83b08 @bcg New MongoRunner.
bcg authored
40
f05c788 Fix to play nice with bundler on 1.9
Peter Kieltyka authored
41 Rake::GemPackageTask.new(spec) do |pkg|
42 pkg.gem_spec = spec
43 end
dbbfb83 Initial commit.
Brenden Grace authored
44
1de346e @bcg A few helper tasks for gem management.
bcg authored
45 namespace :gem do
46
47 desc "build gem"
48 task :build do
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
49 puts "Building em-mongo #{em_mongo_version}"
50 system "gem build em-mongo.gemspec -q"
1de346e @bcg A few helper tasks for gem management.
bcg authored
51 end
52
53 desc "release gem"
54 task :release do
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
55 system "gem push em-mongo-#{em_mongo_version}.gem"
1de346e @bcg A few helper tasks for gem management.
bcg authored
56 end
57
58 end
59
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
60 namespace :spec do
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
61
62 namespace :gem do
63
64 desc "bundler tests"
65 task :bundler do
66 MongoRunner.run do
67 print "Testing Bundler integration ... "
68 if system "cd spec/gem && bundle install --quiet && ./bundler.rb"
69 puts "SUCCESS."
70 else
71 puts "FAILURE."
72 end
73 end
74 end
75
76 desc "rubygems tests"
77 task :rubygems do
78 MongoRunner.run do
79 print "Testing Rubygems integration ... "
80 steps =[]
81 steps << "cd spec/gem"
82 steps << "gem uninstall -a em-mongo >/dev/null"
83 steps << "gem install #{root_dir}/em-mongo-#{em_mongo_version}.gem >/dev/null"
84 steps << "./rubygems.rb"
85 if system steps.join(" && ")
86 puts "SUCCESS."
87 else
88 puts "FAILURE."
89 end
90 end
91 end
92
93 desc "all gem tests"
94 task :all => [:bundler, :rubygems]
95 end
96
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
97 namespace :integration do
1de346e @bcg A few helper tasks for gem management.
bcg authored
98
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
99 desc "default tests"
100 task :default do
101 MongoRunner.run do
102 system "bundle exec spec #{spec.test_files.join(' ')} -t -b -fs -color"
103 end
104 end
105
106 desc "exhaustive tests"
107 task :exhaustive do
108 MongoRunner.run({:noclean => true}) do
109 system "bundle exec spec #{spec.test_files.join(' ')} -t -b -fs -color"
110 end
111 MongoRunner.run({:auth => true}) do
112 system "bundle exec spec #{spec.test_files.join(' ')} -t -b -fs -color"
113 end
114 end
115
1de346e @bcg A few helper tasks for gem management.
bcg authored
116 desc "default tests, but don't start mongodb for me"
63fb193 @bcg Refactored tests, database.rb and authentication (unfortunate massive
bcg authored
117 task :no_mongo do
118 system "bundle exec spec #{spec.test_files.join(' ')} -t -b -fs -color"
119 end
1de346e @bcg A few helper tasks for gem management.
bcg authored
120
dbbfb83 Initial commit.
Brenden Grace authored
121 end
be7f8de @bcg Now with Bundler and a new spec/gem test system.
bcg authored
122
123 desc "release testing"
124 task :release => ['spec:integration:default','gem:build','spec:gem:bundler','spec:gem:rubygems']
dbbfb83 Initial commit.
Brenden Grace authored
125 end
Something went wrong with that request. Please try again.