summaryrefslogtreecommitdiff
path: root/test/fileutils
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-01 02:09:42 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-01 02:09:42 +0000
commit874f8c0494b186406dba339a81b6dcce7fb7c429 (patch)
tree34712e954cddee0a909df4c5cb76d4f77e3615e1 /test/fileutils
parent6213b8370c54bed04b6f9901cd89e9a6fa08557a (diff)
* lib/fileutils.rb: Revert r34669 which altered the way
metaprogramming in FileUtils occurred. [ruby-trunk - Bug #7958] * test/fileutils/visibility_tests.rb: Refactored tests of FileUtils options modules to expose bug found in #7958 * test/fileutils/test_dryrun.rb: ditto. * test/fileutils/test_nowrite.rb: ditto. * test/fileutils/test_verbose.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils')
-rw-r--r--test/fileutils/test_dryrun.rb21
-rw-r--r--test/fileutils/test_nowrite.rb21
-rw-r--r--test/fileutils/test_verbose.rb19
-rw-r--r--test/fileutils/visibility_tests.rb41
4 files changed, 56 insertions, 46 deletions
diff --git a/test/fileutils/test_dryrun.rb b/test/fileutils/test_dryrun.rb
index f467277..03f6bed 100644
--- a/test/fileutils/test_dryrun.rb
+++ b/test/fileutils/test_dryrun.rb
@@ -2,27 +2,16 @@
require 'fileutils'
require 'test/unit'
-require_relative 'clobber'
+require_relative 'visibility_tests'
class TestFileUtilsDryRun < Test::Unit::TestCase
include FileUtils::DryRun
- include TestFileUtils::Clobber
+ include TestFileUtils::Visibility
- FileUtils::METHODS.each do |m|
- define_method "test_singleton_visibility_#{m}" do
- assert_equal true, FileUtils::DryRun.respond_to?(m, true),
- "FileUtils::DryRun.#{m} not defined"
- assert_equal true, FileUtils::DryRun.respond_to?(m, false),
- "FileUtils::DryRun.#{m} not public"
- end
-
- define_method "test_instance_visibility_#{m}" do
- assert_equal true, respond_to?(m, true),
- "FileUtils::DryRun\##{m} is not defined"
- assert_equal true, FileUtils::DryRun.private_method_defined?(m),
- "FileUtils::DryRun\##{m} is not private"
- end
+ def setup
+ super
+ @fu_module = FileUtils::DryRun
end
end
diff --git a/test/fileutils/test_nowrite.rb b/test/fileutils/test_nowrite.rb
index 002f256..946eed3 100644
--- a/test/fileutils/test_nowrite.rb
+++ b/test/fileutils/test_nowrite.rb
@@ -2,27 +2,16 @@
require 'fileutils'
require 'test/unit'
-require_relative 'clobber'
+require_relative 'visibility_tests'
class TestFileUtilsNoWrite < Test::Unit::TestCase
include FileUtils::NoWrite
- include TestFileUtils::Clobber
+ include TestFileUtils::Visibility
- FileUtils::METHODS.each do |m|
- define_method "test_singleton_visibility_#{m}" do
- assert_equal true, FileUtils::NoWrite.respond_to?(m, true),
- "FileUtils::NoWrite.#{m} is not defined"
- assert_equal true, FileUtils::NoWrite.respond_to?(m, false),
- "FileUtils::NoWrite.#{m} is not public"
- end
-
- define_method "test_instance_visibility_#{m}" do
- assert_equal true, respond_to?(m, true),
- "FileUtils::NoWrite\##{m} is not defined"
- assert_equal true, FileUtils::NoWrite.private_method_defined?(m),
- "FileUtils::NoWrite\##{m} is not private"
- end
+ def setup
+ super
+ @fu_module = FileUtils::NoWrite
end
end
diff --git a/test/fileutils/test_verbose.rb b/test/fileutils/test_verbose.rb
index cf46fa9..fb069bc 100644
--- a/test/fileutils/test_verbose.rb
+++ b/test/fileutils/test_verbose.rb
@@ -2,25 +2,16 @@
require 'test/unit'
require 'fileutils'
+require_relative 'visibility_tests'
class TestFileUtilsVerbose < Test::Unit::TestCase
include FileUtils::Verbose
+ include TestFileUtils::Visibility
- FileUtils::METHODS.each do |m|
- define_method "test_singleton_visibility_#{m}" do
- assert_equal true, FileUtils::Verbose.respond_to?(m, true),
- "FileUtils::Verbose.#{m} is not defined"
- assert_equal true, FileUtils::Verbose.respond_to?(m, false),
- "FileUtils::Verbose.#{m} is not public"
- end
-
- define_method "test_visibility_#{m}" do
- assert_equal true, respond_to?(m, true),
- "FileUtils::Verbose\##{m} is not defined"
- assert_equal true, FileUtils::Verbose.private_method_defined?(m),
- "FileUtils::Verbose\##{m} is not private"
- end
+ def setup
+ super
+ @fu_module = FileUtils::Verbose
end
end
diff --git a/test/fileutils/visibility_tests.rb b/test/fileutils/visibility_tests.rb
new file mode 100644
index 0000000..a140614
--- /dev/null
+++ b/test/fileutils/visibility_tests.rb
@@ -0,0 +1,41 @@
+require 'test/unit'
+require 'fileutils'
+
+class TestFileUtils < Test::Unit::TestCase
+end
+
+##
+# These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and
+# FileUtils::DryRun tests
+
+module TestFileUtils::Visibility
+
+ FileUtils::METHODS.each do |m|
+ define_method "test_singleton_visibility_#{m}" do
+ assert @fu_module.respond_to?(m, true),
+ "FileUtils::Verbose.#{m} is not defined"
+ assert @fu_module.respond_to?(m, false),
+ "FileUtils::Verbose.#{m} is not public"
+ end
+
+ define_method "test_visibility_#{m}" do
+ assert respond_to?(m, true),
+ "FileUtils::Verbose\##{m} is not defined"
+ assert @fu_module.private_method_defined?(m),
+ "FileUtils::Verbose\##{m} is not private"
+ end
+ end
+
+ FileUtils::StreamUtils_.private_instance_methods.each do |m|
+ define_method "test_singleton_visibility_#{m}" do
+ assert @fu_module.respond_to?(m, true),
+ "FileUtils::Verbose\##{m} is not defined"
+ end
+
+ define_method "test_visibility_#{m}" do
+ assert respond_to?(m, true),
+ "FileUtils::Verbose\##{m} is not defined"
+ end
+ end
+
+end