Пример #1
0
def main(argv=sys.argv):
    if (len(argv) < 2):
        sys.stderr("Path to an existing interface is required.")
        sys.exit(0)

    filePath = argv[1]
    f = open(filePath)
    interfaceContents = f.readlines()
    f.close()

    interfaceContents = removeSignalsFromInterface(interfaceContents)

    currentScriptPath = os.path.realpath(__file__)
    tempFilePath = os.path.join(os.path.dirname(currentScriptPath),
                                "temporaryFile.txt")

    f = open(tempFilePath, "w")
    f.writelines(interfaceContents)
    f.close()

    sys.argv[1] = tempFilePath

    # Add the directory of this script to the path so we can import gmock_class.
    sys.path.append(os.path.dirname(__file__))

    from cpp import gmock_class
    # Fix the docstring in case they require the usage.
    gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py',
                                                      __file__)
    gmock_class.main()
Пример #2
0
def createMock():
    sys.path.append(os.path.dirname(__file__))
    from cpp import gmock_class
    gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py', __file__)
    gmock_class.main()
Пример #3
0
#
# Copyright 2008 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Driver for starting up Google Mock class generator."""

__author__ = '[email protected] (Neal Norwitz)'

import os
import sys

if __name__ == '__main__':
    # Add the directory of this script to the path so we can import gmock_class.
    sys.path.append(os.path.dirname(__file__))

    from cpp import gmock_class
    # Fix the docstring in case they require the usage.
    gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py',
                                                      __file__)
    gmock_class.main()
Пример #4
0
#
# Copyright 2008 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Driver for starting up Google Mock class generator."""

__author__ = '[email protected] (Neal Norwitz)'

import os
import sys

if __name__ == '__main__':
  # Add the directory of this script to the path so we can import gmock_class.
  sys.path.append(os.path.dirname(__file__))

  from cpp import gmock_class
  # Fix the docstring in case they require the usage.
  gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py', __file__)
  gmock_class.main()
Пример #5
0
        for filename in f:
            input_filepath = os.path.normpath(os.path.join(r, filename))
            output_filepath = os.path.normpath(
                os.path.join(output_dir, "mock_" + filename))

            print("Processing file: %s" % input_filepath)

            stdout = sys.stdout
            sys.stdout = output = StringIO()

            try:
                params = ["../gmock_class", input_filepath]
                if mock_destructors:
                    params.append("-d")

                gmock_class.main(params)
            except SystemExit as e:
                pass

            str_out = output.getvalue()

            if len(str_out) > 0:
                if not os.path.exists(output_dir):
                    os.makedirs(output_dir)

                includes = build_include_header(relative_path, filename)

                f = open(output_filepath, 'wb')
                f.write(includes)
                f.write(str_out)
                f.close()