Skip to content

Commit

Permalink
Adding ruby_test tests into test suite...sorry guys, this makes it lo…
Browse files Browse the repository at this point in the history
…nger again, but we'll find a way to speed the test run soon.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@3818 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Jun 1, 2007
1 parent a7189ef commit bdbb7e5
Show file tree
Hide file tree
Showing 394 changed files with 20,136 additions and 0 deletions.
115 changes: 115 additions & 0 deletions test/externals/ruby_test/README
@@ -0,0 +1,115 @@
== Description
This is a custom test suite for Ruby. It includes tests for both the
core classes and the stdlib.

== Prerequisites
Rake. Version 0.7.2 or later recommended. Earlier versions will delete
the core directory by mistake if you use the 'clean' task, thinking it's
a coredump file.

== Conventions

=== Directory Layout

bench - toplevel directory for all benchmarks

bench/core - toplevel directory for benchmarks of core Ruby methods.
bench/stdlib - toplevel directory for benchmarks of libraries in the stdlib.
test/core - toplevel directory for tests of core Ruby classes.
test/stdlib - toplevel directory for tests of stdlib.
test/lib - contains helper modules that can be used in your test cases.

Under test/core there is a folder for each of the core classes. Under
those folders are one or two subdirectories - 'class' and/or 'instance'.

Under the 'class' folders are the tests for the class methods of the class
in question. Under the 'instance' folders are the tests for the instance
methods of the class in question, if applicable.

=== Test suites
The test program shall be test/unit, by Nathaniel Talbott.

All test files shall start with "tc_", and end with the name of the method,
or an analogue based on the internal method name, e.g. "aref" to refer to
Array#[].

All test class names shall start with "TC_", followed by the class name,
followed by the class or instance method (capitalized), followed by the word
"Class", or "Instance", as appropriate.
- Since writing this, I have changed it to 'ClassMethod' and
'InstanceMethod' instead. So, for the moment, you will see both approaches.

For example, TC_Dir_Getwd_ClassMethod < Test::Unit::TestCase

You can optionally use the Test::Helper module to alleviate some of the
mundane tasks, such as getting the user's name, home directory, setting
the base directory, etc.

Running the tests should be handled via tasks in the Rakefile. Some tests
skipped on certain platforms. Other tests are skipped unless you run the
tests as root. Still others are skipped for alternate implementations, such
as JRuby.

== Testing guidelines for writers
One test per method for the core classes.
- Exception: bang and non-bang methods can be grouped together, as well
as aliases.
Comment your tests as appropriate.
Test basic functionality using most likely real world uses.
Test for expected errors.
Test edge cases (nil, 0, true, false).
Go out of your way to break things. :)

== Coding guidelines for writers
Three space indentation.
Tabs to spaces always.
Meaningful test names.
Avoid tests that depend on other tests.
Always reset your instance variables to nil in the teardown method.

== Benchmark suites
The benchmark program shall be "benchmark", the library that comes bundled
as part of the Ruby standard library.

All benchmark programs shall start with "bench_", and end with the name of
the class. There shall be one benchmark program per class, although
benchmark suites are also allowed per method, if desired. I have created
a few method benchmarks in order to compare changes to the C source with
original source code.

== Notes on the Benchmark suite
The purpose of the benchmark suite is to determine overall speed, do speed
comparisons between minor releases, high iteration testing, look for any
pathological slowdowns, and find methods that can be optimized.

== Running the tests
Use the Rake tasks to run the various tests. You can run the invidiual
test suites by using the name of the class or package, e.g. 'rake
test_array'.

To perform all core tests run 'rake test_core'. Likewise, to perform all
of the stdlib tests run 'rake test_stdlib'.

To perform all tests run 'rake test'.

== On JRuby
As of 25-May-2007 I've decided to go ahead and tailor some of the tests
for JRuby. This is easy enough to do by checking the value of the JRUBY
constant (defined in the Test::Helper module), and usually just means
skipping the posix methods, e.g. Process.wait, etc.

