Googletest export
Remove deprecated/unsupported scripts PiperOrigin-RevId: 389873391
This commit is contained in:
parent
eb7e38dfb4
commit
47f819c3ca
@ -1,5 +0,0 @@
|
||||
# Please Note:
|
||||
|
||||
Files in this directory are no longer supported by the maintainers. They
|
||||
represent mosty historical artifacts and supported by the community only. There
|
||||
is no guarantee whatsoever that these scripts still work.
|
@ -1,83 +0,0 @@
|
||||
# Copyright 2013 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.
|
||||
|
||||
"""Shared utilities for writing scripts for Google Test/Mock."""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
# Matches the line from 'svn info .' output that describes what SVN
|
||||
# path the current local directory corresponds to. For example, in
|
||||
# a googletest SVN workspace's trunk/test directory, the output will be:
|
||||
#
|
||||
# URL: https://googletest.googlecode.com/svn/trunk/test
|
||||
_SVN_INFO_URL_RE = re.compile(r'^URL: https://(\w+)\.googlecode\.com/svn(.*)')
|
||||
|
||||
|
||||
def GetCommandOutput(command):
|
||||
"""Runs the shell command and returns its stdout as a list of lines."""
|
||||
|
||||
f = os.popen(command, 'r')
|
||||
lines = [line.strip() for line in f.readlines()]
|
||||
f.close()
|
||||
return lines
|
||||
|
||||
|
||||
def GetSvnInfo():
|
||||
"""Returns the project name and the current SVN workspace's root path."""
|
||||
|
||||
for line in GetCommandOutput('svn info .'):
|
||||
m = _SVN_INFO_URL_RE.match(line)
|
||||
if m:
|
||||
project = m.group(1) # googletest or googlemock
|
||||
rel_path = m.group(2)
|
||||
root = os.path.realpath(rel_path.count('/') * '../')
|
||||
return project, root
|
||||
|
||||
return None, None
|
||||
|
||||
|
||||
def GetSvnTrunk():
|
||||
"""Returns the current SVN workspace's trunk root path."""
|
||||
|
||||
_, root = GetSvnInfo()
|
||||
return root + '/trunk' if root else None
|
||||
|
||||
|
||||
def IsInGTestSvn():
|
||||
project, _ = GetSvnInfo()
|
||||
return project == 'googletest'
|
||||
|
||||
|
||||
def IsInGMockSvn():
|
||||
project, _ = GetSvnInfo()
|
||||
return project == 'googlemock'
|
@ -1,253 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009, 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.
|
||||
|
||||
"""fuse_gtest_files.py v0.2.0
|
||||
Fuses Google Test source code into a .h file and a .cc file.
|
||||
|
||||
SYNOPSIS
|
||||
fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR
|
||||
|
||||
Scans GTEST_ROOT_DIR for Google Test source code, and generates
|
||||
two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc.
|
||||
Then you can build your tests by adding OUTPUT_DIR to the include
|
||||
search path and linking with OUTPUT_DIR/gtest/gtest-all.cc. These
|
||||
two files contain everything you need to use Google Test. Hence
|
||||
you can "install" Google Test by copying them to wherever you want.
|
||||
|
||||
GTEST_ROOT_DIR can be omitted and defaults to the parent
|
||||
directory of the directory holding this script.
|
||||
|
||||
EXAMPLES
|
||||
./fuse_gtest_files.py fused_gtest
|
||||
./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest
|
||||
|
||||
This tool is experimental. In particular, it assumes that there is no
|
||||
conditional inclusion of Google Test headers. Please report any
|
||||
problems to googletestframework@googlegroups.com. You can read
|
||||
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md for
|
||||
more information.
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import re
|
||||
try:
|
||||
from sets import Set as set # For Python 2.3 compatibility
|
||||
except ImportError:
|
||||
pass
|
||||
import sys
|
||||
|
||||
# We assume that this file is in the scripts/ directory in the Google
|
||||
# Test root directory.
|
||||
DEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
|
||||
|
||||
# Regex for matching '#include "gtest/..."'.
|
||||
INCLUDE_GTEST_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(gtest/.+)"')
|
||||
|
||||
# Regex for matching '#include "src/..."'.
|
||||
INCLUDE_SRC_FILE_REGEX = re.compile(r'^\s*#\s*include\s*"(src/.+)"')
|
||||
|
||||
# Where to find the source seed files.
|
||||
GTEST_H_SEED = 'include/gtest/gtest.h'
|
||||
GTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h'
|
||||
GTEST_ALL_CC_SEED = 'src/gtest-all.cc'
|
||||
|
||||
# Where to put the generated files.
|
||||
GTEST_H_OUTPUT = 'gtest/gtest.h'
|
||||
GTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc'
|
||||
|
||||
|
||||
def VerifyFileExists(directory, relative_path):
|
||||
"""Verifies that the given file exists; aborts on failure.
|
||||
|
||||
relative_path is the file path relative to the given directory.
|
||||
"""
|
||||
|
||||
if not os.path.isfile(os.path.join(directory, relative_path)):
|
||||
print('ERROR: Cannot find %s in directory %s.' % (relative_path,
|
||||
directory))
|
||||
print('Please either specify a valid project root directory '
|
||||
'or omit it on the command line.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def ValidateGTestRootDir(gtest_root):
|
||||
"""Makes sure gtest_root points to a valid gtest root directory.
|
||||
|
||||
The function aborts the program on failure.
|
||||
"""
|
||||
|
||||
VerifyFileExists(gtest_root, GTEST_H_SEED)
|
||||
VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED)
|
||||
|
||||
|
||||
def VerifyOutputFile(output_dir, relative_path):
|
||||
"""Verifies that the given output file path is valid.
|
||||
|
||||
relative_path is relative to the output_dir directory.
|
||||
"""
|
||||
|
||||
# Makes sure the output file either doesn't exist or can be overwritten.
|
||||
output_file = os.path.join(output_dir, relative_path)
|
||||
if os.path.exists(output_file):
|
||||
# TODO(wan@google.com): The following user-interaction doesn't
|
||||
# work with automated processes. We should provide a way for the
|
||||
# Makefile to force overwriting the files.
|
||||
print('%s already exists in directory %s - overwrite it? (y/N) ' %
|
||||
(relative_path, output_dir))
|
||||
answer = sys.stdin.readline().strip()
|
||||
if answer not in ['y', 'Y']:
|
||||
print('ABORTED.')
|
||||
sys.exit(1)
|
||||
|
||||
# Makes sure the directory holding the output file exists; creates
|
||||
# it and all its ancestors if necessary.
|
||||
parent_directory = os.path.dirname(output_file)
|
||||
if not os.path.isdir(parent_directory):
|
||||
os.makedirs(parent_directory)
|
||||
|
||||
|
||||
def ValidateOutputDir(output_dir):
|
||||
"""Makes sure output_dir points to a valid output directory.
|
||||
|
||||
The function aborts the program on failure.
|
||||
"""
|
||||
|
||||
VerifyOutputFile(output_dir, GTEST_H_OUTPUT)
|
||||
VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT)
|
||||
|
||||
|
||||
def FuseGTestH(gtest_root, output_dir):
|
||||
"""Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
|
||||
|
||||
output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
|
||||
processed_files = set() # Holds all gtest headers we've processed.
|
||||
|
||||
def ProcessFile(gtest_header_path):
|
||||
"""Processes the given gtest header file."""
|
||||
|
||||
# We don't process the same header twice.
|
||||
if gtest_header_path in processed_files:
|
||||
return
|
||||
|
||||
processed_files.add(gtest_header_path)
|
||||
|
||||
# Reads each line in the given gtest header.
|
||||
for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):
|
||||
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
||||
if m:
|
||||
# It's '#include "gtest/..."' - let's process it recursively.
|
||||
ProcessFile('include/' + m.group(1))
|
||||
else:
|
||||
# Otherwise we copy the line unchanged to the output file.
|
||||
output_file.write(line)
|
||||
|
||||
ProcessFile(GTEST_H_SEED)
|
||||
output_file.close()
|
||||
|
||||
|
||||
def FuseGTestAllCcToFile(gtest_root, output_file):
|
||||
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
|
||||
|
||||
processed_files = set()
|
||||
|
||||
def ProcessFile(gtest_source_file):
|
||||
"""Processes the given gtest source file."""
|
||||
|
||||
# We don't process the same #included file twice.
|
||||
if gtest_source_file in processed_files:
|
||||
return
|
||||
|
||||
processed_files.add(gtest_source_file)
|
||||
|
||||
# Reads each line in the given gtest source file.
|
||||
for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
|
||||
m = INCLUDE_GTEST_FILE_REGEX.match(line)
|
||||
if m:
|
||||
if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
|
||||
# It's '#include "gtest/gtest-spi.h"'. This file is not
|
||||
# #included by "gtest/gtest.h", so we need to process it.
|
||||
ProcessFile(GTEST_SPI_H_SEED)
|
||||
else:
|
||||
# It's '#include "gtest/foo.h"' where foo is not gtest-spi.
|
||||
# We treat it as '#include "gtest/gtest.h"', as all other
|
||||
# gtest headers are being fused into gtest.h and cannot be
|
||||
# #included directly.
|
||||
|
||||
# There is no need to #include "gtest/gtest.h" more than once.
|
||||
if not GTEST_H_SEED in processed_files:
|
||||
processed_files.add(GTEST_H_SEED)
|
||||
output_file.write('#include "%s"\n' % (GTEST_H_OUTPUT,))
|
||||
else:
|
||||
m = INCLUDE_SRC_FILE_REGEX.match(line)
|
||||
if m:
|
||||
# It's '#include "src/foo"' - let's process it recursively.
|
||||
ProcessFile(m.group(1))
|
||||
else:
|
||||
output_file.write(line)
|
||||
|
||||
ProcessFile(GTEST_ALL_CC_SEED)
|
||||
|
||||
|
||||
def FuseGTestAllCc(gtest_root, output_dir):
|
||||
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
|
||||
|
||||
output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
|
||||
FuseGTestAllCcToFile(gtest_root, output_file)
|
||||
output_file.close()
|
||||
|
||||
|
||||
def FuseGTest(gtest_root, output_dir):
|
||||
"""Fuses gtest.h and gtest-all.cc."""
|
||||
|
||||
ValidateGTestRootDir(gtest_root)
|
||||
ValidateOutputDir(output_dir)
|
||||
|
||||
FuseGTestH(gtest_root, output_dir)
|
||||
FuseGTestAllCc(gtest_root, output_dir)
|
||||
|
||||
|
||||
def main():
|
||||
argc = len(sys.argv)
|
||||
if argc == 2:
|
||||
# fuse_gtest_files.py OUTPUT_DIR
|
||||
FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1])
|
||||
elif argc == 3:
|
||||
# fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
|
||||
FuseGTest(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
print(__doc__)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,730 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2006, 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.
|
||||
|
||||
"""gen_gtest_pred_impl.py v0.1
|
||||
|
||||
Generates the implementation of Google Test predicate assertions and
|
||||
accompanying tests.
|
||||
|
||||
Usage:
|
||||
|
||||
gen_gtest_pred_impl.py MAX_ARITY
|
||||
|
||||
where MAX_ARITY is a positive integer.
|
||||
|
||||
The command generates the implementation of up-to MAX_ARITY-ary
|
||||
predicate assertions, and writes it to file gtest_pred_impl.h in the
|
||||
directory where the script is. It also generates the accompanying
|
||||
unit test in file gtest_pred_impl_unittest.cc.
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
# Where this script is.
|
||||
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
||||
|
||||
# Where to store the generated header.
|
||||
HEADER = os.path.join(SCRIPT_DIR, '../include/gtest/gtest_pred_impl.h')
|
||||
|
||||
# Where to store the generated unit test.
|
||||
UNIT_TEST = os.path.join(SCRIPT_DIR, '../test/gtest_pred_impl_unittest.cc')
|
||||
|
||||
|
||||
def HeaderPreamble(n):
|
||||
"""Returns the preamble for the header file.
|
||||
|
||||
Args:
|
||||
n: the maximum arity of the predicate macros to be generated.
|
||||
"""
|
||||
|
||||
# A map that defines the values used in the preamble template.
|
||||
DEFS = {
|
||||
'today' : time.strftime('%m/%d/%Y'),
|
||||
'year' : time.strftime('%Y'),
|
||||
'command' : '%s %s' % (os.path.basename(sys.argv[0]), n),
|
||||
'n' : n
|
||||
}
|
||||
|
||||
return ((
|
||||
"""// Copyright 2006, 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.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on %(today)s by command
|
||||
// '%(command)s'. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// Implements a family of generic predicate assertion macros.""" +
|
||||
"""#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
// This header implements a family of generic predicate assertion
|
||||
// macros:
|
||||
//
|
||||
// ASSERT_PRED_FORMAT1(pred_format, v1)
|
||||
// ASSERT_PRED_FORMAT2(pred_format, v1, v2)
|
||||
// ...
|
||||
//
|
||||
// where pred_format is a function or functor that takes n (in the
|
||||
// case of ASSERT_PRED_FORMATn) values and their source expression
|
||||
// text, and returns a testing::AssertionResult. See the definition
|
||||
// of ASSERT_EQ in gtest.h for an example.
|
||||
//
|
||||
// If you don't care about formatting, you can use the more
|
||||
// restrictive version:
|
||||
//
|
||||
// ASSERT_PRED1(pred, v1)
|
||||
// ASSERT_PRED2(pred, v1, v2)
|
||||
// ...
|
||||
//
|
||||
// where pred is an n-ary function or functor that returns bool,
|
||||
// and the values v1, v2, ..., must support the << operator for
|
||||
// streaming to std::ostream.
|
||||
//
|
||||
// We also define the EXPECT_* variations.
|
||||
//
|
||||
// For now we only support predicates whose arity is at most %(n)s.
|
||||
// Please email googletestframework@googlegroups.com if you need
|
||||
// support for higher arities.
|
||||
|
||||
// GTEST_ASSERT_ is the basic statement to which all of the assertions
|
||||
// in this file reduce. Don't use this in your code.
|
||||
|
||||
#define GTEST_ASSERT_(expression, on_failure) \\
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\
|
||||
if (const ::testing::AssertionResult gtest_ar = (expression)) \\
|
||||
; \\
|
||||
else \\
|
||||
on_failure(gtest_ar.failure_message())
|
||||
""") % DEFS)
|
||||
|
||||
|
||||
def Arity(n):
|
||||
"""Returns the English name of the given arity."""
|
||||
|
||||
if n < 0:
|
||||
return None
|
||||
elif n <= 3:
|
||||
return ['nullary', 'unary', 'binary', 'ternary'][n]
|
||||
else:
|
||||
return '%s-ary' % n
|
||||
|
||||
|
||||
def Title(word):
|
||||
"""Returns the given word in title case. The difference between
|
||||
this and string's title() method is that Title('4-ary') is '4-ary'
|
||||
while '4-ary'.title() is '4-Ary'."""
|
||||
|
||||
return word[0].upper() + word[1:]
|
||||
|
||||
|
||||
def OneTo(n):
|
||||
"""Returns the list [1, 2, 3, ..., n]."""
|
||||
|
||||
return range(1, n + 1)
|
||||
|
||||
|
||||
def Iter(n, format, sep=''):
|
||||
"""Given a positive integer n, a format string that contains 0 or
|
||||
more '%s' format specs, and optionally a separator string, returns
|
||||
the join of n strings, each formatted with the format string on an
|
||||
iterator ranged from 1 to n.
|
||||
|
||||
Example:
|
||||
|
||||
Iter(3, 'v%s', sep=', ') returns 'v1, v2, v3'.
|
||||
"""
|
||||
|
||||
# How many '%s' specs are in format?
|
||||
spec_count = len(format.split('%s')) - 1
|
||||
return sep.join([format % (spec_count * (i,)) for i in OneTo(n)])
|
||||
|
||||
|
||||
def ImplementationForArity(n):
|
||||
"""Returns the implementation of n-ary predicate assertions."""
|
||||
|
||||
# A map the defines the values used in the implementation template.
|
||||
DEFS = {
|
||||
'n' : str(n),
|
||||
'vs' : Iter(n, 'v%s', sep=', '),
|
||||
'vts' : Iter(n, '#v%s', sep=', '),
|
||||
'arity' : Arity(n),
|
||||
'Arity' : Title(Arity(n))
|
||||
}
|
||||
|
||||
impl = """
|
||||
|
||||
// Helper function for implementing {EXPECT|ASSERT}_PRED%(n)s. Don't use
|
||||
// this in your code.
|
||||
template <typename Pred""" % DEFS
|
||||
|
||||
impl += Iter(n, """,
|
||||
typename T%s""")
|
||||
|
||||
impl += """>
|
||||
AssertionResult AssertPred%(n)sHelper(const char* pred_text""" % DEFS
|
||||
|
||||
impl += Iter(n, """,
|
||||
const char* e%s""")
|
||||
|
||||
impl += """,
|
||||
Pred pred"""
|
||||
|
||||
impl += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
impl += """) {
|
||||
if (pred(%(vs)s)) return AssertionSuccess();
|
||||
|
||||
""" % DEFS
|
||||
|
||||
impl += ' return AssertionFailure() << pred_text << "("'
|
||||
|
||||
impl += Iter(n, """
|
||||
<< e%s""", sep=' << ", "')
|
||||
|
||||
impl += ' << ") evaluates to false, where"'
|
||||
|
||||
impl += Iter(
|
||||
n, """
|
||||
<< "\\n" << e%s << " evaluates to " << ::testing::PrintToString(v%s)"""
|
||||
)
|
||||
|
||||
impl += """;
|
||||
}
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT%(n)s.
|
||||
// Don't use this in your code.
|
||||
#define GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, on_failure)\\
|
||||
GTEST_ASSERT_(pred_format(%(vts)s, %(vs)s), \\
|
||||
on_failure)
|
||||
|
||||
// Internal macro for implementing {EXPECT|ASSERT}_PRED%(n)s. Don't use
|
||||
// this in your code.
|
||||
#define GTEST_PRED%(n)s_(pred, %(vs)s, on_failure)\\
|
||||
GTEST_ASSERT_(::testing::AssertPred%(n)sHelper(#pred""" % DEFS
|
||||
|
||||
impl += Iter(n, """, \\
|
||||
#v%s""")
|
||||
|
||||
impl += """, \\
|
||||
pred"""
|
||||
|
||||
impl += Iter(n, """, \\
|
||||
v%s""")
|
||||
|
||||
impl += """), on_failure)
|
||||
|
||||
// %(Arity)s predicate assertion macros.
|
||||
#define EXPECT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\
|
||||
GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_NONFATAL_FAILURE_)
|
||||
#define EXPECT_PRED%(n)s(pred, %(vs)s) \\
|
||||
GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_NONFATAL_FAILURE_)
|
||||
#define ASSERT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\
|
||||
GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_FATAL_FAILURE_)
|
||||
#define ASSERT_PRED%(n)s(pred, %(vs)s) \\
|
||||
GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_FATAL_FAILURE_)
|
||||
|
||||
""" % DEFS
|
||||
|
||||
return impl
|
||||
|
||||
|
||||
def HeaderPostamble():
|
||||
"""Returns the postamble for the header file."""
|
||||
|
||||
return """
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
"""
|
||||
|
||||
|
||||
def GenerateFile(path, content):
|
||||
"""Given a file path and a content string
|
||||
overwrites it with the given content.
|
||||
"""
|
||||
print 'Updating file %s . . .' % path
|
||||
f = file(path, 'w+')
|
||||
print >>f, content,
|
||||
f.close()
|
||||
|
||||
print 'File %s has been updated.' % path
|
||||
|
||||
|
||||
def GenerateHeader(n):
|
||||
"""Given the maximum arity n, updates the header file that implements
|
||||
the predicate assertions.
|
||||
"""
|
||||
GenerateFile(HEADER,
|
||||
HeaderPreamble(n)
|
||||
+ ''.join([ImplementationForArity(i) for i in OneTo(n)])
|
||||
+ HeaderPostamble())
|
||||
|
||||
|
||||
def UnitTestPreamble():
|
||||
"""Returns the preamble for the unit test file."""
|
||||
|
||||
# A map that defines the values used in the preamble template.
|
||||
DEFS = {
|
||||
'today' : time.strftime('%m/%d/%Y'),
|
||||
'year' : time.strftime('%Y'),
|
||||
'command' : '%s %s' % (os.path.basename(sys.argv[0]), sys.argv[1]),
|
||||
}
|
||||
|
||||
return (
|
||||
"""// Copyright 2006, 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.
|
||||
|
||||
// This file is AUTOMATICALLY GENERATED on %(today)s by command
|
||||
// '%(command)s'. DO NOT EDIT BY HAND!
|
||||
|
||||
// Regression test for gtest_pred_impl.h
|
||||
//
|
||||
// This file is generated by a script and quite long. If you intend to
|
||||
// learn how Google Test works by reading its unit tests, read
|
||||
// gtest_unittest.cc instead.
|
||||
//
|
||||
// This is intended as a regression test for the Google Test predicate
|
||||
// assertions. We compile it as part of the gtest_unittest target
|
||||
// only to keep the implementation tidy and compact, as it is quite
|
||||
// involved to set up the stage for testing Google Test using Google
|
||||
// Test itself.
|
||||
//
|
||||
// Currently, gtest_unittest takes ~11 seconds to run in the testing
|
||||
// daemon. In the future, if it grows too large and needs much more
|
||||
// time to finish, we should consider separating this file into a
|
||||
// stand-alone regression test.
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gtest/gtest-spi.h"
|
||||
|
||||
// A user-defined data type.
|
||||
struct Bool {
|
||||
explicit Bool(int val) : value(val != 0) {}
|
||||
|
||||
bool operator>(int n) const { return value > Bool(n).value; }
|
||||
|
||||
Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
|
||||
|
||||
bool operator==(const Bool& rhs) const { return value == rhs.value; }
|
||||
|
||||
bool value;
|
||||
};
|
||||
|
||||
// Enables Bool to be used in assertions.
|
||||
std::ostream& operator<<(std::ostream& os, const Bool& x) {
|
||||
return os << (x.value ? "true" : "false");
|
||||
}
|
||||
|
||||
""" % DEFS)
|
||||
|
||||
|
||||
def TestsForArity(n):
|
||||
"""Returns the tests for n-ary predicate assertions."""
|
||||
|
||||
# A map that defines the values used in the template for the tests.
|
||||
DEFS = {
|
||||
'n' : n,
|
||||
'es' : Iter(n, 'e%s', sep=', '),
|
||||
'vs' : Iter(n, 'v%s', sep=', '),
|
||||
'vts' : Iter(n, '#v%s', sep=', '),
|
||||
'tvs' : Iter(n, 'T%s v%s', sep=', '),
|
||||
'int_vs' : Iter(n, 'int v%s', sep=', '),
|
||||
'Bool_vs' : Iter(n, 'Bool v%s', sep=', '),
|
||||
'types' : Iter(n, 'typename T%s', sep=', '),
|
||||
'v_sum' : Iter(n, 'v%s', sep=' + '),
|
||||
'arity' : Arity(n),
|
||||
'Arity' : Title(Arity(n)),
|
||||
}
|
||||
|
||||
tests = (
|
||||
"""// Sample functions/functors for testing %(arity)s predicate assertions.
|
||||
|
||||
// A %(arity)s predicate function.
|
||||
template <%(types)s>
|
||||
bool PredFunction%(n)s(%(tvs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
|
||||
// The following two functions are needed because a compiler doesn't have
|
||||
// a context yet to know which template function must be instantiated.
|
||||
bool PredFunction%(n)sInt(%(int_vs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
bool PredFunction%(n)sBool(%(Bool_vs)s) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
""" % DEFS)
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate functor.
|
||||
struct PredFunctor%(n)s {
|
||||
template <%(types)s>
|
||||
bool operator()(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const T%s& v%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += """) {
|
||||
return %(v_sum)s > 0;
|
||||
}
|
||||
};
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate-formatter function.
|
||||
template <%(types)s>
|
||||
testing::AssertionResult PredFormatFunction%(n)s(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const char* e%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
tests += """) {
|
||||
if (PredFunction%(n)s(%(vs)s))
|
||||
return testing::AssertionSuccess();
|
||||
|
||||
return testing::AssertionFailure()
|
||||
<< """ % DEFS
|
||||
|
||||
tests += Iter(n, 'e%s', sep=' << " + " << ')
|
||||
|
||||
tests += """
|
||||
<< " is expected to be positive, but evaluates to "
|
||||
<< %(v_sum)s << ".";
|
||||
}
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// A %(arity)s predicate-formatter functor.
|
||||
struct PredFormatFunctor%(n)s {
|
||||
template <%(types)s>
|
||||
testing::AssertionResult operator()(""" % DEFS
|
||||
|
||||
tests += Iter(n, 'const char* e%s', sep=""",
|
||||
""")
|
||||
|
||||
tests += Iter(n, """,
|
||||
const T%s& v%s""")
|
||||
|
||||
tests += """) const {
|
||||
return PredFormatFunction%(n)s(%(es)s, %(vs)s);
|
||||
}
|
||||
};
|
||||
""" % DEFS
|
||||
|
||||
tests += """
|
||||
// Tests for {EXPECT|ASSERT}_PRED_FORMAT%(n)s.
|
||||
|
||||
class Predicate%(n)sTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
expected_to_finish_ = true;
|
||||
finished_ = false;""" % DEFS
|
||||
|
||||
tests += """
|
||||
""" + Iter(n, 'n%s_ = ') + """0;
|
||||
}
|
||||
"""
|
||||
|
||||
tests += """
|
||||
void TearDown() override {
|
||||
// Verifies that each of the predicate's arguments was evaluated
|
||||
// exactly once."""
|
||||
|
||||
tests += ''.join(["""
|
||||
EXPECT_EQ(1, n%s_) <<
|
||||
"The predicate assertion didn't evaluate argument %s "
|
||||
"exactly once.";""" % (i, i + 1) for i in OneTo(n)])
|
||||
|
||||
tests += """
|
||||
|
||||
// Verifies that the control flow in the test function is expected.
|
||||
if (expected_to_finish_ && !finished_) {
|
||||
FAIL() << "The predicate assertion unexpactedly aborted the test.";
|
||||
} else if (!expected_to_finish_ && finished_) {
|
||||
FAIL() << "The failed predicate assertion didn't abort the test "
|
||||
"as expected.";
|
||||
}
|
||||
}
|
||||
|
||||
// true if and only if the test function is expected to run to finish.
|
||||
static bool expected_to_finish_;
|
||||
|
||||
// true if and only if the test function did run to finish.
|
||||
static bool finished_;
|
||||
""" % DEFS
|
||||
|
||||
tests += Iter(n, """
|
||||
static int n%s_;""")
|
||||
|
||||
tests += """
|
||||
};
|
||||
|
||||
bool Predicate%(n)sTest::expected_to_finish_;
|
||||
bool Predicate%(n)sTest::finished_;
|
||||
""" % DEFS
|
||||
|
||||
tests += Iter(n, """int Predicate%%(n)sTest::n%s_;
|
||||
""") % DEFS
|
||||
|
||||
tests += """
|
||||
typedef Predicate%(n)sTest EXPECT_PRED_FORMAT%(n)sTest;
|
||||
typedef Predicate%(n)sTest ASSERT_PRED_FORMAT%(n)sTest;
|
||||
typedef Predicate%(n)sTest EXPECT_PRED%(n)sTest;
|
||||
typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;
|
||||
""" % DEFS
|
||||
|
||||
def GenTest(use_format, use_assert, expect_failure,
|
||||
use_functor, use_user_type):
|
||||
"""Returns the test for a predicate assertion macro.
|
||||
|
||||
Args:
|
||||
use_format: true if and only if the assertion is a *_PRED_FORMAT*.
|
||||
use_assert: true if and only if the assertion is a ASSERT_*.
|
||||
expect_failure: true if and only if the assertion is expected to fail.
|
||||
use_functor: true if and only if the first argument of the assertion is
|
||||
a functor (as opposed to a function)
|
||||
use_user_type: true if and only if the predicate functor/function takes
|
||||
argument(s) of a user-defined type.
|
||||
|
||||
Example:
|
||||
|
||||
GenTest(1, 0, 0, 1, 0) returns a test that tests the behavior
|
||||
of a successful EXPECT_PRED_FORMATn() that takes a functor
|
||||
whose arguments have built-in types."""
|
||||
|
||||
if use_assert:
|
||||
assrt = 'ASSERT' # 'assert' is reserved, so we cannot use
|
||||
# that identifier here.
|
||||
else:
|
||||
assrt = 'EXPECT'
|
||||
|
||||
assertion = assrt + '_PRED'
|
||||
|
||||
if use_format:
|
||||
pred_format = 'PredFormat'
|
||||
assertion += '_FORMAT'
|
||||
else:
|
||||
pred_format = 'Pred'
|
||||
|
||||
assertion += '%(n)s' % DEFS
|
||||
|
||||
if use_functor:
|
||||
pred_format_type = 'functor'
|
||||
pred_format += 'Functor%(n)s()'
|
||||
else:
|
||||
pred_format_type = 'function'
|
||||
pred_format += 'Function%(n)s'
|
||||
if not use_format:
|
||||
if use_user_type:
|
||||
pred_format += 'Bool'
|
||||
else:
|
||||
pred_format += 'Int'
|
||||
|
||||
test_name = pred_format_type.title()
|
||||
|
||||
if use_user_type:
|
||||
arg_type = 'user-defined type (Bool)'
|
||||
test_name += 'OnUserType'
|
||||
if expect_failure:
|
||||
arg = 'Bool(n%s_++)'
|
||||
else:
|
||||
arg = 'Bool(++n%s_)'
|
||||
else:
|
||||
arg_type = 'built-in type (int)'
|
||||
test_name += 'OnBuiltInType'
|
||||
if expect_failure:
|
||||
arg = 'n%s_++'
|
||||
else:
|
||||
arg = '++n%s_'
|
||||
|
||||
if expect_failure:
|
||||
successful_or_failed = 'failed'
|
||||
expected_or_not = 'expected.'
|
||||
test_name += 'Failure'
|
||||
else:
|
||||
successful_or_failed = 'successful'
|
||||
expected_or_not = 'UNEXPECTED!'
|
||||
test_name += 'Success'
|
||||
|
||||
# A map that defines the values used in the test template.
|
||||
defs = DEFS.copy()
|
||||
defs.update({
|
||||
'assert' : assrt,
|
||||
'assertion' : assertion,
|
||||
'test_name' : test_name,
|
||||
'pf_type' : pred_format_type,
|
||||
'pf' : pred_format,
|
||||
'arg_type' : arg_type,
|
||||
'arg' : arg,
|
||||
'successful' : successful_or_failed,
|
||||
'expected' : expected_or_not,
|
||||
})
|
||||
|
||||
test = """
|
||||
// Tests a %(successful)s %(assertion)s where the
|
||||
// predicate-formatter is a %(pf_type)s on a %(arg_type)s.
|
||||
TEST_F(%(assertion)sTest, %(test_name)s) {""" % defs
|
||||
|
||||
indent = (len(assertion) + 3)*' '
|
||||
extra_indent = ''
|
||||
|
||||
if expect_failure:
|
||||
extra_indent = ' '
|
||||
if use_assert:
|
||||
test += """
|
||||
expected_to_finish_ = false;
|
||||
EXPECT_FATAL_FAILURE({ // NOLINT"""
|
||||
else:
|
||||
test += """
|
||||
EXPECT_NONFATAL_FAILURE({ // NOLINT"""
|
||||
|
||||
test += '\n' + extra_indent + """ %(assertion)s(%(pf)s""" % defs
|
||||
|
||||
test = test % defs
|
||||
test += Iter(n, ',\n' + indent + extra_indent + '%(arg)s' % defs)
|
||||
test += ');\n' + extra_indent + ' finished_ = true;\n'
|
||||
|
||||
if expect_failure:
|
||||
test += ' }, "");\n'
|
||||
|
||||
test += '}\n'
|
||||
return test
|
||||
|
||||
# Generates tests for all 2**6 = 64 combinations.
|
||||
tests += ''.join([GenTest(use_format, use_assert, expect_failure,
|
||||
use_functor, use_user_type)
|
||||
for use_format in [0, 1]
|
||||
for use_assert in [0, 1]
|
||||
for expect_failure in [0, 1]
|
||||
for use_functor in [0, 1]
|
||||
for use_user_type in [0, 1]
|
||||
])
|
||||
|
||||
return tests
|
||||
|
||||
|
||||
def UnitTestPostamble():
|
||||
"""Returns the postamble for the tests."""
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
def GenerateUnitTest(n):
|
||||
"""Returns the tests for up-to n-ary predicate assertions."""
|
||||
|
||||
GenerateFile(UNIT_TEST,
|
||||
UnitTestPreamble()
|
||||
+ ''.join([TestsForArity(i) for i in OneTo(n)])
|
||||
+ UnitTestPostamble())
|
||||
|
||||
|
||||
def _Main():
|
||||
"""The entry point of the script. Generates the header file and its
|
||||
unit test."""
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print __doc__
|
||||
print 'Author: ' + __author__
|
||||
sys.exit(1)
|
||||
|
||||
n = int(sys.argv[1])
|
||||
GenerateHeader(n)
|
||||
GenerateUnitTest(n)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_Main()
|
@ -1,274 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# These variables are automatically filled in by the configure script.
|
||||
name="@PACKAGE_TARNAME@"
|
||||
version="@PACKAGE_VERSION@"
|
||||
|
||||
show_usage()
|
||||
{
|
||||
echo "Usage: gtest-config [OPTIONS...]"
|
||||
}
|
||||
|
||||
show_help()
|
||||
{
|
||||
show_usage
|
||||
cat <<\EOF
|
||||
|
||||
The `gtest-config' script provides access to the necessary compile and linking
|
||||
flags to connect with Google C++ Testing Framework, both in a build prior to
|
||||
installation, and on the system proper after installation. The installation
|
||||
overrides may be issued in combination with any other queries, but will only
|
||||
affect installation queries if called on a built but not installed gtest. The
|
||||
installation queries may not be issued with any other types of queries, and
|
||||
only one installation query may be made at a time. The version queries and
|
||||
compiler flag queries may be combined as desired but not mixed. Different
|
||||
version queries are always combined with logical "and" semantics, and only the
|
||||
last of any particular query is used while all previous ones ignored. All
|
||||
versions must be specified as a sequence of numbers separated by periods.
|
||||
Compiler flag queries output the union of the sets of flags when combined.
|
||||
|
||||
Examples:
|
||||
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
|
||||
|
||||
g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp
|
||||
g++ $(gtest-config --ldflags --libs) -o foo foo.o
|
||||
|
||||
# When using a built but not installed Google Test:
|
||||
g++ $(../../my_gtest_build/scripts/gtest-config ...) ...
|
||||
|
||||
# When using an installed Google Test, but with installation overrides:
|
||||
export GTEST_PREFIX="/opt"
|
||||
g++ $(gtest-config --libdir="/opt/lib64" ...) ...
|
||||
|
||||
Help:
|
||||
--usage brief usage information
|
||||
--help display this help message
|
||||
|
||||
Installation Overrides:
|
||||
--prefix=<dir> overrides the installation prefix
|
||||
--exec-prefix=<dir> overrides the executable installation prefix
|
||||
--libdir=<dir> overrides the library installation prefix
|
||||
--includedir=<dir> overrides the header file installation prefix
|
||||
|
||||
Installation Queries:
|
||||
--prefix installation prefix
|
||||
--exec-prefix executable installation prefix
|
||||
--libdir library installation directory
|
||||
--includedir header file installation directory
|
||||
--version the version of the Google Test installation
|
||||
|
||||
Version Queries:
|
||||
--min-version=VERSION return 0 if the version is at least VERSION
|
||||
--exact-version=VERSION return 0 if the version is exactly VERSION
|
||||
--max-version=VERSION return 0 if the version is at most VERSION
|
||||
|
||||
Compilation Flag Queries:
|
||||
--cppflags compile flags specific to the C-like preprocessors
|
||||
--cxxflags compile flags appropriate for C++ programs
|
||||
--ldflags linker flags
|
||||
--libs libraries for linking
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# This function bounds our version with a min and a max. It uses some clever
|
||||
# POSIX-compliant variable expansion to portably do all the work in the shell
|
||||
# and avoid any dependency on a particular "sed" or "awk" implementation.
|
||||
# Notable is that it will only ever compare the first 3 components of versions.
|
||||
# Further components will be cleanly stripped off. All versions must be
|
||||
# unadorned, so "v1.0" will *not* work. The minimum version must be in $1, and
|
||||
# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should
|
||||
# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than
|
||||
# continuing to maintain our own shell version.
|
||||
check_versions()
|
||||
{
|
||||
major_version=${version%%.*}
|
||||
minor_version="0"
|
||||
point_version="0"
|
||||
if test "${version#*.}" != "${version}"; then
|
||||
minor_version=${version#*.}
|
||||
minor_version=${minor_version%%.*}
|
||||
fi
|
||||
if test "${version#*.*.}" != "${version}"; then
|
||||
point_version=${version#*.*.}
|
||||
point_version=${point_version%%.*}
|
||||
fi
|
||||
|
||||
min_version="$1"
|
||||
min_major_version=${min_version%%.*}
|
||||
min_minor_version="0"
|
||||
min_point_version="0"
|
||||
if test "${min_version#*.}" != "${min_version}"; then
|
||||
min_minor_version=${min_version#*.}
|
||||
min_minor_version=${min_minor_version%%.*}
|
||||
fi
|
||||
if test "${min_version#*.*.}" != "${min_version}"; then
|
||||
min_point_version=${min_version#*.*.}
|
||||
min_point_version=${min_point_version%%.*}
|
||||
fi
|
||||
|
||||
max_version="$2"
|
||||
max_major_version=${max_version%%.*}
|
||||
max_minor_version="0"
|
||||
max_point_version="0"
|
||||
if test "${max_version#*.}" != "${max_version}"; then
|
||||
max_minor_version=${max_version#*.}
|
||||
max_minor_version=${max_minor_version%%.*}
|
||||
fi
|
||||
if test "${max_version#*.*.}" != "${max_version}"; then
|
||||
max_point_version=${max_version#*.*.}
|
||||
max_point_version=${max_point_version%%.*}
|
||||
fi
|
||||
|
||||
test $(($major_version)) -lt $(($min_major_version)) && exit 1
|
||||
if test $(($major_version)) -eq $(($min_major_version)); then
|
||||
test $(($minor_version)) -lt $(($min_minor_version)) && exit 1
|
||||
if test $(($minor_version)) -eq $(($min_minor_version)); then
|
||||
test $(($point_version)) -lt $(($min_point_version)) && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
test $(($major_version)) -gt $(($max_major_version)) && exit 1
|
||||
if test $(($major_version)) -eq $(($max_major_version)); then
|
||||
test $(($minor_version)) -gt $(($max_minor_version)) && exit 1
|
||||
if test $(($minor_version)) -eq $(($max_minor_version)); then
|
||||
test $(($point_version)) -gt $(($max_point_version)) && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Show the usage line when no arguments are specified.
|
||||
if test $# -eq 0; then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--usage) show_usage; exit 0;;
|
||||
--help) show_help; exit 0;;
|
||||
|
||||
# Installation overrides
|
||||
--prefix=*) GTEST_PREFIX=${1#--prefix=};;
|
||||
--exec-prefix=*) GTEST_EXEC_PREFIX=${1#--exec-prefix=};;
|
||||
--libdir=*) GTEST_LIBDIR=${1#--libdir=};;
|
||||
--includedir=*) GTEST_INCLUDEDIR=${1#--includedir=};;
|
||||
|
||||
# Installation queries
|
||||
--prefix|--exec-prefix|--libdir|--includedir|--version)
|
||||
if test -n "${do_query}"; then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
do_query=${1#--}
|
||||
;;
|
||||
|
||||
# Version checking
|
||||
--min-version=*)
|
||||
do_check_versions=yes
|
||||
min_version=${1#--min-version=}
|
||||
;;
|
||||
--max-version=*)
|
||||
do_check_versions=yes
|
||||
max_version=${1#--max-version=}
|
||||
;;
|
||||
--exact-version=*)
|
||||
do_check_versions=yes
|
||||
exact_version=${1#--exact-version=}
|
||||
;;
|
||||
|
||||
# Compiler flag output
|
||||
--cppflags) echo_cppflags=yes;;
|
||||
--cxxflags) echo_cxxflags=yes;;
|
||||
--ldflags) echo_ldflags=yes;;
|
||||
--libs) echo_libs=yes;;
|
||||
|
||||
# Everything else is an error
|
||||
*) show_usage; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# These have defaults filled in by the configure script but can also be
|
||||
# overridden by environment variables or command line parameters.
|
||||
prefix="${GTEST_PREFIX:-@prefix@}"
|
||||
exec_prefix="${GTEST_EXEC_PREFIX:-@exec_prefix@}"
|
||||
libdir="${GTEST_LIBDIR:-@libdir@}"
|
||||
includedir="${GTEST_INCLUDEDIR:-@includedir@}"
|
||||
|
||||
# We try and detect if our binary is not located at its installed location. If
|
||||
# it's not, we provide variables pointing to the source and build tree rather
|
||||
# than to the install tree. This allows building against a just-built gtest
|
||||
# rather than an installed gtest.
|
||||
bindir="@bindir@"
|
||||
this_relative_bindir=`dirname $0`
|
||||
this_bindir=`cd ${this_relative_bindir}; pwd -P`
|
||||
if test "${this_bindir}" = "${this_bindir%${bindir}}"; then
|
||||
# The path to the script doesn't end in the bindir sequence from Autoconf,
|
||||
# assume that we are in a build tree.
|
||||
build_dir=`dirname ${this_bindir}`
|
||||
src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`
|
||||
|
||||
# TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we
|
||||
# should work to remove it, and/or remove libtool altogether, replacing it
|
||||
# with direct references to the library and a link path.
|
||||
gtest_libs="${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
|
||||
gtest_ldflags=""
|
||||
|
||||
# We provide hooks to include from either the source or build dir, where the
|
||||
# build dir is always preferred. This will potentially allow us to write
|
||||
# build rules for generated headers and have them automatically be preferred
|
||||
# over provided versions.
|
||||
gtest_cppflags="-I${build_dir}/include -I${src_dir}/include"
|
||||
gtest_cxxflags="@PTHREAD_CFLAGS@"
|
||||
else
|
||||
# We're using an installed gtest, although it may be staged under some
|
||||
# prefix. Assume (as our own libraries do) that we can resolve the prefix,
|
||||
# and are present in the dynamic link paths.
|
||||
gtest_ldflags="-L${libdir}"
|
||||
gtest_libs="-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@"
|
||||
gtest_cppflags="-I${includedir}"
|
||||
gtest_cxxflags="@PTHREAD_CFLAGS@"
|
||||
fi
|
||||
|
||||
# Do an installation query if requested.
|
||||
if test -n "$do_query"; then
|
||||
case $do_query in
|
||||
prefix) echo $prefix; exit 0;;
|
||||
exec-prefix) echo $exec_prefix; exit 0;;
|
||||
libdir) echo $libdir; exit 0;;
|
||||
includedir) echo $includedir; exit 0;;
|
||||
version) echo $version; exit 0;;
|
||||
*) show_usage; exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Do a version check if requested.
|
||||
if test "$do_check_versions" = "yes"; then
|
||||
# Make sure we didn't receive a bad combination of parameters.
|
||||
test "$echo_cppflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_cxxflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_ldflags" = "yes" && show_usage && exit 1
|
||||
test "$echo_libs" = "yes" && show_usage && exit 1
|
||||
|
||||
if test "$exact_version" != ""; then
|
||||
check_versions $exact_version $exact_version
|
||||
# unreachable
|
||||
else
|
||||
check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}
|
||||
# unreachable
|
||||
fi
|
||||
fi
|
||||
|
||||
# Do the output in the correct order so that these can be used in-line of
|
||||
# a compiler invocation.
|
||||
output=""
|
||||
test "$echo_cppflags" = "yes" && output="$output $gtest_cppflags"
|
||||
test "$echo_cxxflags" = "yes" && output="$output $gtest_cxxflags"
|
||||
test "$echo_ldflags" = "yes" && output="$output $gtest_ldflags"
|
||||
test "$echo_libs" = "yes" && output="$output $gtest_libs"
|
||||
echo $output
|
||||
|
||||
exit 0
|
@ -1,158 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2013 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.
|
||||
|
||||
"""Script for branching Google Test/Mock wiki pages for a new version.
|
||||
|
||||
SYNOPSIS
|
||||
release_docs.py NEW_RELEASE_VERSION
|
||||
|
||||
Google Test and Google Mock's external user documentation is in
|
||||
interlinked wiki files. When we release a new version of
|
||||
Google Test or Google Mock, we need to branch the wiki files
|
||||
such that users of a specific version of Google Test/Mock can
|
||||
look up documentation relevant for that version. This script
|
||||
automates that process by:
|
||||
|
||||
- branching the current wiki pages (which document the
|
||||
behavior of the SVN trunk head) to pages for the specified
|
||||
version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when
|
||||
NEW_RELEASE_VERSION is 2.6);
|
||||
- updating the links in the branched files to point to the branched
|
||||
version (e.g. a link in V2_6_FAQ.wiki that pointed to
|
||||
Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).
|
||||
|
||||
NOTE: NEW_RELEASE_VERSION must be a NEW version number for
|
||||
which the wiki pages don't yet exist; otherwise you'll get SVN
|
||||
errors like "svn: Path 'V1_7_PumpManual.wiki' is not a
|
||||
directory" when running the script.
|
||||
|
||||
EXAMPLE
|
||||
$ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk
|
||||
$ scripts/release_docs.py 2.6 # create wiki pages for v2.6
|
||||
$ svn status # verify the file list
|
||||
$ svn diff # verify the file contents
|
||||
$ svn commit -m "release wiki pages for v2.6"
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
import common
|
||||
|
||||
|
||||
# Wiki pages that shouldn't be branched for every gtest/gmock release.
|
||||
GTEST_UNVERSIONED_WIKIS = ['DevGuide.wiki']
|
||||
GMOCK_UNVERSIONED_WIKIS = [
|
||||
'DesignDoc.wiki',
|
||||
'DevGuide.wiki',
|
||||
'KnownIssues.wiki'
|
||||
]
|
||||
|
||||
|
||||
def DropWikiSuffix(wiki_filename):
|
||||
"""Removes the .wiki suffix (if any) from the given filename."""
|
||||
|
||||
return (wiki_filename[:-len('.wiki')] if wiki_filename.endswith('.wiki')
|
||||
else wiki_filename)
|
||||
|
||||
|
||||
class WikiBrancher(object):
|
||||
"""Branches ..."""
|
||||
|
||||
def __init__(self, dot_version):
|
||||
self.project, svn_root_path = common.GetSvnInfo()
|
||||
if self.project not in ('googletest', 'googlemock'):
|
||||
sys.exit('This script must be run in a gtest or gmock SVN workspace.')
|
||||
self.wiki_dir = svn_root_path + '/wiki'
|
||||
# Turn '2.6' to 'V2_6_'.
|
||||
self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'
|
||||
self.files_to_branch = self.GetFilesToBranch()
|
||||
page_names = [DropWikiSuffix(f) for f in self.files_to_branch]
|
||||
# A link to Foo.wiki is in one of the following forms:
|
||||
# [Foo words]
|
||||
# [Foo#Anchor words]
|
||||
# [http://code.google.com/.../wiki/Foo words]
|
||||
# [http://code.google.com/.../wiki/Foo#Anchor words]
|
||||
# We want to replace 'Foo' with 'V2_6_Foo' in the above cases.
|
||||
self.search_for_re = re.compile(
|
||||
# This regex matches either
|
||||
# [Foo
|
||||
# or
|
||||
# /wiki/Foo
|
||||
# followed by a space or a #, where Foo is the name of an
|
||||
# unversioned wiki page.
|
||||
r'(\[|/wiki/)(%s)([ #])' % '|'.join(page_names))
|
||||
self.replace_with = r'\1%s\2\3' % (self.version_prefix,)
|
||||
|
||||
def GetFilesToBranch(self):
|
||||
"""Returns a list of .wiki file names that need to be branched."""
|
||||
|
||||
unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'
|
||||
else GMOCK_UNVERSIONED_WIKIS)
|
||||
return [f for f in os.listdir(self.wiki_dir)
|
||||
if (f.endswith('.wiki') and
|
||||
not re.match(r'^V\d', f) and # Excluded versioned .wiki files.
|
||||
f not in unversioned_wikis)]
|
||||
|
||||
def BranchFiles(self):
|
||||
"""Branches the .wiki files needed to be branched."""
|
||||
|
||||
print 'Branching %d .wiki files:' % (len(self.files_to_branch),)
|
||||
os.chdir(self.wiki_dir)
|
||||
for f in self.files_to_branch:
|
||||
command = 'svn cp %s %s%s' % (f, self.version_prefix, f)
|
||||
print command
|
||||
os.system(command)
|
||||
|
||||
def UpdateLinksInBranchedFiles(self):
|
||||
|
||||
for f in self.files_to_branch:
|
||||
source_file = os.path.join(self.wiki_dir, f)
|
||||
versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)
|
||||
print 'Updating links in %s.' % (versioned_file,)
|
||||
text = file(source_file, 'r').read()
|
||||
new_text = self.search_for_re.sub(self.replace_with, text)
|
||||
file(versioned_file, 'w').write(new_text)
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(__doc__)
|
||||
|
||||
brancher = WikiBrancher(sys.argv[1])
|
||||
brancher.BranchFiles()
|
||||
brancher.UpdateLinksInBranchedFiles()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2010 Google Inc. All Rights Reserved.
|
||||
|
||||
"""Runs program specified in the command line with the substituted PATH.
|
||||
|
||||
This script is needed for to support building under Pulse which is unable
|
||||
to override the existing PATH variable.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
SUBST_PATH_ENV_VAR_NAME = "SUBST_PATH"
|
||||
|
||||
def main():
|
||||
if SUBST_PATH_ENV_VAR_NAME in os.environ:
|
||||
os.environ["PATH"] = os.environ[SUBST_PATH_ENV_VAR_NAME]
|
||||
|
||||
exit_code = subprocess.Popen(sys.argv[1:]).wait()
|
||||
|
||||
# exit_code is negative (-signal) if the process has been terminated by
|
||||
# a signal. Returning negative exit code is not portable and so we return
|
||||
# 100 instead.
|
||||
if exit_code < 0:
|
||||
exit_code = 100
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,59 +0,0 @@
|
||||
# A Makefile for fusing Google Test and building a sample test against it.
|
||||
#
|
||||
# SYNOPSIS:
|
||||
#
|
||||
# make [all] - makes everything.
|
||||
# make TARGET - makes the given target.
|
||||
# make check - makes everything and runs the built sample test.
|
||||
# make clean - removes all files generated by make.
|
||||
|
||||
# Points to the root of fused Google Test, relative to where this file is.
|
||||
FUSED_GTEST_DIR = output
|
||||
|
||||
# Paths to the fused gtest files.
|
||||
FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
|
||||
FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
|
||||
|
||||
# Where to find the sample test.
|
||||
SAMPLE_DIR = ../../samples
|
||||
|
||||
# Where to find gtest_main.cc.
|
||||
GTEST_MAIN_CC = ../../src/gtest_main.cc
|
||||
|
||||
# Flags passed to the preprocessor.
|
||||
# We have no idea here whether pthreads is available in the system, so
|
||||
# disable its use.
|
||||
CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += -g
|
||||
|
||||
all : sample1_unittest
|
||||
|
||||
check : all
|
||||
./sample1_unittest
|
||||
|
||||
clean :
|
||||
rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
|
||||
|
||||
$(FUSED_GTEST_H) :
|
||||
../fuse_gtest_files.py $(FUSED_GTEST_DIR)
|
||||
|
||||
$(FUSED_GTEST_ALL_CC) :
|
||||
../fuse_gtest_files.py $(FUSED_GTEST_DIR)
|
||||
|
||||
gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
|
||||
|
||||
gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
|
||||
|
||||
sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
|
||||
|
||||
sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
|
||||
$(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
|
||||
|
||||
sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
|
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009, 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.
|
||||
|
||||
"""upload_gtest.py v0.1.0 -- uploads a Google Test patch for review.
|
||||
|
||||
This simple wrapper passes all command line flags and
|
||||
--cc=googletestframework@googlegroups.com to upload.py.
|
||||
|
||||
USAGE: upload_gtest.py [options for upload.py]
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
CC_FLAG = '--cc='
|
||||
GTEST_GROUP = 'googletestframework@googlegroups.com'
|
||||
|
||||
|
||||
def main():
|
||||
# Finds the path to upload.py, assuming it is in the same directory
|
||||
# as this file.
|
||||
my_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
upload_py_path = os.path.join(my_dir, 'upload.py')
|
||||
|
||||
# Adds Google Test discussion group to the cc line if it's not there
|
||||
# already.
|
||||
upload_py_argv = [upload_py_path]
|
||||
found_cc_flag = False
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith(CC_FLAG):
|
||||
found_cc_flag = True
|
||||
cc_line = arg[len(CC_FLAG):]
|
||||
cc_list = [addr for addr in cc_line.split(',') if addr]
|
||||
if GTEST_GROUP not in cc_list:
|
||||
cc_list.append(GTEST_GROUP)
|
||||
upload_py_argv.append(CC_FLAG + ','.join(cc_list))
|
||||
else:
|
||||
upload_py_argv.append(arg)
|
||||
|
||||
if not found_cc_flag:
|
||||
upload_py_argv.append(CC_FLAG + GTEST_GROUP)
|
||||
|
||||
# Invokes upload.py with the modified command line flags.
|
||||
os.execv(upload_py_path, upload_py_argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user