From d201456903f3ecae1f7794edfab0d5678e642265 Mon Sep 17 00:00:00 2001 From: shiqian Date: Thu, 3 Jul 2008 22:38:12 +0000 Subject: Initial import. --- test/gtest_uninitialized_test.py | 110 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 test/gtest_uninitialized_test.py (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py new file mode 100755 index 00000000..1956a7b9 --- /dev/null +++ b/test/gtest_uninitialized_test.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# +# Copyright 2008, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Verifies that Google Test warns the user when not initialized properly.""" + +__author__ = 'wan@google.com (Zhanyong Wan)' + +import gtest_test_utils +import os +import sys +import unittest + +IS_WINDOWS = os.name == 'nt' +IS_LINUX = os.name == 'posix' + +if IS_WINDOWS: + BUILD_DIRS = [ + 'build.dbg\\', + 'build.opt\\', + 'build.dbg8\\', + 'build.opt8\\', + ] + COMMAND = 'gtest_uninitialized_test_.exe' + +if IS_LINUX: + COMMAND = os.path.join(gtest_test_utils.GetBuildDir(), + 'gtest_uninitialized_test_') + + +def Assert(condition): + if not condition: + raise AssertionError + + +def AssertEq(expected, actual): + if expected != actual: + print 'Expected: %s' % (expected,) + print ' Actual: %s' % (actual,) + raise AssertionError + + +def GetOutput(command): + """Runs the given command and returns its output.""" + + stdin, stdout = os.popen2(command, 't') + stdin.close() + output = stdout.read() + stdout.close() + return output + + +def TestExitCodeAndOutput(command): + """Runs the given command and verifies its exit code and output.""" + + # 256 corresponds to return code 0. + AssertEq(256, os.system(command)) + output = GetOutput(command) + Assert('InitGoogleTest' in output) + + +if IS_WINDOWS: + + def main(): + for build_dir in BUILD_DIRS: + command = build_dir + COMMAND + print 'Testing with %s . . .' % (command,) + TestExitCodeAndOutput(command) + return 0 + + if __name__ == '__main__': + main() + + +if IS_LINUX: + + class GTestUninitializedTest(unittest.TestCase): + def testExitCodeAndOutput(self): + TestExitCodeAndOutput(COMMAND) + + + if __name__ == '__main__': + gtest_test_utils.Main() -- cgit v1.2.3 From e4e9a8bd7d2dbbad62030c8f80513e3c81b32213 Mon Sep 17 00:00:00 2001 From: shiqian Date: Tue, 8 Jul 2008 21:32:17 +0000 Subject: Makes the autotools scripts work on Mac OS X. Also hopefully makes gtest compile on Windows CE. --- test/gtest_uninitialized_test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py index 1956a7b9..d553bbf9 100755 --- a/test/gtest_uninitialized_test.py +++ b/test/gtest_uninitialized_test.py @@ -80,8 +80,15 @@ def GetOutput(command): def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" - # 256 corresponds to return code 0. - AssertEq(256, os.system(command)) + # Verifies that 'command' exits with code 1. + if IS_WINDOWS: + # On Windows, os.system(command) returns the exit code of 'command'. + AssertEq(1, os.system(command)) + else: + # On Unix-like system, os.system(command) returns 256 times the + # exit code of 'command'. + AssertEq(256, os.system(command)) + output = GetOutput(command) Assert('InitGoogleTest' in output) -- cgit v1.2.3 From e79c3ccb73d68543e8ad98d69179dee74abff7ab Mon Sep 17 00:00:00 2001 From: shiqian Date: Thu, 18 Sep 2008 21:18:11 +0000 Subject: Makes the Python tests more portable by calling standard functions to interpret the result of os.system(). This could fix the broken Python tests on some users' machines. --- test/gtest_uninitialized_test.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py index d553bbf9..037daa8f 100755 --- a/test/gtest_uninitialized_test.py +++ b/test/gtest_uninitialized_test.py @@ -81,13 +81,7 @@ def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" # Verifies that 'command' exits with code 1. - if IS_WINDOWS: - # On Windows, os.system(command) returns the exit code of 'command'. - AssertEq(1, os.system(command)) - else: - # On Unix-like system, os.system(command) returns 256 times the - # exit code of 'command'. - AssertEq(256, os.system(command)) + AssertEq(1, gtest_test_utils.GetExitStatus(os.system(command))) output = GetOutput(command) Assert('InitGoogleTest' in output) -- cgit v1.2.3 From 957ed9fb5210a8e0e51f713387961d2538921aed Mon Sep 17 00:00:00 2001 From: vladlosev Date: Wed, 26 Nov 2008 20:06:52 +0000 Subject: Adding test/gtest_uninitialized_test.py missing from the previous check-in --- test/gtest_uninitialized_test.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py index 037daa8f..a3ba629c 100755 --- a/test/gtest_uninitialized_test.py +++ b/test/gtest_uninitialized_test.py @@ -67,24 +67,14 @@ def AssertEq(expected, actual): raise AssertionError -def GetOutput(command): - """Runs the given command and returns its output.""" - - stdin, stdout = os.popen2(command, 't') - stdin.close() - output = stdout.read() - stdout.close() - return output - - def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" # Verifies that 'command' exits with code 1. - AssertEq(1, gtest_test_utils.GetExitStatus(os.system(command))) - - output = GetOutput(command) - Assert('InitGoogleTest' in output) + p = gtest_test_utils.Subprocess(command) + Assert(p.exited) + AssertEq(1, p.exit_code) + Assert('InitGoogleTest' in p.output) if IS_WINDOWS: -- cgit v1.2.3 From 7fa242a44b47ce74d7246440b14571f7a5dd1b17 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 9 Apr 2009 02:57:38 +0000 Subject: Makes the Python tests more stable (by Vlad Losev); fixes a memory leak in GetThreadCount() on Mac (by Vlad Losev); improves fuse_gtest_files.py to support fusing Google Mock files (by Zhanyong Wan). --- test/gtest_uninitialized_test.py | 41 ++++++---------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py index a3ba629c..19b92e90 100755 --- a/test/gtest_uninitialized_test.py +++ b/test/gtest_uninitialized_test.py @@ -34,25 +34,11 @@ __author__ = 'wan@google.com (Zhanyong Wan)' import gtest_test_utils -import os import sys import unittest -IS_WINDOWS = os.name == 'nt' -IS_LINUX = os.name == 'posix' -if IS_WINDOWS: - BUILD_DIRS = [ - 'build.dbg\\', - 'build.opt\\', - 'build.dbg8\\', - 'build.opt8\\', - ] - COMMAND = 'gtest_uninitialized_test_.exe' - -if IS_LINUX: - COMMAND = os.path.join(gtest_test_utils.GetBuildDir(), - 'gtest_uninitialized_test_') +COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') def Assert(condition): @@ -77,25 +63,10 @@ def TestExitCodeAndOutput(command): Assert('InitGoogleTest' in p.output) -if IS_WINDOWS: - - def main(): - for build_dir in BUILD_DIRS: - command = build_dir + COMMAND - print 'Testing with %s . . .' % (command,) - TestExitCodeAndOutput(command) - return 0 - - if __name__ == '__main__': - main() - - -if IS_LINUX: - - class GTestUninitializedTest(unittest.TestCase): - def testExitCodeAndOutput(self): - TestExitCodeAndOutput(COMMAND) +class GTestUninitializedTest(unittest.TestCase): + def testExitCodeAndOutput(self): + TestExitCodeAndOutput(COMMAND) - if __name__ == '__main__': - gtest_test_utils.Main() +if __name__ == '__main__': + gtest_test_utils.Main() -- cgit v1.2.3 From 532dc2de35f2cef191bc91c3587a9f8f4974756f Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 17 Jun 2009 21:06:27 +0000 Subject: Implements a subset of TR1 tuple needed by gtest and gmock (by Zhanyong Wan); cleaned up the Python tests (by Vlad Losev); made run_tests.py invokable from any directory (by Vlad Losev). --- test/gtest_uninitialized_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'test/gtest_uninitialized_test.py') diff --git a/test/gtest_uninitialized_test.py b/test/gtest_uninitialized_test.py index 19b92e90..6ae57eee 100755 --- a/test/gtest_uninitialized_test.py +++ b/test/gtest_uninitialized_test.py @@ -34,8 +34,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)' import gtest_test_utils -import sys -import unittest COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') @@ -63,7 +61,7 @@ def TestExitCodeAndOutput(command): Assert('InitGoogleTest' in p.output) -class GTestUninitializedTest(unittest.TestCase): +class GTestUninitializedTest(gtest_test_utils.TestCase): def testExitCodeAndOutput(self): TestExitCodeAndOutput(COMMAND) -- cgit v1.2.3