diff options
author | Gennadiy Civil <misterg@google.com> | 2019-08-06 19:51:51 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-08-06 19:51:51 (GMT) |
commit | f64f7bd36735e14f520d8813af5b7cb780b7e164 (patch) | |
tree | 62244e1ffdc64a6a5ef657c3883c50f29abecee8 /googletest | |
parent | 07ec69a886529c3228fcf436b7a352c4f1ddc1fb (diff) | |
parent | d0cb77dcce6ce56a99ba8d0cdfbea96f5fd81aeb (diff) | |
download | googletest-f64f7bd36735e14f520d8813af5b7cb780b7e164.zip googletest-f64f7bd36735e14f520d8813af5b7cb780b7e164.tar.gz googletest-f64f7bd36735e14f520d8813af5b7cb780b7e164.tar.bz2 |
Merge pull request #2375 from kuzkry:broken-links
PiperOrigin-RevId: 261970482
Diffstat (limited to 'googletest')
-rwxr-xr-x | googletest/scripts/fuse_gtest_files.py | 24 | ||||
-rwxr-xr-x | googletest/scripts/gen_gtest_pred_impl.py | 14 | ||||
-rwxr-xr-x | googletest/scripts/pump.py | 2 | ||||
-rwxr-xr-x | googletest/scripts/release_docs.py | 158 | ||||
-rwxr-xr-x | googletest/scripts/upload.py | 2 |
5 files changed, 181 insertions, 19 deletions
diff --git a/googletest/scripts/fuse_gtest_files.py b/googletest/scripts/fuse_gtest_files.py index fb0c322..d0dd464 100755 --- a/googletest/scripts/fuse_gtest_files.py +++ b/googletest/scripts/fuse_gtest_files.py @@ -172,7 +172,6 @@ def FuseGTestH(gtest_root, output_dir): output_file.write(line) ProcessFile(GTEST_H_SEED) - ProcessFile(GTEST_SPI_H_SEED) output_file.close() @@ -194,15 +193,20 @@ def FuseGTestAllCcToFile(gtest_root, output_file): for line in open(os.path.join(gtest_root, gtest_source_file), 'r'): m = INCLUDE_GTEST_FILE_REGEX.match(line) if m: - # It's '#include "gtest/foo.h"'. - # 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,)) + 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: diff --git a/googletest/scripts/gen_gtest_pred_impl.py b/googletest/scripts/gen_gtest_pred_impl.py index b00830d..b43efdf 100755 --- a/googletest/scripts/gen_gtest_pred_impl.py +++ b/googletest/scripts/gen_gtest_pred_impl.py @@ -540,10 +540,10 @@ class Predicate%(n)sTest : public testing::Test { } } - // true if the test function is expected to run to finish. + // true iff the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true iff the test function did run to finish. static bool finished_; """ % DEFS @@ -572,12 +572,12 @@ typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest; """Returns the test for a predicate assertion macro. Args: - use_format: true if the assertion is a *_PRED_FORMAT*. - use_assert: true if the assertion is a ASSERT_*. - expect_failure: true if the assertion is expected to fail. - use_functor: true if the first argument of the assertion is + use_format: true iff the assertion is a *_PRED_FORMAT*. + use_assert: true iff the assertion is a ASSERT_*. + expect_failure: true iff the assertion is expected to fail. + use_functor: true iff the first argument of the assertion is a functor (as opposed to a function) - use_user_type: true if the predicate functor/function takes + use_user_type: true iff the predicate functor/function takes argument(s) of a user-defined type. Example: diff --git a/googletest/scripts/pump.py b/googletest/scripts/pump.py index 7dfb87a..5efb653 100755 --- a/googletest/scripts/pump.py +++ b/googletest/scripts/pump.py @@ -161,7 +161,7 @@ class Token: def StartsWith(lines, pos, string): - """Returns True if the given position in lines starts with 'string'.""" + """Returns True iff the given position in lines starts with 'string'.""" return lines[pos.line][pos.column:].startswith(string) diff --git a/googletest/scripts/release_docs.py b/googletest/scripts/release_docs.py new file mode 100755 index 0000000..1291347 --- /dev/null +++ b/googletest/scripts/release_docs.py @@ -0,0 +1,158 @@ +#!/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 documenation 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() diff --git a/googletest/scripts/upload.py b/googletest/scripts/upload.py index 8563e5f..c852e4c 100755 --- a/googletest/scripts/upload.py +++ b/googletest/scripts/upload.py @@ -631,7 +631,7 @@ class VersionControlSystem(object): new_content: For text files, this is empty. For binary files, this is the contents of the new file, since the diff output won't contain information to reconstruct the current file. - is_binary: True if the file is binary. + is_binary: True iff the file is binary. status: The status of the file. """ |