Explorar o código

Merge pull request #703 from infosiftr/improve-ruby-stdlib-test

Improve the "ruby-standard-libs" test, especially with regards to jruby-specific exclusion and failure output
yosifkit %!s(int64=10) %!d(string=hai) anos
pai
achega
c115a82742
Modificáronse 1 ficheiros con 25 adicións e 6 borrados
  1. 25 6
      test/tests/ruby-standard-libs/container.rb

+ 25 - 6
test/tests/ruby-standard-libs/container.rb

@@ -8,7 +8,7 @@ stdlib = [
 	'coverage',
 	'csv',
 	'date',
-#	'dbm', 'gdbm', # TODO figure out a way to make this one load conditionally based on whether we're _not_ on jruby (since jruby doesn't have dbm)
+	'dbm',
 	'delegate',
 	'digest',
 	'drb',
@@ -21,6 +21,7 @@ stdlib = [
 	'fileutils',
 	'find',
 	'forwardable',
+	'gdbm',
 	'getoptlong',
 	'io/console',
 	'io/nonblock',
@@ -52,8 +53,7 @@ stdlib = [
 	'pp',
 	'prettyprint',
 	'prime',
-# prints all sorts of info to stderr, not easy to test right now
-#	'profile',
+	#'profile', # prints all sorts of info to stderr, not easy to test right now
 	'profiler',
 	'pstore',
 	'psych',
@@ -93,12 +93,31 @@ stdlib = [
 	'xmlrpc/client',
 	'xmlrpc/server',
 	'yaml',
-	'zlib'
+	'zlib',
 ]
 
+if defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
+	# these libraries don't work or don't exist on JRuby ATM
+	stdlib.delete('dbm')
+	stdlib.delete('gdbm')
+	stdlib.delete('mkmf')
+	stdlib.delete('objspace')
+	stdlib.delete('sdbm')
+end
+
+result = 'ok'
 stdlib.each do |lib|
 	#puts "Testing #{lib}"
-	require lib
+	begin
+		require lib
+	rescue Exception => e
+		result = 'failure'
+		STDERR.puts "\n\nrequire '#{lib}' failed: #{e.message}\n"
+		STDERR.puts e.backtrace.join("\n")
+		STDERR.puts "\n"
+	end
 end
 
-puts 'ok'
+exit(1) unless result == 'ok'
+
+puts result