summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2011-01-02 22:15:30 +0100
committerFlorian Frank <flori@ping.de>2011-01-02 22:25:32 +0100
commita3a4c82b577ea44cbebe7c07a4b08b1d0079bd61 (patch)
tree0446107759fc24b32eb0727da2d5fa34ed778409
parent7d20dd9bce9f333c451d074cc0d2ac90560399e0 (diff)
downloadjson-a3a4c82b577ea44cbebe7c07a4b08b1d0079bd61.tar.gz
fixed test setup
-rw-r--r--Rakefile32
-rw-r--r--tests/setup_variant.rb11
-rwxr-xr-xtests/test_json.rb6
-rwxr-xr-xtests/test_json_addition.rb6
-rw-r--r--tests/test_json_encoding.rb6
-rwxr-xr-xtests/test_json_fixtures.rb6
-rwxr-xr-xtests/test_json_generate.rb6
-rw-r--r--tests/test_json_string_matching.rb6
-rwxr-xr-xtests/test_json_unicode.rb6
9 files changed, 33 insertions, 52 deletions
diff --git a/Rakefile b/Rakefile
index 09e9110..6cd0b12 100644
--- a/Rakefile
+++ b/Rakefile
@@ -101,7 +101,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask)
s.extra_rdoc_files << 'README'
s.rdoc_options <<
'--title' << 'JSON implemention for ruby' << '--main' << 'README'
- s.test_files.concat Dir['tests/*.rb']
+ s.test_files.concat Dir['./tests/test_*.rb']
s.author = "Florian Frank"
s.email = "flori@ping.de"
@@ -138,7 +138,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
s.extra_rdoc_files << 'README'
s.rdoc_options <<
'--title' << 'JSON implemention for Ruby' << '--main' << 'README'
- s.test_files.concat Dir['tests/*.rb']
+ s.test_files.concat Dir['./tests/test_*.rb']
s.author = "Florian Frank"
s.email = "flori@ping.de"
@@ -187,6 +187,17 @@ EOT
end
end
+desc "Testing library (pure ruby)"
+task :test_pure => :clean do
+ ENV['JSON'] = 'pure'
+ ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
+ myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
+end
+
+desc "Testing library (pure ruby and extension)"
+task :test => [ :test_pure, :test_ext ]
+
+
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
cd JAVA_DIR do
@@ -233,7 +244,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
desc "Testing library (jruby)"
task :test_ext => :create_jar do
ENV['JSON'] = 'ext'
- myruby '-S', 'testrb', '-Ilib', *Dir['tests/*.rb']
+ myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
end
file JRUBY_PARSER_JAR => :compile_ext do
@@ -277,9 +288,6 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
desc "Build all gems and archives for a new release of the jruby extension."
task :release => [ :clean, :version, :jruby_gem ]
-
- desc "Testing library (jruby extension)"
- task :test => :test_ext
else
desc "Compiling extension"
task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
@@ -304,7 +312,7 @@ else
task :test_ext => :compile_ext do
ENV['JSON'] = 'ext'
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
- myruby '-S', 'testrb', *Dir['./tests/*.rb']
+ myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
end
desc "Benchmarking parser"
@@ -378,16 +386,6 @@ else
desc "Generate diagrams of ragel parser"
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
- desc "Testing library (pure ruby)"
- task :test_pure => :clean do
- ENV['JSON'] = 'pure'
- ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
- myruby '-S', 'testrb', *Dir['tests/*.rb']
- end
-
- desc "Testing library (pure ruby and extension)"
- task :test => [ :test_pure, :test_ext ]
-
desc "Build all gems and archives for a new release of json and json_pure."
task :release => [ :clean, :version, :cross, :native, :gem, ] do
sh "#$0 clean native gem"
diff --git a/tests/setup_variant.rb b/tests/setup_variant.rb
new file mode 100644
index 0000000..2dab184
--- /dev/null
+++ b/tests/setup_variant.rb
@@ -0,0 +1,11 @@
+case ENV['JSON']
+when 'pure'
+ $:.unshift 'lib'
+ require 'json/pure'
+when 'ext'
+ $:.unshift 'ext', 'lib'
+ require 'json/ext'
+else
+ $:.unshift 'ext', 'lib'
+ require 'json'
+end
diff --git a/tests/test_json.rb b/tests/test_json.rb
index 00e52f5..2fc3c09 100755
--- a/tests/test_json.rb
+++ b/tests/test_json.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
require 'stringio'
unless Array.method_defined?(:permutation)
diff --git a/tests/test_json_addition.rb b/tests/test_json_addition.rb
index edf8699..c8bfb41 100755
--- a/tests/test_json_addition.rb
+++ b/tests/test_json_addition.rb
@@ -2,11 +2,7 @@
# -*- coding:utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
load 'json/add/core.rb'
require 'date'
diff --git a/tests/test_json_encoding.rb b/tests/test_json_encoding.rb
index cdeca58..7af5e63 100644
--- a/tests/test_json_encoding.rb
+++ b/tests/test_json_encoding.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
class TC_JSONEncoding < Test::Unit::TestCase
include JSON
diff --git a/tests/test_json_fixtures.rb b/tests/test_json_fixtures.rb
index 378667f..e9df8f5 100755
--- a/tests/test_json_fixtures.rb
+++ b/tests/test_json_fixtures.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
class TC_JSONFixtures < Test::Unit::TestCase
def setup
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index 5380a06..e6219df 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
class TC_JSONGenerate < Test::Unit::TestCase
include JSON
diff --git a/tests/test_json_string_matching.rb b/tests/test_json_string_matching.rb
index 0ea12ed..149a63b 100644
--- a/tests/test_json_string_matching.rb
+++ b/tests/test_json_string_matching.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
require 'stringio'
require 'time'
diff --git a/tests/test_json_unicode.rb b/tests/test_json_unicode.rb
index 505f5d5..ace56ca 100755
--- a/tests/test_json_unicode.rb
+++ b/tests/test_json_unicode.rb
@@ -2,11 +2,7 @@
# -*- coding: utf-8 -*-
require 'test/unit'
-case ENV['JSON']
-when 'pure' then require 'json/pure'
-when 'ext' then require 'json/ext'
-else require 'json'
-end
+require File.join(File.dirname(__FILE__), 'setup_variant')
class TC_JSONUnicode < Test::Unit::TestCase
include JSON