== Acknowledgements
Some tests shamelessly plagiarized from rubicon or bfts.

== License
Ruby's

== Warranty
This package is provided "as is" and without any express or
implied warranties, including, without limitation, the implied
warranties of merchantability and fitness for a particular purpose.

== Author
Daniel J. Berger
djberg96 at gmail dot com
imperator on IRC (irc.freenode.net)
250 changes: 250 additions & 0 deletions test/externals/ruby_test/Rakefile
@@ -0,0 +1,250 @@
require 'rake'
require 'rake/testtask'

desc "Runs the test suite for the core classes"
Rake::TestTask.new('test_core') do |t|
t.test_files = FileList['test/core/**/tc*']
t.warning = true
end

desc "Runs the test suite for the Array class"
Rake::TestTask.new('test_array') do |t|
t.test_files = FileList['test/core/Array/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Bignum class"
Rake::TestTask.new('test_bignum') do |t|
t.test_files = FileList['test/core/Bignum/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Binding class"
Rake::TestTask.new('test_binding') do |t|
t.test_files = FileList['test/core/Binding/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Class module"
Rake::TestTask.new('test_class') do |t|
t.test_files = FileList['test/core/Class/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Comparable module"
Rake::TestTask.new('test_comparable') do |t|
t.test_files = FileList['test/core/Comparable/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Dir class"
Rake::TestTask.new('test_dir') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/Dir/*/*.rb']
end

desc "Runs the test suite for the Enumerable class"
Rake::TestTask.new('test_enumerable') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/Enumerable/*/*.rb']
end

desc "Runs the test suite for the FalseClass class"
Rake::TestTask.new('test_false') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/FalseClass/*/*.rb']
end

desc "Runs the test suite for the File class"
Rake::TestTask.new('test_file') do |t|
t.libs << 'lib'
t.warning = true
if defined? JRUBY_VERSION
files = [
'test/core/File/class/tc_basename.rb',
'test/core/File/class/tc_constants.rb',
'test/core/File/class/tc_delete.rb',
'test/core/File/class/tc_directory.rb',
'test/core/File/class/tc_dirname.rb',
'test/core/File/class/tc_exist.rb',
'test/core/File/class/tc_expand_path.rb',
'test/core/File/class/tc_extname.rb',
'test/core/File/class/tc_expand_path.rb',
'test/core/File/class/tc_file.rb',
'test/core/File/class/tc_join.rb',
'test/core/File/class/tc_new.rb',
'test/core/File/class/tc_size.rb',
'test/core/File/class/tc_split.rb',
'test/core/File/class/tc_zero.rb',
]
else
files = FileList['test/core/File/*/*.rb']
end
t.test_files = files
end

desc "Runs the test suite for the File::Stat class"
Rake::TestTask.new('test_file_stat') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/FileStat/*/*.rb']
end

desc "Runs the test suite for the Fixnum class"
Rake::TestTask.new('test_fixnum') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/Fixnum/*/*.rb']
end

desc "Runs the test suite for the Float class"
Rake::TestTask.new('test_float') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/Float/*/*.rb']
end

desc "Runs the test suite for the Hash class"
Rake::TestTask.new('test_hash') do |t|
t.test_files = FileList['test/core/Hash/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Integer class"
Rake::TestTask.new('test_integer') do |t|
t.test_files = FileList['test/core/Integer/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the IO class"
Rake::TestTask.new('test_io') do |t|
t.test_files = FileList['test/core/IO/*/*.rb']
t.verbose = true
t.warning = true
end

desc "Runs the test suite for the Math module"
Rake::TestTask.new('test_math') do |t|
t.test_files = FileList['test/core/Math/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Module object"
Rake::TestTask.new('test_module') do |t|
t.test_files = FileList['test/core/Module/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the NilClass class"
Rake::TestTask.new('test_nil') do |t|
t.test_files = FileList['test/core/NilClass/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Numeric class"
Rake::TestTask.new('test_numeric') do |t|
t.test_files = FileList['test/core/Numeric/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the ObjectSpace class"
Rake::TestTask.new('test_objectspace') do |t|
t.test_files = FileList['test/core/ObjectSpace/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Process module"
Rake::TestTask.new('test_process') do |t|
t.test_files = FileList['test/core/Process/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Process::GID module"
Rake::TestTask.new('test_process_gid') do |t|
t.test_files = FileList['test/core/ProcessGID/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Process::Sys module"
Rake::TestTask.new('test_process_sys') do |t|
t.test_files = FileList['test/core/ProcessSys/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Process::UID module"
Rake::TestTask.new('test_process_uid') do |t|
t.test_files = FileList['test/core/ProcessUID/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Range class"
Rake::TestTask.new('test_range') do |t|
t.test_files = FileList['test/core/Range/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the String class"
Rake::TestTask.new('test_string') do |t|
t.test_files = FileList['test/core/String/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the Struct class"
Rake::TestTask.new('test_struct') do |t|
t.test_files = FileList['test/core/Struct/*/*.rb']
t.warning = true
end

desc "Runs the test suite for the TrueClass class"
Rake::TestTask.new('test_true') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/core/TrueClass/*/*.rb']
end

## Test tasks for the stdlib ##

desc "Run the test suite for all stdlib packages"
Rake::TestTask.new('test_stdlib') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/*/*.rb']
end

desc "Run the test suite for the English package"
Rake::TestTask.new('test_english') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/English/*.rb']
end

desc "Run the test suite for the Pathname package"
Rake::TestTask.new('test_pathname') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/Pathname/*.rb']
end

desc "Run the test suite for the Rational package"
Rake::TestTask.new('test_rational') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/Rational/*.rb']
end

desc "Run the test suite for the Set package"
Rake::TestTask.new('test_set') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/Set/*.rb']
end

desc "Run the test suite for the Socket package"
Rake::TestTask.new('test_socket') do |t|
t.libs << 'lib'
t.warning = true
t.test_files = FileList['test/stdlib/Socket/*.rb']
end
27 changes: 27 additions & 0 deletions test/externals/ruby_test/SCORECARD
@@ -0,0 +1,27 @@
= A list of bugs and other things discovered as a result of this test suite.

== Bugs
* Dir.chdir and '/'. See ruby-core: 8914.
* String#slice! documentation. See ruby-core: 9754.
* String#upto infinite loop bug. See ruby-core: 9864.
* Process::GID#eid= and Process::UID#eid= aliases. See ruby-core: 11022.

== Quirks, Inconsistencies and Other Stuff
* Math.atanh(1), and similar edge cases, raise different errors on different
platforms (ERANGE vs EDOM). On MS Windows, no error is raised and Infinity
is returned instead. See ruby-core: 10174.
* Some methods raise ArgumentError when they probably ought to return
TypeError. Ruby is inconsistent on this, even within the same method. For
example, ['test'].pack('C') raises a TypeError, while ['test'].pack('D')
raises an ArgumentError. Many of these can be traced to the Integer() and
Float() kernel methods.
* Some methods, such as File.join, allow you pass no arguments when they
probably ought to check for 0 arguments and raise an ArgumentError. At the
moment they're just no-ops.
* The chsize() function in MS VC++ 6.0 has a bug where it does not raise an
error if you pass a negative value for the size argument. This affects the
File.truncate method, i.e. it's a no-op instead of raising an error. MS
VC++ 8.0 fixes this bug.
* Problems with File and File::Stat caused by an underlying bug in the
Solaris stat() function, where the st_size member wasn't set properly.
See ruby-core: 9926.

0 comments on commit bdbb7e5

Please sign in to comment.