From 9b1e8d55363aa67e9e981b7977ed6eded8026b68 Mon Sep 17 00:00:00 2001 From: lutter Date: Fri, 31 Mar 2006 01:29:54 +0000 Subject: Accept a single file as a test to run in addition to a directory git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1046 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/puppettest.rb | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/puppettest.rb b/test/puppettest.rb index a8af679fb..8bcef7faa 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -890,24 +890,26 @@ class PuppetTestSuite def initialize(name) path = File.join(self.class.basedir, name) - unless FileTest.directory?(path) - puts "TestSuites are directories containing test cases" + if FileTest.directory?(path) + # load each of the files + Dir.entries(path).collect { |file| + File.join(path,file) + }.find_all { |file| + FileTest.file?(file) and file =~ /\.rb$/ + }.sort { |a,b| + # in the order they were modified, so the last modified files + # are loaded and thus displayed last + File.stat(b) <=> File.stat(a) + }.each { |file| + require file + } + elsif FileTest.file?(path) && path =~ /\.rb$/ + require path + else + puts "TestSuites are directories or files containing test cases" puts "no such directory: %s" % path exit(65) end - - # load each of the files - Dir.entries(path).collect { |file| - File.join(path,file) - }.find_all { |file| - FileTest.file?(file) and file =~ /\.rb$/ - }.sort { |a,b| - # in the order they were modified, so the last modified files - # are loaded and thus displayed last - File.stat(b) <=> File.stat(a) - }.each { |file| - require file - } end end -- cgit