Skip to content

Commit

Permalink
defaulting configuration for local tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancalhoun committed Apr 2, 2016
1 parent d9a9ead commit 4e2cb82
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/cppunit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -33,15 +33,15 @@ 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
}
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 4e2cb82

Please sign in to comment.