From 4e2cb827fdd8914da247f9d00dc2101d58005299 Mon Sep 17 00:00:00 2001 From: Ryan Calhoun Date: Sat, 2 Apr 2016 10:23:08 -0700 Subject: [PATCH] defaulting configuration for local tests --- test/cppunit_test.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/cppunit_test.rb b/test/cppunit_test.rb index 3bc5e8a..5de5965 100644 --- a/test/cppunit_test.rb +++ b/test/cppunit_test.rb @@ -4,7 +4,7 @@ class CppUnitTest < Test::Unit::TestCase def testCppUnit - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { output = `./cppunit_test` assert_equal 1, $?.exitstatus assert_match /^[\.FE]+$/, output @@ -13,7 +13,7 @@ def testCppUnit end def testCppUnitVersion - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-v --version).each {|opt| output = `./cppunit_test #{opt}` assert_equal 0, $?.exitstatus @@ -23,7 +23,7 @@ def testCppUnitVersion end def testCppUnitHelp - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-h --help).each {|opt| output = `./cppunit_test #{opt}` assert_equal 0, $?.exitstatus @@ -33,7 +33,7 @@ def testCppUnitHelp end def testCppUnitBadOption - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { output, error, status = Open3.capture3 './cppunit_test -X' assert_equal 1, status.exitstatus assert_match /invalid option -X/, error @@ -41,7 +41,7 @@ def testCppUnitBadOption end def testCppUnitDisableProgress - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-p --no-print-progress).each {|opt| output = `./cppunit_test #{opt}` assert_equal 1, $?.exitstatus @@ -52,7 +52,7 @@ def testCppUnitDisableProgress end def testCppUnitDisableResult - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-r --no-print-result).each {|opt| output = `./cppunit_test #{opt}` assert_equal 1, $?.exitstatus @@ -63,7 +63,7 @@ def testCppUnitDisableResult end def testCppUnitVerbose - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-V --verbose).each {|opt| output = `./cppunit_test #{opt}` assert_equal 1, $?.exitstatus @@ -74,7 +74,7 @@ def testCppUnitVerbose end def testCppUnitXml - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { %w(-x --xml-output).each {|opt| output = `./cppunit_test #{opt}` assert_equal 1, $?.exitstatus @@ -86,7 +86,7 @@ def testCppUnitXml end def testCppUnitByName - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { output = `./cppunit_test -V FooTest` assert_equal 1, $?.exitstatus assert_match /FooTest/, output @@ -102,11 +102,15 @@ def testCppUnitByName end def testCppUnitByMethod - Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) { + Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', configuration.to_s)) { output = `./cppunit_test -V FooTest::testOk` assert_equal 0, $?.exitstatus assert_match /FooTest::testOk/, output assert_match /OK\s+\(1\stests\)/, output } end + + def configuration + ENV['CONFIGURAtION'] || 'Debug' + end end