diff options
author | Haibo Huang <hhb@google.com> | 2019-05-23 05:17:19 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-05-23 05:17:19 -0700 |
commit | 51a2af3f3affb00aa71ae0fa1cf56d5d2a39073a (patch) | |
tree | 580c481ab8049407cf1555bcbbc6ace73df9d219 | |
parent | 002c22e5f2dc9030d0b414a4fce547d9e30e0644 (diff) | |
parent | df9906a80f39b1b8782dc862d4d42da3796fcdc7 (diff) | |
download | google-fruit-51a2af3f3affb00aa71ae0fa1cf56d5d2a39073a.tar.gz |
Merge "Upgrade google-fruit to d1608a5732fc44e29a067e4b578888d0ec32291d" am: 66a3a3f5b0 am: 4e6085d2e1
am: df9906a80f
Change-Id: Ib2405ac6a341faa301ed271dfeecfd603331ab67
75 files changed, 749 insertions, 526 deletions
diff --git a/.travis.yml b/.travis.yml index e5cf995..bcde127 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,66 +10,85 @@ matrix: fast_finish: true include: - compiler: gcc - env: COMPILER=gcc-8 UBUNTU=18.10 TEST=ReleasePlain - install: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=gcc-9 UBUNTU=19.04 TEST=ReleasePlain + install: export OS=linux; export COMPILER='gcc-9'; export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/postsubmit.sh + script: export OS=linux; export COMPILER='gcc-9'; export UBUNTU='19.04'; extras/scripts/postsubmit.sh ReleasePlain - compiler: gcc - env: COMPILER=gcc-8 UBUNTU=18.10 TEST=DebugPlain - install: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=gcc-9 UBUNTU=19.04 TEST=DebugPlain + install: export OS=linux; export COMPILER='gcc-9'; export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/postsubmit.sh + script: export OS=linux; export COMPILER='gcc-9'; export UBUNTU='19.04'; extras/scripts/postsubmit.sh DebugPlain - compiler: clang - env: COMPILER=clang-7.0 STL=libstdc++ UBUNTU=18.10 TEST=ReleasePlain - install: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=clang-6.0 STL=libstdc++ UBUNTU=19.04 TEST=ReleasePlain + install: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/postsubmit.sh ReleasePlain + script: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/postsubmit.sh ReleasePlain - compiler: clang - env: COMPILER=clang-7.0 STL=libstdc++ UBUNTU=18.10 TEST=DebugAsanUbsan - install: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=clang-6.0 STL=libstdc++ UBUNTU=19.04 TEST=DebugAsanUbsan + install: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/postsubmit.sh DebugAsanUbsan + script: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/postsubmit.sh DebugAsanUbsan - compiler: clang - env: COMPILER=clang-7.0 STL=libstdc++ UBUNTU=18.10 TEST=DebugPlain - install: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=clang-6.0 STL=libstdc++ UBUNTU=19.04 TEST=DebugPlain + install: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; - export UBUNTU='18.10'; extras/scripts/postsubmit.sh DebugPlain + script: export OS=linux; export COMPILER='clang-6.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/postsubmit.sh DebugPlain - compiler: gcc - env: COMPILER=bazel UBUNTU=16.04 - install: export OS=linux; export COMPILER='bazel'; export UBUNTU='16.04'; extras/scripts/travis_ci_install_linux.sh + env: COMPILER=bazel UBUNTU=18.04 + install: export OS=linux; export COMPILER='bazel'; export UBUNTU='18.04'; extras/scripts/travis_ci_install_linux.sh os: linux - script: export OS=linux; export COMPILER='bazel'; export UBUNTU='16.04'; extras/scripts/postsubmit.sh + script: export OS=linux; export COMPILER='bazel'; export UBUNTU='18.04'; extras/scripts/postsubmit.sh DebugPlain - compiler: gcc - env: COMPILER=gcc-6 TEST=DebugPlain - install: export OS=osx; export COMPILER='gcc-6'; extras/scripts/travis_ci_install_osx.sh + env: COMPILER=gcc-8 TEST=DebugPlain + install: export OS=osx; export COMPILER='gcc-8'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 - script: export OS=osx; export COMPILER='gcc-6'; extras/scripts/postsubmit.sh DebugPlain - - compiler: clang - env: COMPILER=clang-4.0 STL=libc++ TEST=DebugPlain - install: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh - os: osx - osx_image: xcode8 - script: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/postsubmit.sh - DebugPlain + osx_image: xcode10.2 + script: export OS=osx; export COMPILER='gcc-8'; extras/scripts/postsubmit.sh DebugPlain - compiler: clang env: COMPILER=clang-default STL=libc++ TEST=DebugPlain install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode10 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/postsubmit.sh DebugPlain - compiler: clang + env: COMPILER=clang-8.0 STL=libstdc++ UBUNTU=19.04 TEST=ReleasePlainNoPch + install: export OS=linux; export COMPILER='clang-8.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='clang-8.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/postsubmit.sh ReleasePlainNoPch + - compiler: clang + env: COMPILER=clang-8.0 STL=libstdc++ UBUNTU=19.04 TEST=DebugAsanUbsanNoPch + install: export OS=linux; export COMPILER='clang-8.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='clang-8.0'; export STL='libstdc++'; + export UBUNTU='19.04'; extras/scripts/postsubmit.sh DebugAsanUbsanNoPch + - compiler: gcc + env: COMPILER=gcc-8 UBUNTU=18.10 TEST=ReleasePlain + install: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/postsubmit.sh + ReleasePlain + - compiler: gcc + env: COMPILER=gcc-8 UBUNTU=18.10 TEST=DebugPlain + install: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='gcc-8'; export UBUNTU='18.10'; extras/scripts/postsubmit.sh + DebugPlain + - compiler: clang env: COMPILER=clang-4.0 STL=libstdc++ UBUNTU=18.10 TEST=ReleasePlain install: export OS=linux; export COMPILER='clang-4.0'; export STL='libstdc++'; export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh @@ -83,6 +102,26 @@ matrix: os: linux script: export OS=linux; export COMPILER='clang-4.0'; export STL='libstdc++'; export UBUNTU='18.10'; extras/scripts/postsubmit.sh DebugAsanUbsan + - compiler: clang + env: COMPILER=clang-7.0 STL=libstdc++ UBUNTU=18.10 TEST=ReleasePlainNoPch + install: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; + export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; + export UBUNTU='18.10'; extras/scripts/postsubmit.sh ReleasePlainNoPch + - compiler: clang + env: COMPILER=clang-7.0 STL=libstdc++ UBUNTU=18.10 TEST=DebugAsanUbsanNoPch + install: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; + export UBUNTU='18.10'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='clang-7.0'; export STL='libstdc++'; + export UBUNTU='18.10'; extras/scripts/postsubmit.sh DebugAsanUbsanNoPch + - compiler: gcc + env: COMPILER=bazel UBUNTU=16.04 + install: export OS=linux; export COMPILER='bazel'; export UBUNTU='16.04'; extras/scripts/travis_ci_install_linux.sh + os: linux + script: export OS=linux; export COMPILER='bazel'; export UBUNTU='16.04'; extras/scripts/postsubmit.sh + DebugPlain - compiler: gcc env: COMPILER=gcc-5 UBUNTU=14.04 TEST=ReleasePlain install: export OS=linux; export COMPILER='gcc-5'; export UBUNTU='14.04'; extras/scripts/travis_ci_install_linux.sh @@ -155,35 +194,56 @@ matrix: env: COMPILER=gcc-5 TEST=ReleasePlain install: export OS=osx; export COMPILER='gcc-5'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='gcc-5'; extras/scripts/postsubmit.sh ReleasePlain - compiler: gcc env: COMPILER=gcc-5 TEST=DebugPlain install: export OS=osx; export COMPILER='gcc-5'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='gcc-5'; extras/scripts/postsubmit.sh DebugPlain - compiler: gcc - env: COMPILER=gcc-6 TEST=ReleasePlain - install: export OS=osx; export COMPILER='gcc-6'; extras/scripts/travis_ci_install_osx.sh + env: COMPILER=gcc-8 TEST=ReleasePlain + install: export OS=osx; export COMPILER='gcc-8'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 - script: export OS=osx; export COMPILER='gcc-6'; extras/scripts/postsubmit.sh ReleasePlain + osx_image: xcode10.2 + script: export OS=osx; export COMPILER='gcc-8'; extras/scripts/postsubmit.sh ReleasePlain - compiler: clang env: COMPILER=clang-4.0 STL=libc++ TEST=ReleasePlain install: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/postsubmit.sh ReleasePlain - compiler: clang env: COMPILER=clang-4.0 STL=libc++ TEST=DebugAsanUbsan install: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='clang-4.0'; export STL='libc++'; extras/scripts/postsubmit.sh DebugAsanUbsan - compiler: clang + env: COMPILER=clang-8.0 STL=libc++ TEST=ReleasePlainNoPch + install: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh + os: osx + osx_image: xcode10.2 + script: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/postsubmit.sh + ReleasePlainNoPch + - compiler: clang + env: COMPILER=clang-8.0 STL=libc++ TEST=DebugAsanUbsanNoPch + install: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh + os: osx + osx_image: xcode10.2 + script: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/postsubmit.sh + DebugAsanUbsanNoPch + - compiler: clang + env: COMPILER=clang-8.0 STL=libc++ TEST=DebugPlainNoPch + install: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh + os: osx + osx_image: xcode10.2 + script: export OS=osx; export COMPILER='clang-8.0'; export STL='libc++'; extras/scripts/postsubmit.sh + DebugPlainNoPch + - compiler: clang env: COMPILER=clang-default STL=libc++ TEST=ReleasePlain install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh @@ -204,7 +264,7 @@ matrix: install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8.2 + osx_image: xcode8.3 script: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/postsubmit.sh ReleasePlain - compiler: clang @@ -212,7 +272,7 @@ matrix: install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode8.2 + osx_image: xcode8.3 script: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/postsubmit.sh DebugAsan - compiler: clang @@ -236,7 +296,7 @@ matrix: install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode10 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/postsubmit.sh ReleasePlain - compiler: clang @@ -244,7 +304,7 @@ matrix: install: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/travis_ci_install_osx.sh os: osx - osx_image: xcode10 + osx_image: xcode10.2 script: export OS=osx; export COMPILER='clang-default'; export STL='libc++'; extras/scripts/postsubmit.sh DebugAsanUbsan services: @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/google/fruit.git" } - version: "3c40e442d52aee6fa696ab5aaf449645c83ab6fa" + version: "d1608a5732fc44e29a067e4b578888d0ec32291d" license_type: NOTICE last_upgrade_date { - year: 2018 - month: 10 - day: 29 + year: 2019 + month: 5 + day: 2 } } diff --git a/cmake-modules/FindFruit.cmake b/cmake-modules/FindFruit.cmake new file mode 100644 index 0000000..a6155cd --- /dev/null +++ b/cmake-modules/FindFruit.cmake @@ -0,0 +1,24 @@ +# You can set your own route by setting FRUIT_INSTALLED_DIR: +# set(ENV{FRUIT_INSTALLED_DIR} "/path/to/fruit/build") + +find_path(FRUIT_INCLUDE_DIR fruit.h + HINTS ( + FRUIT_INSTALLED_DIR + /usr + /usr/local + ) + PATH_SUFFIXES include/fruit include fruit +) + +find_library(FRUIT_LIBRARY + NAMES fruit + HINTS ( + FRUIT_INSTALLED_DIR + /usr + /usr/local + ) + PATH_SUFFIXES lib ${FRUIT_INSTALLED_DIR} +) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(fruit DEFAULT_MSG FRUIT_LIBRARY FRUIT_INCLUDE_DIR) diff --git a/conanfile.py b/conanfile.py index 93eeebd..e5419a9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,6 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanException +import os class FruitConan(ConanFile): @@ -7,11 +8,14 @@ class FruitConan(ConanFile): version = "3.4.0" license = "Apache" url = "https://github.com/google/fruit" + homepage = "https://github.com/google/fruit" description = "C++ dependency injection framework" settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False], "use_boost": [True, False]} - default_options = "shared=False", "use_boost=True" + default_options = {"shared": False, "use_boost": True} generators = "cmake" + exports = "COPYING" + _source_subfolder = "source_subfolder" def configure(self): min_version = { @@ -33,17 +37,19 @@ class FruitConan(ConanFile): self.requires("boost/1.68.0@conan/stable") def source(self): - self.run("git clone https://github.com/google/fruit") - self.run("cd fruit && git checkout v%s" % self.version) + tools.get("{0}/archive/v{1}.tar.gz".format(self.homepage, self.version)) + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) # This small hack might be useful to guarantee proper /MT /MD linkage # in MSVC if the packaged project doesn't have variables to set it # properly - tools.replace_in_file("fruit/CMakeLists.txt", "project(Fruit)", + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "project(Fruit)", '''PROJECT(Myfruit) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup()''') - def build(self): + def _configure_cmake(self): cmake = CMake(self) cmake.definitions["FRUIT_IS_BEING_BUILT_BY_CONAN"] = "YES" cmake.definitions["BUILD_SHARED_LIBS"] = "YES" if self.options.shared else "NO" @@ -55,20 +61,20 @@ conan_basic_setup()''') if self.settings.os == "Windows": cmake.definitions["FRUIT_TESTS_USE_PRECOMPILED_HEADERS"] = "NO" cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type - cmake.configure(source_folder="fruit") + cmake.configure(source_folder=self._source_subfolder) + return cmake + + def build(self): + cmake = self._configure_cmake() cmake.build() - cmake.install() def package(self): - self.copy("*.h", dst="include", src="include") - self.copy("*.h", dst="include", src="fruit/include") - self.copy("*fruit.lib", dst="lib", keep_path=False) - self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.so", dst="lib", keep_path=False) - self.copy("*.dylib", dst="lib", keep_path=False) - self.copy("*.a", dst="lib", keep_path=False) - tools.save("LICENSE", tools.load("fruit/COPYING")) - self.copy("COPYING", dst="licenses", ignore_case=True, keep_path=False) + cmake = self._configure_cmake() + cmake.install() + + self.copy("COPYING", dst="licenses", ignore_case=True, keep_path=False, + src=self._source_subfolder) def package_info(self): + self.cpp_info.includedirs = ["include"] self.cpp_info.libs = ["fruit"] diff --git a/extras/bazel_root/WORKSPACE b/extras/bazel_root/WORKSPACE index 68f44c8..8622415 100644 --- a/extras/bazel_root/WORKSPACE +++ b/extras/bazel_root/WORKSPACE @@ -1,3 +1,5 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + git_repository( name = "com_google_googletest", remote = "https://github.com/google/googletest", diff --git a/extras/benchmark/format_bench_results.py b/extras/benchmark/format_bench_results.py index f95a483..49c4893 100755 --- a/extras/benchmark/format_bench_results.py +++ b/extras/benchmark/format_bench_results.py @@ -49,7 +49,7 @@ def extract_results(bench_results, fixed_benchmark_params, column_dimension, row raise Exception( 'Found multiple benchmark results with the same fixed benchmark params, benchmark param for row and benchmark param for column, so a result can\'t be uniquely determined. ' + 'Consider adding additional values in fixed_benchmark_params. Remaining dimensions: %s vs %s' % ( - remaining_dimensions, previous_remaining_dimensions)) + remaining_dimensions, previous_remaining_dimensions)) table_data[row_value][column_value] = results[result_dimension] remaining_dimensions_by_row_column[(row_value, column_value)] = remaining_dimensions except Exception as e: @@ -257,6 +257,7 @@ def make_immutable(x): def dict_pretty_printer(dict_data): if isinstance(dict_data, list): dict_data = {make_immutable(mapping['from']): mapping['to'] for mapping in dict_data} + def pretty_print(s): if s in dict_data: return dict_data[s] @@ -312,7 +313,6 @@ def main(): else: baseline_bench_results = None - with open(args.benchmark_tables_definition, 'r') as f: for table_definition in yaml.load(f)["tables"]: try: diff --git a/extras/benchmark/no_di_library_source_generator.py b/extras/benchmark/no_di_library_source_generator.py index 6b66aa9..2d91d04 100644 --- a/extras/benchmark/no_di_library_source_generator.py +++ b/extras/benchmark/no_di_library_source_generator.py @@ -148,7 +148,7 @@ Class{class_index}::Class{class_index}({constructor_params}) def _generate_main(injection_graph, use_interfaces, use_new_delete, generate_runtime_bench_code): [toplevel_class_index] = [node_id for node_id in injection_graph.nodes_iter() - if not injection_graph.predecessors(node_id)] + if not injection_graph.predecessors(node_id)] if use_interfaces: include_directives = ''.join('#include "class%s.h"\n' % index diff --git a/extras/benchmark/run_benchmarks.py b/extras/benchmark/run_benchmarks.py index 449d81d..d19232b 100755 --- a/extras/benchmark/run_benchmarks.py +++ b/extras/benchmark/run_benchmarks.py @@ -301,12 +301,12 @@ class GenericGeneratedSourcesBenchmark: return parse_results(results.splitlines()) def run_startup_benchmark(self): - N=1000 + n = 1000 start = timer() - for i in range(0, N): + for i in range(0, n): run_command(self.tmpdir + '/main', args = []) end = timer() - result = {'startup_time': (end - start) / N} + result = {'startup_time': (end - start) / n} return result def run_executable_size_benchmark(self): @@ -600,11 +600,11 @@ def run_benchmark(benchmark, max_runs, timeout_hours, output_file, min_runs=3): if abs(confidence_interval_2dig[0] - confidence_interval_2dig[1]) > numpy.finfo(float).eps * 10: if len(results) < max_runs: print("Running again to get more precision on the metric %s. Current confidence interval: [%.3g, %.3g]" % ( - dimension, confidence_interval[0], confidence_interval[1])) + dimension, confidence_interval[0], confidence_interval[1])) break else: print("Warning: couldn't determine a precise result for the metric %s. Confidence interval: [%.3g, %.3g]" % ( - dimension, confidence_interval[0], confidence_interval[1])) + dimension, confidence_interval[0], confidence_interval[1])) else: # We've reached sufficient precision in all metrics, or we've reached the max number of runs. break @@ -641,8 +641,7 @@ def expand_benchmark_definition(benchmark_definition): """ dict_keys = sorted(benchmark_definition.keys()) # Turn non-list values into single-item lists. - benchmark_definition = {dict_key: value if isinstance(value, list) - else [value] + benchmark_definition = {dict_key: value if isinstance(value, list) else [value] for dict_key, value in benchmark_definition.items()} # Compute the cartesian product of the value lists value_combinations = itertools.product(*(benchmark_definition[dict_key] for dict_key in dict_keys)) @@ -728,7 +727,7 @@ def main(): benchmark_name = benchmark_definition['name'] if (benchmark_name in {'boost_di_compile_time', 'boost_di_run_time', 'boost_di_executable_size'} - and args.boost_di_sources_dir is None): + and args.boost_di_sources_dir is None): raise Exception('Error: you need to specify the --boost-di-sources-dir flag in order to run Boost.DI benchmarks.') if benchmark_name == 'new_delete_run_time': diff --git a/extras/dockerfiles/Dockerfile.ubuntu-19.04 b/extras/dockerfiles/Dockerfile.ubuntu-19.04 new file mode 100644 index 0000000..7939990 --- /dev/null +++ b/extras/dockerfiles/Dockerfile.ubuntu-19.04 @@ -0,0 +1,9 @@ +FROM ubuntu:19.04 +MAINTAINER Marco Poletti <poletti.marco@gmail.com> + +COPY ubuntu-19.04_custom.list /etc/apt/sources.list.d/ +COPY common_install.sh common_cleanup.sh ubuntu-19.04_install.sh / + +RUN bash -x /common_install.sh && \ + bash -x /ubuntu-19.04_install.sh && \ + bash -x /common_cleanup.sh diff --git a/extras/dockerfiles/Dockerfile.ubuntu_arm-18.04 b/extras/dockerfiles/Dockerfile.ubuntu_arm-18.04 new file mode 100644 index 0000000..852abb5 --- /dev/null +++ b/extras/dockerfiles/Dockerfile.ubuntu_arm-18.04 @@ -0,0 +1,9 @@ +FROM multiarch/ubuntu-core:arm64-bionic +MAINTAINER Marco Poletti <poletti.marco@gmail.com> + +COPY ubuntu_arm-18.04_custom.list /etc/apt/sources.list.d/ +COPY common_install.sh common_cleanup.sh ubuntu_arm-18.04_install.sh / + +RUN bash -x /common_install.sh && \ + bash -x /ubuntu_arm-18.04_install.sh && \ + bash -x /common_cleanup.sh diff --git a/extras/dockerfiles/common_install.sh b/extras/dockerfiles/common_install.sh index 1215ebd..f92136c 100644 --- a/extras/dockerfiles/common_install.sh +++ b/extras/dockerfiles/common_install.sh @@ -20,9 +20,6 @@ apt-get install -y --allow-unauthenticated --no-install-recommends \ make \ cmake \ libboost-dev \ - g++-5 \ - clang-3.9 \ - clang-4.0 \ libc++-dev \ python3-pip \ python3-setuptools \ diff --git a/extras/dockerfiles/ubuntu-14.04_install.sh b/extras/dockerfiles/ubuntu-14.04_install.sh index 974c3d1..3e643f8 100644 --- a/extras/dockerfiles/ubuntu-14.04_install.sh +++ b/extras/dockerfiles/ubuntu-14.04_install.sh @@ -7,4 +7,7 @@ apt-get install -y --allow-unauthenticated --no-install-recommends \ clang-3.6 \ clang-3.7 \ clang-3.8 \ + clang-3.9 \ + clang-4.0 \ + g++-5 \ g++-4.9 diff --git a/extras/dockerfiles/ubuntu-16.04_install.sh b/extras/dockerfiles/ubuntu-16.04_install.sh index 391231b..4d47e56 100644 --- a/extras/dockerfiles/ubuntu-16.04_install.sh +++ b/extras/dockerfiles/ubuntu-16.04_install.sh @@ -13,10 +13,14 @@ apt-get install -y --allow-unauthenticated --no-install-recommends \ clang-3.6 \ clang-3.7 \ clang-3.8 \ + clang-3.9 \ + clang-4.0 \ + g++-5 \ g++-4.9 \ g++-6 \ python \ bazel \ + git \ openjdk-8-jdk \ clang-format diff --git a/extras/dockerfiles/ubuntu-17.04_install.sh b/extras/dockerfiles/ubuntu-17.04_install.sh index 89a9f5c..6c774ef 100644 --- a/extras/dockerfiles/ubuntu-17.04_install.sh +++ b/extras/dockerfiles/ubuntu-17.04_install.sh @@ -7,6 +7,9 @@ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F apt-get install -y --allow-unauthenticated --no-install-recommends \ clang-3.7 \ clang-3.8 \ + clang-3.9 \ + clang-4.0 \ + g++-5 \ g++-4.9 \ g++-6 \ python \ diff --git a/extras/dockerfiles/ubuntu-17.10_install.sh b/extras/dockerfiles/ubuntu-17.10_install.sh index 799ddf9..07147aa 100644 --- a/extras/dockerfiles/ubuntu-17.10_install.sh +++ b/extras/dockerfiles/ubuntu-17.10_install.sh @@ -6,6 +6,9 @@ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F apt-get install -y --allow-unauthenticated --no-install-recommends \ g++-7 \ + g++-5 \ + clang-3.9 \ + clang-4.0 \ clang-3.8 \ clang-5.0 \ python \ diff --git a/extras/dockerfiles/ubuntu-18.04_install.sh b/extras/dockerfiles/ubuntu-18.04_install.sh index fa240d3..3d4cde7 100644 --- a/extras/dockerfiles/ubuntu-18.04_install.sh +++ b/extras/dockerfiles/ubuntu-18.04_install.sh @@ -2,11 +2,26 @@ set -e +apt-get install -y --no-install-recommends \ + curl + +# For the Bazel repository +curl https://bazel.build/bazel-release.pub.gpg | apt-key add - + +echo 'deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8' >> /etc/apt/sources.list.d/bazel.list + +apt-get update -qq + apt-get install -y --allow-unauthenticated --no-install-recommends \ - g++-7 \ g++-8 \ + g++-7 \ + g++-5 \ + clang-3.9 \ + clang-4.0 \ clang-5.0 \ clang-6.0 \ + bazel \ + git \ python \ python3-sh \ python3-typed-ast \ diff --git a/extras/dockerfiles/ubuntu-18.10_install.sh b/extras/dockerfiles/ubuntu-18.10_install.sh index f21f41d..1357b11 100644 --- a/extras/dockerfiles/ubuntu-18.10_install.sh +++ b/extras/dockerfiles/ubuntu-18.10_install.sh @@ -5,6 +5,9 @@ set -e apt-get install -y --allow-unauthenticated --no-install-recommends \ g++-7 \ g++-8 \ + g++-5 \ + clang-3.9 \ + clang-4.0 \ clang-6.0 \ clang-7 \ python \ diff --git a/extras/dockerfiles/ubuntu-19.04_custom.list b/extras/dockerfiles/ubuntu-19.04_custom.list new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/extras/dockerfiles/ubuntu-19.04_custom.list diff --git a/extras/dockerfiles/ubuntu-19.04_install.sh b/extras/dockerfiles/ubuntu-19.04_install.sh new file mode 100644 index 0000000..2f78bdd --- /dev/null +++ b/extras/dockerfiles/ubuntu-19.04_install.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +apt-get install -y --allow-unauthenticated --no-install-recommends \ + g++-7 \ + g++-8 \ + g++-9 \ + clang-6.0 \ + clang-7 \ + clang-8 \ + python \ + python3-sh \ + python3-typed-ast \ + clang-format diff --git a/extras/dockerfiles/ubuntu_arm-16.04_install.sh b/extras/dockerfiles/ubuntu_arm-16.04_install.sh index c04008d..504b2c0 100644 --- a/extras/dockerfiles/ubuntu_arm-16.04_install.sh +++ b/extras/dockerfiles/ubuntu_arm-16.04_install.sh @@ -6,6 +6,9 @@ apt-get install -y --allow-unauthenticated --no-install-recommends \ clang-3.5 \ clang-3.6 \ clang-3.7 \ + clang-3.9 \ + clang-4.0 \ + g++-5 \ g++-4.9 \ g++-6 \ python \ diff --git a/extras/dockerfiles/ubuntu_arm-17.10_install.sh b/extras/dockerfiles/ubuntu_arm-17.10_install.sh index 8883fd4..9c09139 100644 --- a/extras/dockerfiles/ubuntu_arm-17.10_install.sh +++ b/extras/dockerfiles/ubuntu_arm-17.10_install.sh @@ -6,6 +6,9 @@ set -e apt-get install -y --allow-unauthenticated --no-install-recommends \ g++-7 \ + g++-5 \ + clang-3.9 \ + clang-4.0 \ clang-5.0 \ python \ python3-sh \ diff --git a/extras/dockerfiles/ubuntu_arm-18.04_custom.list b/extras/dockerfiles/ubuntu_arm-18.04_custom.list new file mode 100644 index 0000000..e347ae1 --- /dev/null +++ b/extras/dockerfiles/ubuntu_arm-18.04_custom.list @@ -0,0 +1,8 @@ +#deb [trusted=yes] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic main +#deb-src [trusted=yes] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic main +#deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic main +#deb-src [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic main +#deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-4.0 main +#deb-src [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-4.0 main +#deb [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main +#deb-src [trusted=yes] http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main diff --git a/extras/dockerfiles/ubuntu_arm-18.04_install.sh b/extras/dockerfiles/ubuntu_arm-18.04_install.sh new file mode 100644 index 0000000..8e21982 --- /dev/null +++ b/extras/dockerfiles/ubuntu_arm-18.04_install.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +apt-get install -y --allow-unauthenticated --no-install-recommends \ + g++-8 \ + g++-7 \ + g++-5 \ + clang-3.9 \ + clang-4.0 \ + clang-5.0 \ + clang-6.0 \ + python \ + python3-sh \ + python3-typed-ast \ + clang-format diff --git a/extras/scripts/analyze_template_instantiations_clang_diagnostics.py b/extras/scripts/analyze_template_instantiations_clang_diagnostics.py index 3e661c8..247b18d 100755 --- a/extras/scripts/analyze_template_instantiations_clang_diagnostics.py +++ b/extras/scripts/analyze_template_instantiations_clang_diagnostics.py @@ -23,7 +23,7 @@ import ply.lex as lex import ply.yacc as yacc from functools import lru_cache as memoize -diagnostic_header_pattern = re.compile('[^ ]+\.[^ ]+:[0-9]+:[0-9]+: ([^ ]*): (.*)') +diagnostic_header_pattern = re.compile(r'[^ ]+\.[^ ]+:[0-9]+:[0-9]+: ([^ ]*): (.*)') in_file_included_from_pattern = re.compile('In file included from .*:') in_instantiation_of_template_pattern = re.compile('in instantiation of (.*) (?:requested|required) here') static_warning_marked_deprecated_here_pattern = re.compile('\'static_warning\' has been explicitly marked deprecated here') @@ -54,7 +54,7 @@ t_LPAREN = r'\(' t_RPAREN = r'\)' t_LBRACKET = r'\[' t_RBRACKET = r'\]' -t_LBRACE = r'}' +t_LBRACE = r'}' t_RBRACE = r'{' t_LESS_THAN = r'<' t_GREATER_THAN = r'>' @@ -89,7 +89,7 @@ class TerminalAstNode(AstNode): self.max_line_length = 0 else: # This never happens ATM, so we don't handle it. - assert not '\n' in s + assert '\n' not in s self.first_line_length = len(s) self.last_line_length = len(s) @@ -265,6 +265,7 @@ def p_balanced_string_with_balanced_token_no_comma_separated_elems(p): p_1 = p[1] p_2 = p[2] p_3 = p[3] + def result(current_indent, current_line_length, inside_meta_type, last_token_was_type_wrapper, accept_single_line_only): return compute_layout(p_1, [], p_2, p_3, current_indent, current_line_length, inside_meta_type, last_token_was_type_wrapper, accept_single_line_only) @@ -281,6 +282,7 @@ def p_balanced_string_with_balanced_token_some_comma_separated_elems(p): p_3 = p[3] p_4 = p[4] p_5 = p[5] + def result(current_indent, current_line_length, inside_meta_type, last_token_was_type_wrapper, accept_single_line_only): if not inside_meta_type: if p_1 == '(' and p_4 == ')': diff --git a/extras/scripts/postsubmit-helper.sh b/extras/scripts/postsubmit-helper.sh index 8188681..6d361a9 100755 --- a/extras/scripts/postsubmit-helper.sh +++ b/extras/scripts/postsubmit-helper.sh @@ -32,6 +32,11 @@ gcc-8) export CXX=g++-8 ;; +gcc-9) + export CC=gcc-9 + export CXX=g++-9 + ;; + clang-3.5) export CC=clang-3.5 export CXX=clang++-3.5 @@ -86,6 +91,11 @@ clang-7.0) export CXX=clang++-7 ;; +clang-8.0) + export CC=clang-8 + export CXX=clang++-8 + ;; + clang-default) export CC=clang export CXX=clang++ diff --git a/extras/scripts/travis_ci_install_osx.sh b/extras/scripts/travis_ci_install_osx.sh index cb80087..3d86634 100755 --- a/extras/scripts/travis_ci_install_osx.sh +++ b/extras/scripts/travis_ci_install_osx.sh @@ -8,16 +8,14 @@ install_brew_package() { time (brew outdated "$1" || brew upgrade "$@") else # Package not installed yet, install. - # If there are conflicts, try overwriting the files (these are in /usr/local anyway so it should be ok). - time (brew install "$@" || brew link --overwrite gcc49) + # If there are issues, try upgrading instead. + time (brew install "$@" || brew upgrade "$@") fi } time brew update -# For md5sum -install_brew_package md5sha1sum -# For `timeout' +# For md5sum, timeout install_brew_package coreutils if [[ "${INSTALL_VALGRIND}" == "1" ]] @@ -31,18 +29,27 @@ case "${COMPILER}" in gcc-4.9) install_brew_package gcc@4.9 ;; gcc-5) install_brew_package gcc@5 ;; gcc-6) install_brew_package gcc@6 ;; +gcc-7) install_brew_package gcc@7 ;; +gcc-8) install_brew_package gcc@8 ;; clang-default) ;; -clang-3.7) install_brew_package llvm@3.7 --with-clang --with-libcxx;; -clang-3.8) install_brew_package llvm@3.8 --with-clang --with-libcxx;; clang-3.9) install_brew_package llvm@3.9 --with-clang --with-libcxx;; -clang-4.0) install_brew_package llvm --with-clang --with-libcxx;; +clang-4.0) install_brew_package llvm@4 --with-clang --with-libcxx;; +clang-5.0) install_brew_package llvm@5 --with-clang --with-libcxx;; +clang-6.0) install_brew_package llvm@6 --with-clang --with-libcxx;; +clang-7.0) install_brew_package llvm@7 --with-clang --with-libcxx;; +clang-8.0) install_brew_package llvm@8 --with-clang --with-libcxx;; *) echo "Compiler not supported: ${COMPILER}. See travis_ci_install_osx.sh"; exit 1 ;; esac +install_brew_package boost install_brew_package python time pip3 install pytest time pip3 install pytest-xdist time pip3 install sh +# TODO: remove this. +ls -l /usr/local/include +find /usr/local/include/boost* + # This adds python-installed executables to PATH (notably py.test). export PATH="$(brew --prefix)/bin:$PATH" diff --git a/extras/scripts/travis_yml_generator.py b/extras/scripts/travis_yml_generator.py index 9188269..ddaaedf 100755 --- a/extras/scripts/travis_yml_generator.py +++ b/extras/scripts/travis_yml_generator.py @@ -19,130 +19,147 @@ import yaml build_matrix_smoke_test_rows = [] build_matrix_rows = [] + def determine_compiler_kind(compiler): - if compiler.startswith('gcc'): - return 'gcc' - elif compiler.startswith('clang'): - return 'clang' - else: - raise Exception('Unexpected compiler: %s' % compiler) + if compiler.startswith('gcc'): + return 'gcc' + elif compiler.startswith('clang'): + return 'clang' + else: + raise Exception('Unexpected compiler: %s' % compiler) + def determine_tests(asan, ubsan, smoke_tests, use_precompiled_headers_in_tests, exclude_tests, include_only_tests): - tests = [] - has_debug_build = False - tests += ['ReleasePlain'] - if asan: - has_debug_build = True - if ubsan: - tests += ['DebugAsanUbsan'] + tests = [] + has_debug_build = False + tests += ['ReleasePlain'] + if asan: + has_debug_build = True + if ubsan: + tests += ['DebugAsanUbsan'] + else: + tests += ['DebugAsan'] + if ubsan and not asan: + raise Exception('Enabling UBSan but not ASan is not currently supported.') + if not has_debug_build: + tests += ['DebugPlain'] + for smoke_test in smoke_tests: + if smoke_test not in tests: + tests += [smoke_test] + excessive_excluded_tests = set(exclude_tests) - set(tests) + if excessive_excluded_tests: + raise Exception( + 'Some tests were excluded but were not going to run anyway: %s. ' + 'Tests to run (ignoring the possible NoPch prefix): %s' + % (excessive_excluded_tests, tests)) + if include_only_tests is not None: + if exclude_tests != []: + raise Exception('Using exclude_tests and include_only_tests together is not supported.') + tests = include_only_tests else: - tests += ['DebugAsan'] - if ubsan and not asan: - raise Exception('Enabling UBSan but not ASan is not currently supported.') - if not has_debug_build: - tests += ['DebugPlain'] - for smoke_test in smoke_tests: - if smoke_test not in tests: - tests += [smoke_test] - excessive_excluded_tests = set(exclude_tests) - set(tests) - if excessive_excluded_tests: - raise Exception( - 'Some tests were excluded but were not going to run anyway: %s. ' - 'Tests to run (ignoring the possible NoPch prefix): %s' - % (excessive_excluded_tests, tests)) - if include_only_tests is not None: - if exclude_tests != []: - raise Exception('Using exclude_tests and include_only_tests together is not supported.') - tests = include_only_tests - else: - tests = [test for test in tests if test not in exclude_tests] - if not use_precompiled_headers_in_tests: - tests = [test + 'NoPch' for test in tests] - return tests + tests = [test for test in tests if test not in exclude_tests] + if not use_precompiled_headers_in_tests: + tests = [test + 'NoPch' for test in tests] + return tests + def generate_export_statements_for_env(env): - return ' '.join(['export %s=\'%s\';' % (var_name, value) for (var_name, value) in sorted(env.items())]) + return ' '.join(['export %s=\'%s\';' % (var_name, value) for (var_name, value) in sorted(env.items())]) + def generate_env_string_for_env(env): - return ' '.join(['%s=%s' % (var_name, value) for (var_name, value) in sorted(env.items())]) + return ' '.join(['%s=%s' % (var_name, value) for (var_name, value) in sorted(env.items())]) + def add_ubuntu_tests(ubuntu_version, compiler, os='linux', stl=None, asan=True, ubsan=True, use_precompiled_headers_in_tests=True, smoke_tests=[], exclude_tests=[], include_only_tests=None): - env = { - 'UBUNTU': ubuntu_version, - 'COMPILER': compiler - } - if stl is not None: - env['STL'] = stl - compiler_kind = determine_compiler_kind(compiler) - export_statements = 'export OS=' + os + '; ' + generate_export_statements_for_env(env=env) - test_environment_template = {'os': 'linux', 'compiler': compiler_kind, - 'install': '%s extras/scripts/travis_ci_install_linux.sh' % export_statements} - tests = determine_tests(asan, ubsan, smoke_tests, - use_precompiled_headers_in_tests=use_precompiled_headers_in_tests, - exclude_tests=exclude_tests, - include_only_tests=include_only_tests) - for test in tests: - test_environment = test_environment_template.copy() - test_environment['script'] = '%s extras/scripts/postsubmit.sh %s' % (export_statements, test) - # The TEST variable has no effect on the test run, but allows to see the test name in the Travis CI dashboard. - test_environment['env'] = generate_env_string_for_env(env) + " TEST=%s" % test - if test in smoke_tests: - build_matrix_smoke_test_rows.append(test_environment) - else: - build_matrix_rows.append(test_environment) + env = { + 'UBUNTU': ubuntu_version, + 'COMPILER': compiler + } + if stl is not None: + env['STL'] = stl + compiler_kind = determine_compiler_kind(compiler) + export_statements = 'export OS=' + os + '; ' + generate_export_statements_for_env(env=env) + test_environment_template = {'os': 'linux', 'compiler': compiler_kind, + 'install': '%s extras/scripts/travis_ci_install_linux.sh' % export_statements} + tests = determine_tests(asan, ubsan, smoke_tests, + use_precompiled_headers_in_tests=use_precompiled_headers_in_tests, + exclude_tests=exclude_tests, + include_only_tests=include_only_tests) + for test in tests: + test_environment = test_environment_template.copy() + test_environment['script'] = '%s extras/scripts/postsubmit.sh %s' % (export_statements, test) + # The TEST variable has no effect on the test run, but allows to see the test name in the Travis CI dashboard. + test_environment['env'] = generate_env_string_for_env(env) + " TEST=%s" % test + if test in smoke_tests: + build_matrix_smoke_test_rows.append(test_environment) + else: + build_matrix_rows.append(test_environment) def add_osx_tests(compiler, xcode_version=None, stl=None, asan=True, ubsan=True, use_precompiled_headers_in_tests=True, smoke_tests=[], exclude_tests=[], include_only_tests=None): - env = {'COMPILER': compiler} - if stl is not None: - env['STL'] = stl - compiler_kind = determine_compiler_kind(compiler) - export_statements = 'export OS=osx; ' + generate_export_statements_for_env(env=env) - test_environment_template = {'os': 'osx', 'compiler': compiler_kind, - 'install': '%s extras/scripts/travis_ci_install_osx.sh' % export_statements} - if xcode_version is not None: - test_environment_template['osx_image'] = 'xcode%s' % xcode_version - - tests = determine_tests(asan, ubsan, smoke_tests, - use_precompiled_headers_in_tests=use_precompiled_headers_in_tests, - exclude_tests=exclude_tests, include_only_tests=include_only_tests) - for test in tests: - test_environment = test_environment_template.copy() - test_environment['script'] = '%s extras/scripts/postsubmit.sh %s' % (export_statements, test) - # The TEST variable has no effect on the test run, but allows to see the test name in the Travis CI dashboard. - test_environment['env'] = generate_env_string_for_env(env) + " TEST=%s" % test - if test in smoke_tests: - build_matrix_smoke_test_rows.append(test_environment) - else: - build_matrix_rows.append(test_environment) + env = {'COMPILER': compiler} + if stl is not None: + env['STL'] = stl + compiler_kind = determine_compiler_kind(compiler) + export_statements = 'export OS=osx; ' + generate_export_statements_for_env(env=env) + test_environment_template = {'os': 'osx', 'compiler': compiler_kind, + 'install': '%s extras/scripts/travis_ci_install_osx.sh' % export_statements} + if xcode_version is not None: + test_environment_template['osx_image'] = 'xcode%s' % xcode_version + + tests = determine_tests(asan, ubsan, smoke_tests, + use_precompiled_headers_in_tests=use_precompiled_headers_in_tests, + exclude_tests=exclude_tests, include_only_tests=include_only_tests) + for test in tests: + test_environment = test_environment_template.copy() + test_environment['script'] = '%s extras/scripts/postsubmit.sh %s' % (export_statements, test) + # The TEST variable has no effect on the test run, but allows to see the test name in the Travis CI dashboard. + test_environment['env'] = generate_env_string_for_env(env) + " TEST=%s" % test + if test in smoke_tests: + build_matrix_smoke_test_rows.append(test_environment) + else: + build_matrix_rows.append(test_environment) def add_bazel_tests(ubuntu_version, smoke_tests=[]): - env = { - 'UBUNTU': ubuntu_version, - 'COMPILER': 'bazel', - } - test = 'DebugPlain' - export_statements = 'export OS=linux; ' + generate_export_statements_for_env(env=env) - test_environment = {'os': 'linux', - 'compiler': 'gcc', - 'env': generate_env_string_for_env(env), - 'install': '%s extras/scripts/travis_ci_install_linux.sh' % export_statements, - 'script': '%s extras/scripts/postsubmit.sh %s' % (export_statements, test)} - if test in smoke_tests: - build_matrix_smoke_test_rows.append(test_environment) - else: - build_matrix_rows.append(test_environment) + env = { + 'UBUNTU': ubuntu_version, + 'COMPILER': 'bazel', + } + test = 'DebugPlain' + export_statements = 'export OS=linux; ' + generate_export_statements_for_env(env=env) + test_environment = {'os': 'linux', + 'compiler': 'gcc', + 'env': generate_env_string_for_env(env), + 'install': '%s extras/scripts/travis_ci_install_linux.sh' % export_statements, + 'script': '%s extras/scripts/postsubmit.sh %s' % (export_statements, test)} + if test in smoke_tests: + build_matrix_smoke_test_rows.append(test_environment) + else: + build_matrix_rows.append(test_environment) + # TODO: re-enable ASan/UBSan once they work in Travis CI. ATM (as of 18 November 2017) they fail due to https://github.com/google/sanitizers/issues/837 -add_ubuntu_tests(ubuntu_version='18.10', compiler='gcc-8', asan=False, ubsan=False, smoke_tests=['DebugPlain', 'ReleasePlain']) +add_ubuntu_tests(ubuntu_version='19.04', compiler='gcc-9', asan=False, ubsan=False, + smoke_tests=['DebugPlain', 'ReleasePlain']) +add_ubuntu_tests(ubuntu_version='19.04', compiler='clang-6.0', stl='libstdc++', + smoke_tests=['DebugPlain', 'DebugAsanUbsan', 'ReleasePlain']) +add_ubuntu_tests(ubuntu_version='19.04', compiler='clang-8.0', stl='libstdc++', + # Disabled due to https://bugs.llvm.org/show_bug.cgi?id=41625. + use_precompiled_headers_in_tests=False) + +add_ubuntu_tests(ubuntu_version='18.10', compiler='gcc-8', asan=False, ubsan=False) add_ubuntu_tests(ubuntu_version='18.10', compiler='clang-4.0', stl='libstdc++') -add_ubuntu_tests(ubuntu_version='18.10', compiler='clang-7.0', stl='libstdc++', smoke_tests=['DebugPlain', 'DebugAsanUbsan', 'ReleasePlain']) +add_ubuntu_tests(ubuntu_version='18.10', compiler='clang-7.0', stl='libstdc++', + # Disabled due to https://bugs.llvm.org/show_bug.cgi?id=41625. + use_precompiled_headers_in_tests=False) -add_bazel_tests(ubuntu_version='16.04', smoke_tests=['DebugPlain']) +add_bazel_tests(ubuntu_version='18.04', smoke_tests=['DebugPlain']) +add_bazel_tests(ubuntu_version='16.04') # ASan/UBSan are disabled for all these, the analysis on later versions is better anyway. # Also, in some combinations they wouldn't work. @@ -157,17 +174,20 @@ add_ubuntu_tests(ubuntu_version='14.04', compiler='clang-3.9', stl='libc++', asa # overridden at runtime. This was likely caused by different translation units being compiled with different # visibility settings. # and the build eventually fails or times out. -add_osx_tests(compiler='gcc-5', xcode_version='8', asan=False, ubsan=False) -add_osx_tests(compiler='gcc-6', xcode_version='8', asan=False, ubsan=False, smoke_tests=['DebugPlain']) -add_osx_tests(compiler='clang-4.0', xcode_version='8', stl='libc++', smoke_tests=['DebugPlain']) +add_osx_tests(compiler='gcc-5', xcode_version='10.2', asan=False, ubsan=False) +add_osx_tests(compiler='gcc-8', xcode_version='10.2', asan=False, ubsan=False, smoke_tests=['DebugPlain']) +add_osx_tests(compiler='clang-4.0', xcode_version='10.2', stl='libc++') +add_osx_tests(compiler='clang-8.0', xcode_version='10.2', stl='libc++', smoke_tests=['DebugPlain'], + # Disabled due to https://bugs.llvm.org/show_bug.cgi?id=41625. + use_precompiled_headers_in_tests=False) # UBSan is disabled because AppleClang does not support -fsanitize=undefined. add_osx_tests(compiler='clang-default', xcode_version='7.3', stl='libc++', ubsan=False) # UBSan is disabled because AppleClang does not support -fsanitize=undefined. -add_osx_tests(compiler='clang-default', xcode_version='8.2', stl='libc++', ubsan=False) +add_osx_tests(compiler='clang-default', xcode_version='8.3', stl='libc++', ubsan=False) add_osx_tests(compiler='clang-default', xcode_version='9.4', stl='libc++') -add_osx_tests(compiler='clang-default', xcode_version='10', stl='libc++', smoke_tests=['DebugPlain']) +add_osx_tests(compiler='clang-default', xcode_version='10.2', stl='libc++', smoke_tests=['DebugPlain']) # ** Disabled combinations ** # @@ -201,22 +221,24 @@ add_osx_tests(compiler='clang-default', xcode_version='10', stl='libc++', smoke_ yaml_file = { - 'sudo': 'required', - 'dist': 'trusty', - 'services' : ['docker'], - 'language': 'cpp', - 'branches': { - 'only': ['master'], - }, - 'matrix': { - 'fast_finish': True, - 'include': build_matrix_smoke_test_rows + build_matrix_rows, - }, + 'sudo': 'required', + 'dist': 'trusty', + 'services': ['docker'], + 'language': 'cpp', + 'branches': { + 'only': ['master'], + }, + 'matrix': { + 'fast_finish': True, + 'include': build_matrix_smoke_test_rows + build_matrix_rows, + }, } + class CustomDumper(yaml.SafeDumper): - def ignore_aliases(self, _data): - return True + def ignore_aliases(self, _data): + return True + print('#') print('# This file was auto-generated from extras/scripts/travis_yml_generator.py, DO NOT EDIT') diff --git a/include/fruit/impl/normalized_component_storage/normalized_component_storage_holder.h b/include/fruit/impl/normalized_component_storage/normalized_component_storage_holder.h index 6b1b7e9..180f297 100644 --- a/include/fruit/impl/normalized_component_storage/normalized_component_storage_holder.h +++ b/include/fruit/impl/normalized_component_storage/normalized_component_storage_holder.h @@ -58,7 +58,7 @@ public: NormalizedComponentStorageHolder(const NormalizedComponentStorage&) = delete; NormalizedComponentStorageHolder& operator=(NormalizedComponentStorageHolder&&) = delete; - NormalizedComponentStorageHolder& operator=(const NormalizedComponentStorageHolder&) = default; + NormalizedComponentStorageHolder& operator=(const NormalizedComponentStorageHolder&) = delete; // We don't use the default destructor because that would require the inclusion of // normalized_component_storage.h. We define this in the cpp file instead. diff --git a/tests/data_structures/test_fixed_size_allocator.py b/tests/data_structures/test_fixed_size_allocator.py index 061ea6e..1f32294 100644 --- a/tests/data_structures/test_fixed_size_allocator.py +++ b/tests/data_structures/test_fixed_size_allocator.py @@ -189,5 +189,5 @@ def test_move_constructor(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/data_structures/test_fixed_size_vector.py b/tests/data_structures/test_fixed_size_vector.py index 91058eb..9dd7a93 100644 --- a/tests/data_structures/test_fixed_size_vector.py +++ b/tests/data_structures/test_fixed_size_vector.py @@ -213,5 +213,5 @@ def test_clear(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/data_structures/test_semistatic_graph.py b/tests/data_structures/test_semistatic_graph.py index f6db0e8..743b416 100644 --- a/tests/data_structures/test_semistatic_graph.py +++ b/tests/data_structures/test_semistatic_graph.py @@ -371,5 +371,5 @@ def test_incomplete_graph(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/data_structures/test_semistatic_map.py b/tests/data_structures/test_semistatic_map.py index e51f13e..3f4d3d0 100644 --- a/tests/data_structures/test_semistatic_map.py +++ b/tests/data_structures/test_semistatic_map.py @@ -210,5 +210,5 @@ def test_move_assignment(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_algos.py b/tests/meta/test_algos.py index 17e1ffa..b0ff2e2 100644 --- a/tests/meta/test_algos.py +++ b/tests/meta/test_algos.py @@ -37,5 +37,5 @@ def test_HasDuplicates(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_basics.py b/tests/meta/test_basics.py index d12a0ae..88d5ad2 100644 --- a/tests/meta/test_basics.py +++ b/tests/meta/test_basics.py @@ -84,5 +84,5 @@ def test_DeferArgs(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_graph.py b/tests/meta/test_graph.py index 8de01ba..73beb87 100644 --- a/tests/meta/test_graph.py +++ b/tests/meta/test_graph.py @@ -59,5 +59,5 @@ def test_GraphFindLoop(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_list.py b/tests/meta/test_list.py index 609d74d..afe0d24 100644 --- a/tests/meta/test_list.py +++ b/tests/meta/test_list.py @@ -43,5 +43,5 @@ def test_FoldList(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_map.py b/tests/meta/test_map.py index 4358a9e..0d9396b 100644 --- a/tests/meta/test_map.py +++ b/tests/meta/test_map.py @@ -74,5 +74,5 @@ def test_GetMapKeys(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_meta_component.py b/tests/meta/test_meta_component.py index 9aafb01..7b9ea4a 100644 --- a/tests/meta/test_meta_component.py +++ b/tests/meta/test_meta_component.py @@ -81,5 +81,5 @@ def test_NumAssistedBefore(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_metaprogramming.py b/tests/meta/test_metaprogramming.py index 1d7f29c..e09adbc 100644 --- a/tests/meta/test_metaprogramming.py +++ b/tests/meta/test_metaprogramming.py @@ -42,5 +42,5 @@ def test_GetNthType(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_proof_trees.py b/tests/meta/test_proof_trees.py index dc14266..31b5922 100644 --- a/tests/meta/test_proof_trees.py +++ b/tests/meta/test_proof_trees.py @@ -70,5 +70,5 @@ def test_IsForestEqualTo(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_set.py b/tests/meta/test_set.py index 5a10579..549624e 100644 --- a/tests/meta/test_set.py +++ b/tests/meta/test_set.py @@ -269,5 +269,5 @@ def test_SetUnion(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/meta/test_vector.py b/tests/meta/test_vector.py index 34dd066..5b812fc 100644 --- a/tests/meta/test_vector.py +++ b/tests/meta/test_vector.py @@ -115,5 +115,5 @@ def test_VectorRemoveFirstN(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_bind_interface.py b/tests/test_bind_interface.py index 14f1b35..ff7c65e 100755 --- a/tests/test_bind_interface.py +++ b/tests/test_bind_interface.py @@ -321,5 +321,5 @@ def test_bind_non_normalized_types_error(): COMMON_DEFINITIONS, source) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_binding_clash.py b/tests/test_binding_clash.py index aad02b7..3b57fad 100755 --- a/tests/test_binding_clash.py +++ b/tests/test_binding_clash.py @@ -42,10 +42,10 @@ COMMON_DEFINITIONS = ''' struct Annotation3 {}; ''' -CONSTRUCTOR_BINDING=( +CONSTRUCTOR_BINDING = ( '', '.registerConstructor<XAnnot()>()') -INTERFACE_BINDING=( +INTERFACE_BINDING = ( ''' struct Y : public X {}; ''', @@ -53,7 +53,7 @@ INTERFACE_BINDING=( .bind<XAnnot, YAnnot>() .registerConstructor<YAnnot()>() ''') -INTERFACE_BINDING2=( +INTERFACE_BINDING2 = ( ''' struct Y2 : public X {}; ''', @@ -61,7 +61,7 @@ INTERFACE_BINDING2=( .bind<XAnnot, Y2Annot>() .registerConstructor<Y2Annot()>() ''') -INSTALL=( +INSTALL = ( ''' fruit::Component<XAnnot> getParentComponent() { return fruit::createComponent() @@ -69,7 +69,7 @@ INSTALL=( } ''', '.install(getParentComponent)') -INSTALL2=( +INSTALL2 = ( ''' fruit::Component<XAnnot> getParentComponent2() { return fruit::createComponent() @@ -77,7 +77,7 @@ INSTALL2=( } ''', '.install(getParentComponent2)') -CONST_BINDING_FROM_INSTALL=( +CONST_BINDING_FROM_INSTALL = ( ''' fruit::Component<const XAnnot> getParentComponent() { return fruit::createComponent() @@ -85,7 +85,7 @@ CONST_BINDING_FROM_INSTALL=( } ''', '.install(getParentComponent)') -CONST_BINDING_FROM_INSTALL2=( +CONST_BINDING_FROM_INSTALL2 = ( ''' fruit::Component<const XAnnot> getParentComponent2() { return fruit::createComponent() @@ -93,12 +93,12 @@ CONST_BINDING_FROM_INSTALL2=( } ''', '.install(getParentComponent2)') -CONST_BINDING=( +CONST_BINDING = ( ''' const X x{}; ''', '.bindInstance<XAnnot, X>(x)') -CONST_BINDING2=( +CONST_BINDING2 = ( ''' const X x2{}; ''', @@ -216,13 +216,13 @@ def test_clash_with_binding(binding1_preparation, binding1, binding2_preparation source, locals()) -CONSTRUCTOR_BINDING_ANNOT1=( +CONSTRUCTOR_BINDING_ANNOT1 = ( '', '.registerConstructor<XAnnot1()>()') -CONSTRUCTOR_BINDING_ANNOT2=( +CONSTRUCTOR_BINDING_ANNOT2 = ( '', '.registerConstructor<XAnnot2()>()') -INTERFACE_BINDING_ANNOT1=( +INTERFACE_BINDING_ANNOT1 = ( ''' struct Y : public X {}; ''', @@ -230,7 +230,7 @@ INTERFACE_BINDING_ANNOT1=( .bind<XAnnot1, YAnnot1>() .registerConstructor<YAnnot1()>() ''') -INTERFACE_BINDING_ANNOT2=( +INTERFACE_BINDING_ANNOT2 = ( ''' struct Z : public X {}; ''', @@ -238,7 +238,7 @@ INTERFACE_BINDING_ANNOT2=( .bind<XAnnot2, ZAnnot2>() .registerConstructor<ZAnnot2()>() ''') -INSTALL_ANNOT1=( +INSTALL_ANNOT1 = ( ''' fruit::Component<XAnnot1> getParentComponent1() { return fruit::createComponent() @@ -246,7 +246,7 @@ INSTALL_ANNOT1=( } ''', '.install(getParentComponent1)') -INSTALL_ANNOT2=( +INSTALL_ANNOT2 = ( ''' fruit::Component<XAnnot2> getParentComponent2() { return fruit::createComponent() @@ -254,7 +254,7 @@ INSTALL_ANNOT2=( } ''', '.install(getParentComponent2)') -CONST_BINDING_FROM_INSTALL_ANNOT1=( +CONST_BINDING_FROM_INSTALL_ANNOT1 = ( ''' fruit::Component<ConstXAnnot1> getParentComponent1() { return fruit::createComponent() @@ -262,7 +262,7 @@ CONST_BINDING_FROM_INSTALL_ANNOT1=( } ''', '.install(getParentComponent1)') -CONST_BINDING_FROM_INSTALL_ANNOT2=( +CONST_BINDING_FROM_INSTALL_ANNOT2 = ( ''' fruit::Component<ConstXAnnot2> getParentComponent2() { return fruit::createComponent() @@ -270,12 +270,12 @@ CONST_BINDING_FROM_INSTALL_ANNOT2=( } ''', '.install(getParentComponent2)') -CONST_BINDING_ANNOT1=( +CONST_BINDING_ANNOT1 = ( ''' const X x1{}; ''', '.bindInstance<XAnnot1, X>(x1)') -CONST_BINDING_ANNOT2=( +CONST_BINDING_ANNOT2 = ( ''' const X x2{}; ''', @@ -518,5 +518,5 @@ def test_during_component_merge_consistent_ok(XAnnot): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_binding_compression.py b/tests/test_binding_compression.py index 680449d..1eb1d37 100755 --- a/tests/test_binding_compression.py +++ b/tests/test_binding_compression.py @@ -157,5 +157,5 @@ def test_compression_undone(): COMMON_DEFINITIONS, source) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_class_destruction.py b/tests/test_class_destruction.py index f36c83d..31b9a6e 100644 --- a/tests/test_class_destruction.py +++ b/tests/test_class_destruction.py @@ -169,5 +169,5 @@ def test_injector_creation_and_injection( source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_component.py b/tests/test_component.py index 5bb6017..ad81340 100755 --- a/tests/test_component.py +++ b/tests/test_component.py @@ -76,12 +76,12 @@ def test_move_partial_component(XAnnot): } ''' expect_generic_compile_error( - 'error: use of deleted function .fruit::PartialComponent<Bindings>::PartialComponent\(fruit::PartialComponent<Bindings>&&\).' - + '|error: call to deleted constructor of .fruit::PartialComponent<>.' - # MSVC 2017 - + '|error C2280: .fruit::PartialComponent<>::PartialComponent\(fruit::PartialComponent<> &&\).: attempting to reference a deleted function' - # MSVC 2015 - + '|error C2248: .fruit::PartialComponent<>::PartialComponent.: cannot access private member declared in class .fruit::PartialComponent<>.', + r'error: use of deleted function .fruit::PartialComponent<Bindings>::PartialComponent\(fruit::PartialComponent<Bindings>&&\).' + r'|error: call to deleted constructor of .fruit::PartialComponent<>.' + # MSVC 2017 + r'|error C2280: .fruit::PartialComponent<>::PartialComponent\(fruit::PartialComponent<> &&\).: attempting to reference a deleted function' + # MSVC 2015 + r'|error C2248: .fruit::PartialComponent<>::PartialComponent.: cannot access private member declared in class .fruit::PartialComponent<>.', COMMON_DEFINITIONS, source, locals()) @@ -143,7 +143,7 @@ def test_error_no_factory_binding_found(MaybeConst): } ''' expect_compile_error( - 'NoBindingFoundError<std::function<std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)>', + r'NoBindingFoundError<std::function<std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)>', 'No explicit binding nor C::Inject definition was found for T.', COMMON_DEFINITIONS, source, @@ -162,11 +162,11 @@ def test_error_no_factory_binding_found_with_annotation(MaybeConst): } ''' expect_compile_error( - 'NoBindingFoundError<fruit::Annotated<Annotation1,std::function<std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)>>', + r'NoBindingFoundError<fruit::Annotated<Annotation1,std::function<std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)>>', 'No explicit binding nor C::Inject definition was found for T.', COMMON_DEFINITIONS, source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_component_and_injector_params.py b/tests/test_component_and_injector_params.py index 00ccdb5..fce1452 100755 --- a/tests/test_component_and_injector_params.py +++ b/tests/test_component_and_injector_params.py @@ -211,16 +211,16 @@ def test_same_type_in_required_and_provided_different_annotation_ok(): source) @pytest.mark.parametrize('XVariantAnnot,XVariantRegexp', [ - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('X&', 'X&'), - ('const X&', 'const X&'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), - ('fruit::Annotated<Annotation1, X*>', 'X\*'), - ('fruit::Annotated<Annotation1, const X*>', 'const X\*'), - ('fruit::Annotated<Annotation1, X&>', 'X&'), - ('fruit::Annotated<Annotation1, const X&>', 'const X&'), - ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', 'std::shared_ptr<X>'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('X&', r'X&'), + ('const X&', r'const X&'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), + ('fruit::Annotated<Annotation1, X*>', r'X\*'), + ('fruit::Annotated<Annotation1, const X*>', r'const X\*'), + ('fruit::Annotated<Annotation1, X&>', r'X&'), + ('fruit::Annotated<Annotation1, const X&>', r'const X&'), + ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', r'std::shared_ptr<X>'), ]) @pytest.mark.parametrize('Class', [ 'Component', @@ -257,16 +257,16 @@ def test_const_provided_type_ok(XVariantAnnot, XVariantRegexp, Class): locals()) @pytest.mark.parametrize('XVariantAnnot,XVariantRegexp', [ - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('X&', 'X&'), - ('const X&', 'const X&'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), - ('fruit::Annotated<Annotation1, X*>', 'X\*'), - ('fruit::Annotated<Annotation1, const X*>', 'const X\*'), - ('fruit::Annotated<Annotation1, X&>', 'X&'), - ('fruit::Annotated<Annotation1, const X&>', 'const X&'), - ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', 'std::shared_ptr<X>'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('X&', r'X&'), + ('const X&', r'const X&'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), + ('fruit::Annotated<Annotation1, X*>', r'X\*'), + ('fruit::Annotated<Annotation1, const X*>', r'const X\*'), + ('fruit::Annotated<Annotation1, X&>', r'X&'), + ('fruit::Annotated<Annotation1, const X&>', r'const X&'), + ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', r'std::shared_ptr<X>'), ]) @pytest.mark.parametrize('Class', [ 'Component', @@ -426,5 +426,5 @@ def test_error_requirements_in_injector_second_argument(XAnnot, YAnnot): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_component_functions.py b/tests/test_component_functions.py index 69ab6cf..b53a417 100755 --- a/tests/test_component_functions.py +++ b/tests/test_component_functions.py @@ -145,10 +145,10 @@ def test_component_function_error_not_move_constructible(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(Arg&&\).' - + '|error: call to deleted constructor of .Arg.' - + '|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .const Arg &.' - + '|.Arg::Arg\(Arg &&\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg::Arg\(Arg&&\).' + r'|error: call to deleted constructor of .Arg.' + r'|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .const Arg &.' + r'|.Arg::Arg\(Arg &&\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -182,10 +182,10 @@ def test_component_function_error_not_move_constructible_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(Arg&&\).' - + '|error: call to deleted constructor of .Arg.' - + '|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .int.' - + '|error: copying parameter of type .Arg. invokes deleted constructor', + r'error: use of deleted function .Arg::Arg\(Arg&&\).' + r'|error: call to deleted constructor of .Arg.' + r'|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .int.' + r'|error: copying parameter of type .Arg. invokes deleted constructor', COMMON_DEFINITIONS, source) @@ -221,12 +221,12 @@ def test_component_function_error_not_copy_constructible(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(const Arg&\).' - + '|error: call to deleted constructor of .Arg.' - + '|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function' + r'error: use of deleted function .Arg::Arg\(const Arg&\).' + r'|error: call to deleted constructor of .Arg.' + r'|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function' # This is the error printed by MSVC. It's not great but I couldn't find a way to have it print # a more useful error. - + '|cannot convert argument 1 from .int. to .std::allocator_arg_t.', + r'|cannot convert argument 1 from .int. to .std::allocator_arg_t.', COMMON_DEFINITIONS, source) @@ -263,12 +263,12 @@ def test_component_function_error_not_copy_constructible_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(const Arg&\).' - + '|error: call to deleted constructor of .Arg.' - + '|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function' + r'error: use of deleted function .Arg::Arg\(const Arg&\).' + r'|error: call to deleted constructor of .Arg.' + r'|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function' # This is the error printed by MSVC. It's not great but I couldn't find a way to have it print # a more useful error. - + '|cannot convert argument 1 from .int. to .std::allocator_arg_t.', + r'|cannot convert argument 1 from .int. to .std::allocator_arg_t.', COMMON_DEFINITIONS, source) @@ -301,9 +301,9 @@ def test_component_function_error_not_move_assignable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -337,9 +337,9 @@ def test_component_function_error_not_move_assignable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -375,9 +375,9 @@ def test_component_function_error_not_copy_assignable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -414,9 +414,9 @@ def test_component_function_error_not_copy_assignable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -450,9 +450,9 @@ def test_component_function_error_not_equality_comparable(): } ''' expect_generic_compile_error( - 'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' - + '|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' - + '|error C2676: binary .==.: .const Arg. does not define this operator', + r'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' + r'|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' + r'|error C2676: binary .==.: .const Arg. does not define this operator', COMMON_DEFINITIONS, source) @@ -487,9 +487,9 @@ def test_component_function_error_not_equality_comparable_with_conversion(): } ''' expect_generic_compile_error( - 'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' - + '|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' - + '|error C2676: binary .==.: .const Arg. does not define this operator', + r'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' + r'|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' + r'|error C2676: binary .==.: .const Arg. does not define this operator', COMMON_DEFINITIONS, source) @@ -515,12 +515,12 @@ def test_component_function_error_not_hashable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .std::hash<Arg>::hash\(\).' - + '|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' - + '|error: invalid use of incomplete type .struct std::hash<Arg>.' - + '|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' - + '|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' - + '|error C2064: term does not evaluate to a function taking 1 arguments', + r'error: use of deleted function .std::hash<Arg>::hash\(\).' + r'|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' + r'|error: invalid use of incomplete type .struct std::hash<Arg>.' + r'|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' + r'|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' + r'|error C2064: term does not evaluate to a function taking 1 arguments', COMMON_DEFINITIONS, source) @@ -547,14 +547,14 @@ def test_component_function_error_not_hashable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .std::hash<Arg>::hash\(\).' - + '|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' - + '|error: invalid use of incomplete type .struct std::hash<Arg>.' - + '|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' - + '|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' - + '|error C2064: term does not evaluate to a function taking 1 arguments', + r'error: use of deleted function .std::hash<Arg>::hash\(\).' + r'|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' + r'|error: invalid use of incomplete type .struct std::hash<Arg>.' + r'|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' + r'|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' + r'|error C2064: term does not evaluate to a function taking 1 arguments', COMMON_DEFINITIONS, source) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_component_replacement.py b/tests/test_component_replacement.py index 46c52a7..9cdadb5 100755 --- a/tests/test_component_replacement.py +++ b/tests/test_component_replacement.py @@ -115,7 +115,7 @@ def test_replace_component_success_across_normalized_component( ('std::string', 'getReplacementComponent, std::string("Hello, world")'), ]) def test_replace_component_installed_using_component_function_success( - ReplacedComponentParamTypes, ReplacedComponentInstallation, ReplacementComponentParamTypes, ReplacementComponentInstallation): + ReplacedComponentParamTypes, ReplacedComponentInstallation, ReplacementComponentParamTypes, ReplacementComponentInstallation): source = ''' fruit::Component<int> getReplacedComponent(ReplacedComponentParamTypes) { static int n = 10; @@ -306,11 +306,11 @@ def test_replace_component_different_type_error(): ''' expect_generic_compile_error( # Clang - 'candidate template ignored: could not match .Component<int>. against .Component<double>.' + r'candidate template ignored: could not match .Component<int>. against .Component<double>.' # GCC - '|mismatched types .int. and .double.' + r'|mismatched types .int. and .double.' # MSVC - '|could not deduce template argument for .fruit::Component<int> \(__cdecl \*\)\(FormalArgs...\). from .fruit::Component<double> \(void\).', + r'|could not deduce template argument for .fruit::Component<int> \(__cdecl \*\)\(FormalArgs...\). from .fruit::Component<double> \(void\).', COMMON_DEFINITIONS, source) @@ -442,11 +442,11 @@ def test_replace_component_already_replaced_inconsistent_error( } ''' expect_runtime_error( - 'Fatal injection error: the component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) was replaced ' - + '\(using .replace\(...\).with\(...\)\) with both the component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) and the component function at ' - + '(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) .', + r'Fatal injection error: the component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) was replaced ' + r'\(using .replace\(...\).with\(...\)\) with both the component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) and the component function at ' + r'(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) .', COMMON_DEFINITIONS, source, locals()) @@ -497,11 +497,11 @@ def test_replace_component_already_replaced_across_normalized_component_inconsis } ''' expect_runtime_error( - 'Fatal injection error: the component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) was replaced ' - + '\(using .replace\(...\).with\(...\)\) with both the component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) and the component function at ' - + '(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) .', + r'Fatal injection error: the component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) was replaced ' + r'\(using .replace\(...\).with\(...\)\) with both the component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) and the component function at ' + r'(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) .', COMMON_DEFINITIONS, source, locals()) @@ -541,11 +541,11 @@ def test_replace_component_after_install_error( } ''' expect_runtime_error( - 'Fatal injection error: unable to replace \(using .replace\(...\).with\(...\)\) the component function at ' - + '(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) with the ' - + 'component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) because the former component function ' - + 'was installed before the .replace\(...\).with\(...\).', + r'Fatal injection error: unable to replace \(using .replace\(...\).with\(...\)\) the component function at ' + r'(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) with the ' + r'component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) because the former component function ' + r'was installed before the .replace\(...\).with\(...\).', COMMON_DEFINITIONS, source, locals()) @@ -590,11 +590,11 @@ def test_replace_component_after_install_across_normalized_component_error( } ''' expect_runtime_error( - 'Fatal injection error: unable to replace \(using .replace\(...\).with\(...\)\) the component function at ' - + '(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) with the ' - + 'component function at (0x)?[0-9a-fA-F]* with signature ' - + '(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) because the former component function ' - + 'was installed before the .replace\(...\).with\(...\).', + r'Fatal injection error: unable to replace \(using .replace\(...\).with\(...\)\) the component function at ' + r'(0x)?[0-9a-fA-F]* with signature (class )?fruit::Component<int> \((__cdecl)?\*\)\((void)?ReplacedComponentParamTypes\) with the ' + r'component function at (0x)?[0-9a-fA-F]* with signature ' + r'(class )?fruit::Component<int> \((__cdecl)?\*\)\(.*\) because the former component function ' + r'was installed before the .replace\(...\).with\(...\).', COMMON_DEFINITIONS, source, locals()) @@ -987,5 +987,5 @@ def test_replace_component_already_replaced_with_different_args(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_defn_h_includes.py b/tests/test_defn_h_includes.py index 5b1d54f..ac66972 100755 --- a/tests/test_defn_h_includes.py +++ b/tests/test_defn_h_includes.py @@ -68,5 +68,5 @@ def test_defn_file_inclusion(): if other_header not in (main_header_file, alternative_main_header_file) and defn_file in other_header_includes: raise Exception('Unexpected direct include: %s includes %s' % (other_header, defn_file)) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_dependency_loop.py b/tests/test_dependency_loop.py index b9698bb..e1abf52 100755 --- a/tests/test_dependency_loop.py +++ b/tests/test_dependency_loop.py @@ -142,5 +142,5 @@ def test_with_different_annotations_ok(): COMMON_DEFINITIONS, source) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_eager_injection.py b/tests/test_eager_injection.py index 60a914b..9ec776f 100644 --- a/tests/test_eager_injection.py +++ b/tests/test_eager_injection.py @@ -115,5 +115,5 @@ def test_eager_injection(): locals(), ignore_deprecation_warnings=True) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_include_test.py b/tests/test_include_test.py index b9fc3fb..d39e3b2 100644 --- a/tests/test_include_test.py +++ b/tests/test_include_test.py @@ -38,5 +38,5 @@ def test_header_self_contained(HeaderFile): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_injected_provider.py b/tests/test_injected_provider.py index 8754610..76f78e1 100755 --- a/tests/test_injected_provider.py +++ b/tests/test_injected_provider.py @@ -28,11 +28,11 @@ COMMON_DEFINITIONS = ''' ''' @pytest.mark.parametrize('XVariant,XVariantRegexp', [ - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('X&', 'X&'), - ('const X&', 'const X&'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('X&', r'X&'), + ('const X&', r'const X&'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), ]) def test_error_non_class_type_parameter(XVariant, XVariantRegexp): source = ''' @@ -201,7 +201,7 @@ def test_provider_get_error_type_not_provided(): ('void', r'void'), ('fruit::Annotated<Annotation1, fruit::Annotated<Annotation1, X>>', r'fruit::Annotated<Annotation1, X>'), ]) -def test_provider_get_error_type_not_injectable(XVariant,XVariantRegex): +def test_provider_get_error_type_not_injectable(XVariant, XVariantRegex): source = ''' struct X {}; @@ -217,10 +217,10 @@ def test_provider_get_error_type_not_injectable(XVariant,XVariantRegex): locals()) @pytest.mark.parametrize('XProviderGetParam,XProviderGetParamRegex', [ - ('X&', 'X&'), - ('X*', 'X\*'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), - ('fruit::Provider<X>', 'fruit::Provider<X>'), + ('X&', r'X&'), + ('X*', r'X\*'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), + ('fruit::Provider<X>', r'fruit::Provider<X>'), ]) def test_const_provider_get_does_not_allow_injecting_nonconst_variants(XProviderGetParam, XProviderGetParamRegex): source = ''' @@ -288,5 +288,5 @@ def test_lazy_injection_with_annotations(Y_PROVIDER_ANNOT): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_injector.py b/tests/test_injector.py index ed79b99..64eaf1d 100755 --- a/tests/test_injector.py +++ b/tests/test_injector.py @@ -106,10 +106,10 @@ def test_error_declared_nonconst_types_provided_as_const(XAnnot, ConstXAnnot): } ''' expect_generic_compile_error( - 'no matching constructor for initialization of .fruit::Injector<XAnnot>.' - '|no matching function for call to .fruit::Injector<XAnnot>::Injector\(fruit::Component<ConstXAnnot> \(&\)\(\)\).' + r'no matching constructor for initialization of .fruit::Injector<XAnnot>.' + r'|no matching function for call to .fruit::Injector<XAnnot>::Injector\(fruit::Component<ConstXAnnot> \(&\)\(\)\).' # MSVC - '|.fruit::Injector<XAnnot>::Injector.: none of the 2 overloads could convert all the argument types', + r'|.fruit::Injector<XAnnot>::Injector.: none of the 2 overloads could convert all the argument types', COMMON_DEFINITIONS, source, locals()) @@ -164,12 +164,12 @@ def test_injector_get_error_type_not_provided(XAnnot, YAnnot): locals()) @pytest.mark.parametrize('ConstXAnnot,XInjectorGetParam,XInjectorGetParamRegex', [ - ('const X', 'X&', 'X&'), - ('const X', 'X*', 'X\*'), - ('const X', 'std::shared_ptr<X>', 'std::shared_ptr<X>'), - ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, X&>', 'fruit::Annotated<Annotation1, X&>'), - ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, X*>', 'fruit::Annotated<Annotation1, X\*>'), - ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, std::shared_ptr<X>>', 'fruit::Annotated<Annotation1, std::shared_ptr<X>>'), + ('const X', 'X&', r'X&'), + ('const X', 'X*', r'X\*'), + ('const X', 'std::shared_ptr<X>', r'std::shared_ptr<X>'), + ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, X&>', r'fruit::Annotated<Annotation1, X&>'), + ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, X*>', r'fruit::Annotated<Annotation1, X\*>'), + ('fruit::Annotated<Annotation1, const X>', 'fruit::Annotated<Annotation1, std::shared_ptr<X>>', r'fruit::Annotated<Annotation1, std::shared_ptr<X>>'), ]) def test_injector_const_provided_type_does_not_allow_injecting_nonconst_variants(ConstXAnnot, XInjectorGetParam, XInjectorGetParamRegex): source = ''' @@ -264,7 +264,7 @@ def test_injector_get_const_binding_ok(XBindingInInjector, XInjectorGetParam): ('void', r'void'), ('fruit::Annotated<Annotation1, X**>', r'X\*\*'), ]) -def test_injector_get_error_type_not_injectable(XVariant,XVariantRegex): +def test_injector_get_error_type_not_injectable(XVariant, XVariantRegex): source = ''' struct X {}; @@ -282,7 +282,7 @@ def test_injector_get_error_type_not_injectable(XVariant,XVariantRegex): @pytest.mark.parametrize('XVariant,XVariantRegex', [ ('X[]', r'X\[\]'), ]) -def test_injector_get_error_array_type(XVariant,XVariantRegex): +def test_injector_get_error_array_type(XVariant, XVariantRegex): source = ''' struct X {}; @@ -299,5 +299,5 @@ def test_injector_get_error_array_type(XVariant,XVariantRegex): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_injector_unsafe_get.py b/tests/test_injector_unsafe_get.py index 8768c63..e479d50 100755 --- a/tests/test_injector_unsafe_get.py +++ b/tests/test_injector_unsafe_get.py @@ -71,5 +71,5 @@ def test_success(XAnnot, YAnnot, ZAnnot): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_install.py b/tests/test_install.py index 9ea4d48..c9b1b84 100755 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -399,9 +399,9 @@ def test_install_with_args_error_not_move_constructible(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(Arg&&\).' - + '|error: call to deleted constructor of .Arg.' - + '|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .const Arg &.', + r'error: use of deleted function .Arg::Arg\(Arg&&\).' + r'|error: call to deleted constructor of .Arg.' + r'|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .const Arg &.', COMMON_DEFINITIONS, source) @@ -433,9 +433,9 @@ def test_install_with_args_error_not_move_constructible_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(Arg&&\).' - + '|error: call to deleted constructor of .Arg.' - + '|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .int.', + r'error: use of deleted function .Arg::Arg\(Arg&&\).' + r'|error: call to deleted constructor of .Arg.' + r'|.Arg::Arg\(Arg &&\).: cannot convert argument 1 from .std::_Tuple_val<Arg>. to .int.', COMMON_DEFINITIONS, source) @@ -471,9 +471,9 @@ def test_install_with_args_error_not_copy_constructible(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(const Arg&\).' - + '|error: call to deleted constructor of .Arg.' - + '|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg::Arg\(const Arg&\).' + r'|error: call to deleted constructor of .Arg.' + r'|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -510,9 +510,9 @@ def test_install_with_args_error_not_copy_constructible_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg::Arg\(const Arg&\).' - + '|error: call to deleted constructor of .Arg.' - + '|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg::Arg\(const Arg&\).' + r'|error: call to deleted constructor of .Arg.' + r'|error C2280: .Arg::Arg\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -543,9 +543,9 @@ def test_install_with_args_error_not_move_assignable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -577,9 +577,9 @@ def test_install_with_args_error_not_move_assignable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(Arg&&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(Arg &&\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -615,9 +615,9 @@ def test_install_with_args_error_not_copy_assignable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -654,9 +654,9 @@ def test_install_with_args_error_not_copy_assignable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' - + '|error: overload resolution selected deleted operator .=.' - + '|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', + r'error: use of deleted function .Arg& Arg::operator=\(const Arg&\).' + r'|error: overload resolution selected deleted operator .=.' + r'|error C2280: .Arg &Arg::operator =\(const Arg &\).: attempting to reference a deleted function', COMMON_DEFINITIONS, source) @@ -690,9 +690,9 @@ def test_install_with_args_error_not_equality_comparable(): } ''' expect_generic_compile_error( - 'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' - + '|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' - + '|error C2676: binary .==.: .const Arg. does not define this operator', + r'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' + r'|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' + r'|error C2676: binary .==.: .const Arg. does not define this operator', COMMON_DEFINITIONS, source) @@ -727,9 +727,9 @@ def test_install_with_args_error_not_equality_comparable_with_conversion(): } ''' expect_generic_compile_error( - 'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' - + '|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' - + '|error C2676: binary .==.: .const Arg. does not define this operator', + r'error: no match for .operator==. \(operand types are .const Arg. and .const Arg.\)' + r'|error: invalid operands to binary expression \(.const Arg. and .const Arg.\)' + r'|error C2676: binary .==.: .const Arg. does not define this operator', COMMON_DEFINITIONS, source) @@ -753,12 +753,12 @@ def test_install_with_args_error_not_hashable(): } ''' expect_generic_compile_error( - 'error: use of deleted function .std::hash<Arg>::hash\(\).' - + '|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' - + '|error: invalid use of incomplete type .struct std::hash<Arg>.' - + '|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' - + '|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' - + '|error C2064: term does not evaluate to a function taking 1 arguments', + r'error: use of deleted function .std::hash<Arg>::hash\(\).' + r'|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' + r'|error: invalid use of incomplete type .struct std::hash<Arg>.' + r'|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' + r'|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' + r'|error C2064: term does not evaluate to a function taking 1 arguments', COMMON_DEFINITIONS, source) @@ -783,12 +783,12 @@ def test_install_with_args_error_not_hashable_with_conversion(): } ''' expect_generic_compile_error( - 'error: use of deleted function .std::hash<Arg>::hash\(\).' - + '|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' - + '|error: invalid use of incomplete type .struct std::hash<Arg>.' - + '|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' - + '|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' - + '|error C2064: term does not evaluate to a function taking 1 arguments', + r'error: use of deleted function .std::hash<Arg>::hash\(\).' + r'|error: call to implicitly-deleted default constructor of .std::hash<Arg>.' + r'|error: invalid use of incomplete type .struct std::hash<Arg>.' + r'|error: implicit instantiation of undefined template .std::(__1::)?hash<Arg>.' + r'|error C2338: The C\+\+ Standard doesn.t provide a hash for this type.' + r'|error C2064: term does not evaluate to a function taking 1 arguments', COMMON_DEFINITIONS, source) @@ -1008,12 +1008,12 @@ def test_install_component_functions_loop(): } ''' expect_runtime_error( - 'Component installation trace \(from top-level to the most deeply-nested\):\n' - + '(class )?fruit::Component<(struct )?X> ?\((__cdecl)?\*\)\((void)?\)\n' - + '<-- The loop starts here\n' - + '(class )?fruit::Component<(struct )?Y> ?\((__cdecl)?\*\)\((void)?\)\n' - + '(class )?fruit::Component<(struct )?Z> ?\((__cdecl)?\*\)\((void)?\)\n' - + '(class )?fruit::Component<(struct )?Y> ?\((__cdecl)?\*\)\((void)?\)\n', + r'Component installation trace \(from top-level to the most deeply-nested\):\n' + r'(class )?fruit::Component<(struct )?X> ?\((__cdecl)?\*\)\((void)?\)\n' + r'<-- The loop starts here\n' + r'(class )?fruit::Component<(struct )?Y> ?\((__cdecl)?\*\)\((void)?\)\n' + r'(class )?fruit::Component<(struct )?Z> ?\((__cdecl)?\*\)\((void)?\)\n' + r'(class )?fruit::Component<(struct )?Y> ?\((__cdecl)?\*\)\((void)?\)\n', COMMON_DEFINITIONS, source, locals()) @@ -1063,5 +1063,5 @@ def test_install_component_functions_different_arguments_loop_not_reported(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_install_component_functions.py b/tests/test_install_component_functions.py index bd7647a..2850cdc 100755 --- a/tests/test_install_component_functions.py +++ b/tests/test_install_component_functions.py @@ -368,5 +368,5 @@ def test_install_component_functions_wrong_argument_type(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_misc.py b/tests/test_misc.py index 0cd6bec..873ef20 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -165,5 +165,5 @@ def test_misc(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_multibindings_bind_instance.py b/tests/test_multibindings_bind_instance.py index 634a627..8a18859 100755 --- a/tests/test_multibindings_bind_instance.py +++ b/tests/test_multibindings_bind_instance.py @@ -66,10 +66,10 @@ def test_multibindings_bind_const_instance_error(XAnnot): } ''' expect_generic_compile_error( - 'candidate function not viable: 1st argument \(.const X.\) would lose const qualifier' - '|no matching function for call to .fruit::PartialComponent<.*>::addInstanceMultibinding(<XAnnot,X>)?\(const X&\).' - '|error: no matching member function for call to .addInstanceMultibinding.' - '|cannot convert argument 1 from .const X. to .X &.', + r'candidate function not viable: 1st argument \(.const X.\) would lose const qualifier' + r'|no matching function for call to .fruit::PartialComponent<.*>::addInstanceMultibinding(<XAnnot,X>)?\(const X&\).' + r'|error: no matching member function for call to .addInstanceMultibinding.' + r'|cannot convert argument 1 from .const X. to .X &.', COMMON_DEFINITIONS, source, locals()) @@ -119,10 +119,10 @@ def test_multibindings_bind_const_instance_vector_error(XAnnot): } ''' expect_generic_compile_error( - 'candidate function not viable: 1st argument \(.const std::vector<X>.\) would lose const qualifier' - '|cannot convert .values. \(type .const std::(__debug::)?vector<X>.\) to type .std::(__debug::)?vector<X>&.' - '|no matching member function for call to .addInstanceMultibindings.' - '|cannot convert argument 1 from .const std::vector<X,std::allocator<.*>>. to .std::vector<X,std::allocator<.*>> &.', + r'candidate function not viable: 1st argument \(.const std::vector<X>.\) would lose const qualifier' + r'|cannot convert .values. \(type .const std::(__debug::)?vector<X>.\) to type .std::(__debug::)?vector<X>&.' + r'|no matching .*function for call to .*addInstanceMultibindings' + r'|cannot convert argument 1 from .const std::vector<X,std::allocator<.*>>. to .std::vector<X,std::allocator<.*>> &.', COMMON_DEFINITIONS, source, locals()) @@ -195,5 +195,5 @@ def test_multibindings_bind_instance_non_injectable_type_error(XVariant, XVarian source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_multibindings_bind_interface.py b/tests/test_multibindings_bind_interface.py index 90c4678..78b911a 100755 --- a/tests/test_multibindings_bind_interface.py +++ b/tests/test_multibindings_bind_interface.py @@ -204,5 +204,5 @@ def test_error_abstract_class_clang(ScalerAnnot, ScalerImplAnnot): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_multibindings_bind_provider.py b/tests/test_multibindings_bind_provider.py index 9008c2f..8cfc4e1 100755 --- a/tests/test_multibindings_bind_provider.py +++ b/tests/test_multibindings_bind_provider.py @@ -114,7 +114,7 @@ def test_bind_multibinding_provider_abstract_class_with_no_virtual_destructor_er ''' expect_compile_error( 'MultibindingProviderReturningPointerToAbstractClassWithNoVirtualDestructorError<I>', - 'registerMultibindingProvider\(\) was called with a lambda that returns a pointer to T, but T is an abstract class with no virtual destructor', + r'registerMultibindingProvider\(\) was called with a lambda that returns a pointer to T, but T is an abstract class with no virtual destructor', COMMON_DEFINITIONS, source, locals()) @@ -368,12 +368,12 @@ def test_bind_multibinding_provider_requiring_const_then_requiring_nonconst_decl ('new X()', 'X*'), ]) @pytest.mark.parametrize('YAnnot,ConstYAnnot,YVariant,YVariantRegex', [ - ('Y', 'Y', 'Y**', 'Y\*\*'), - ('Y', 'Y', 'std::shared_ptr<Y>*', 'std::shared_ptr<Y>\*'), - ('Y', 'const Y', 'Y**', 'Y\*\*'), - ('Y', 'const Y', 'std::shared_ptr<Y>*', 'std::shared_ptr<Y>\*'), - ('fruit::Annotated<Annotation1, Y>', 'fruit::Annotated<Annotation1, Y>', 'Y**', 'Y\*\*'), - ('fruit::Annotated<Annotation1, Y>', 'fruit::Annotated<Annotation1, const Y>', 'Y**', 'Y\*\*'), + ('Y', 'Y', 'Y**', r'Y\*\*'), + ('Y', 'Y', 'std::shared_ptr<Y>*', r'std::shared_ptr<Y>\*'), + ('Y', 'const Y', 'Y**', r'Y\*\*'), + ('Y', 'const Y', 'std::shared_ptr<Y>*', r'std::shared_ptr<Y>\*'), + ('fruit::Annotated<Annotation1, Y>', 'fruit::Annotated<Annotation1, Y>', 'Y**', r'Y\*\*'), + ('fruit::Annotated<Annotation1, Y>', 'fruit::Annotated<Annotation1, const Y>', 'Y**', r'Y\*\*'), ]) def test_bind_multibinding_provider_with_param_error_type_not_injectable(ConstructX, XPtr, YAnnot, ConstYAnnot, YVariant, YVariantRegex): source = ''' @@ -565,5 +565,5 @@ def test_provider_returns_nullptr_error(XAnnot, XPtrAnnot, XAnnotRegex): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_multibindings_misc.py b/tests/test_multibindings_misc.py index 5b85700..346d027 100755 --- a/tests/test_multibindings_misc.py +++ b/tests/test_multibindings_misc.py @@ -531,14 +531,14 @@ def test_with_normalized_component_lazy_components_not_deduped_across(): source) @pytest.mark.parametrize('XVariantAnnot,XVariantRegexp', [ - ('const X', 'const X'), - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), - ('fruit::Annotated<Annotation1, const X>', 'const X'), - ('fruit::Annotated<Annotation1, X*>', 'X\*'), - ('fruit::Annotated<Annotation1, const X*>', 'const X\*'), - ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', 'std::shared_ptr<X>'), + ('const X', r'const X'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), + ('fruit::Annotated<Annotation1, const X>', r'const X'), + ('fruit::Annotated<Annotation1, X*>', r'X\*'), + ('fruit::Annotated<Annotation1, const X*>', r'const X\*'), + ('fruit::Annotated<Annotation1, std::shared_ptr<X>>', r'std::shared_ptr<X>'), ]) def test_multibindings_get_error_non_class_type(XVariantAnnot, XVariantRegexp): source = ''' @@ -573,5 +573,5 @@ def test_multibindings_get_error_reference_type(XVariantAnnot, XVariantRegexp): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_normalized_component.py b/tests/test_normalized_component.py index 4d0025d..582ea71 100755 --- a/tests/test_normalized_component.py +++ b/tests/test_normalized_component.py @@ -172,9 +172,9 @@ def test_normalized_component_providing_nonconst_from_component_providing_const_ } ''' expect_generic_compile_error( - 'no matching function for call to .fruit::NormalizedComponent<ConstXAnnot>::NormalizedComponent\(fruit::Component<XAnnot> \(&\)\(\)\).' - '|no matching constructor for initialization of .fruit::NormalizedComponent<ConstXAnnot>.' - '|.fruit::NormalizedComponent<ConstXAnnot>::NormalizedComponent.: none of the 2 overloads could convert all the argument types', + r'no matching function for call to .fruit::NormalizedComponent<ConstXAnnot>::NormalizedComponent\(fruit::Component<XAnnot> \(&\)\(\)\).' + r'|no matching constructor for initialization of .fruit::NormalizedComponent<ConstXAnnot>.' + r'|.fruit::NormalizedComponent<ConstXAnnot>::NormalizedComponent.: none of the 2 overloads could convert all the argument types', COMMON_DEFINITIONS, source, locals()) @@ -202,5 +202,5 @@ def test_injector_from_normalized_component_nonconst_requirements_provided_as_co source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_register_constructor.py b/tests/test_register_constructor.py index 3333075..cb0ae44 100755 --- a/tests/test_register_constructor.py +++ b/tests/test_register_constructor.py @@ -213,8 +213,8 @@ def test_register_constructor_error_malformed_signature(): } ''' expect_compile_error( - 'NotASignatureError<X\[\]>', - 'CandidateSignature was specified as parameter, but it.s not a signature. Signatures are of the form', + r'NotASignatureError<X\[\]>', + r'CandidateSignature was specified as parameter, but it.s not a signature. Signatures are of the form', COMMON_DEFINITIONS, source) @@ -230,8 +230,8 @@ def test_register_constructor_error_malformed_signature_autoinject(): } ''' expect_compile_error( - 'InjectTypedefNotASignatureError<X,X\[\]>', - 'C::Inject should be a typedef to a signature', + r'InjectTypedefNotASignatureError<X,X\[\]>', + r'C::Inject should be a typedef to a signature', COMMON_DEFINITIONS, source) @@ -251,8 +251,8 @@ def test_register_constructor_does_not_exist_error(charPtrAnnot): } ''' expect_compile_error( - 'NoConstructorMatchingInjectSignatureError<X,X\(char\*\)>', - 'contains an Inject typedef but it.s not constructible with the specified types', + r'NoConstructorMatchingInjectSignatureError<X,X\(char\*\)>', + r'contains an Inject typedef but it.s not constructible with the specified types', COMMON_DEFINITIONS, source, locals()) @@ -273,8 +273,8 @@ def test_autoinject_constructor_does_not_exist_error(charPtrAnnot): } ''' expect_compile_error( - 'NoConstructorMatchingInjectSignatureError<X,X\(char\*\)>', - 'contains an Inject typedef but it.s not constructible with the specified types', + r'NoConstructorMatchingInjectSignatureError<X,X\(char\*\)>', + r'contains an Inject typedef but it.s not constructible with the specified types', COMMON_DEFINITIONS, source, locals()) @@ -586,5 +586,5 @@ def test_register_constructor_with_param_error_type_not_injectable(YVariant, YVa locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_register_factory.py b/tests/test_register_factory.py index 02d1169..2f5027a 100755 --- a/tests/test_register_factory.py +++ b/tests/test_register_factory.py @@ -155,8 +155,8 @@ def test_register_factory_autoinject_abstract_class_with_no_virtual_destructor_e } ''' expect_compile_error( - 'FactoryBindingForUniquePtrOfClassWithNoVirtualDestructorError<std::function<std::unique_ptr<Scaler(,std::default_delete<Scaler>)?>\(double\)>,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', - 'Fruit was trying to bind BaseFactory to DerivedFactory but the return type of BaseFactory is a std::unique_ptr of a class with no virtual destructor', + r'FactoryBindingForUniquePtrOfClassWithNoVirtualDestructorError<std::function<std::unique_ptr<Scaler(,std::default_delete<Scaler>)?>\(double\)>,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', + r'Fruit was trying to bind BaseFactory to DerivedFactory but the return type of BaseFactory is a std::unique_ptr of a class with no virtual destructor', COMMON_DEFINITIONS, source, locals()) @@ -180,8 +180,8 @@ def test_register_factory_autoinject_non_abstract_class_with_no_virtual_destruct } ''' expect_compile_error( - 'FactoryBindingForUniquePtrOfClassWithNoVirtualDestructorError<std::function<std::unique_ptr<Scaler(,std::default_delete<Scaler>)?>\(double\)>,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', - 'Fruit was trying to bind BaseFactory to DerivedFactory but the return type of BaseFactory is a std::unique_ptr of a class with no virtual destructor', + r'FactoryBindingForUniquePtrOfClassWithNoVirtualDestructorError<std::function<std::unique_ptr<Scaler(,std::default_delete<Scaler>)?>\(double\)>,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', + r'Fruit was trying to bind BaseFactory to DerivedFactory but the return type of BaseFactory is a std::unique_ptr of a class with no virtual destructor', COMMON_DEFINITIONS, source, locals()) @@ -286,13 +286,13 @@ def test_autoinject_returning_value(MaybeConst): ('Scaler', 'ScalerImpl', 'std::function<std::unique_ptr<Scaler>(double)>', - 'std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>', - ), + r'std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>', + ), ('fruit::Annotated<Annotation1, Scaler>', 'fruit::Annotated<Annotation2, ScalerImpl>', 'fruit::Annotated<Annotation1, std::function<std::unique_ptr<Scaler>(double)>>', - 'fruit::Annotated<Annotation2,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', - ), + r'fruit::Annotated<Annotation2,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>', + ), ]) def test_autoinject_error_abstract_class(ScalerAnnot, ScalerImplAnnot, ScalerFactoryAnnot, ScalerImplFactoryAnnotRegex): source = ''' @@ -1166,8 +1166,8 @@ def test_register_factory_with_different_annotation_error(): } ''' expect_compile_error( - 'NoBindingFoundError<fruit::Annotated<Annotation1,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>>', - '', + r'NoBindingFoundError<fruit::Annotated<Annotation1,std::function<std::unique_ptr<ScalerImpl(,std::default_delete<ScalerImpl>)?>\(double\)>>>', + r'', COMMON_DEFINITIONS, source) @@ -1309,12 +1309,12 @@ def test_register_factory_error_not_function(): 'ScalerImpl', 'ScalerImpl*', 'std::function<std::unique_ptr<Scaler>(double)>', - 'ScalerImpl\*\(fruit::Assisted<double>\)'), + r'ScalerImpl\*\(fruit::Assisted<double>\)'), ('fruit::Annotated<Annotation1, Scaler>', 'fruit::Annotated<Annotation2, ScalerImpl>', 'fruit::Annotated<Annotation2, ScalerImpl*>', 'fruit::Annotated<Annotation2, std::function<std::unique_ptr<Scaler>(double)>>', - 'fruit::Annotated<Annotation2,ScalerImpl\*>\(fruit::Assisted<double>\)') + r'fruit::Annotated<Annotation2,ScalerImpl\*>\(fruit::Assisted<double>\)') ]) def test_register_factory_for_pointer(ScalerAnnot, ScalerImplAnnot, ScalerImplPtrAnnot, ScalerFactoryAnnot, ScalerImplFactorySignatureAnnotRegex): source = ''' @@ -1361,10 +1361,10 @@ def test_register_factory_for_pointer(ScalerAnnot, ScalerImplAnnot, ScalerImplPt @pytest.mark.parametrize('ScalerPtrAnnot,ScalerFactoryAnnot,ScalerFactorySignatureAnnotRegex', [ ('Scaler*', 'std::function<Scaler(double)>', - 'Scaler\*\(fruit::Assisted<double>\)'), + r'Scaler\*\(fruit::Assisted<double>\)'), ('fruit::Annotated<Annotation1, Scaler*>', 'fruit::Annotated<Annotation1, std::function<Scaler(double)>>', - 'fruit::Annotated<Annotation1,Scaler\*>\(fruit::Assisted<double>\)'), + r'fruit::Annotated<Annotation1,Scaler\*>\(fruit::Assisted<double>\)'), ]) def test_register_factory_for_pointer_returning_value(ScalerPtrAnnot, ScalerFactoryAnnot, ScalerFactorySignatureAnnotRegex): source = ''' @@ -1595,8 +1595,8 @@ def test_register_factory_inconsistent_signature(ScalerImplAnnot): } ''' expect_compile_error( - 'FunctorSignatureDoesNotMatchError<ScalerImpl\(double\),ScalerImpl\(float\)>', - 'Unexpected functor signature', + r'FunctorSignatureDoesNotMatchError<ScalerImpl\(double\),ScalerImpl\(float\)>', + r'Unexpected functor signature', COMMON_DEFINITIONS, source, locals()) @@ -1632,8 +1632,8 @@ def test_register_factory_inconsistent_signature_returning_value(): } ''' expect_compile_error( - 'FunctorSignatureDoesNotMatchError<Scaler\(double\),Scaler\(float\)>', - 'Unexpected functor signature', + r'FunctorSignatureDoesNotMatchError<Scaler\(double\),Scaler\(float\)>', + r'Unexpected functor signature', COMMON_DEFINITIONS, source) @@ -1684,8 +1684,8 @@ def test_register_factory_not_existing_constructor1(XAnnot, XFactoryAnnot): } ''' expect_compile_error( - 'FunctorSignatureDoesNotMatchError<XAnnot\(int\),XAnnot\((void)?\)>', - 'Unexpected functor signature', + r'FunctorSignatureDoesNotMatchError<XAnnot\(int\),XAnnot\((void)?\)>', + r'Unexpected functor signature', COMMON_DEFINITIONS, source, locals()) @@ -1694,11 +1694,11 @@ def test_register_factory_not_existing_constructor1(XAnnot, XFactoryAnnot): # or mention that there are other ways to satisfy that dependency. @pytest.mark.parametrize('XIntFactoryAnnot,XIntFactoryAnnotRegex,XVoidFactoryAnnotRegex', [ ('std::function<std::unique_ptr<X>(int)>', - 'std::unique_ptr<X(,std::default_delete<X>)?>\(int\)', - 'std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)'), + r'std::unique_ptr<X(,std::default_delete<X>)?>\(int\)', + r'std::unique_ptr<X(,std::default_delete<X>)?>\((void)?\)'), ('fruit::Annotated<Annotation1, std::function<std::unique_ptr<X>(int)>>', - 'fruit::Annotated<Annotation1,std::unique_ptr<X(,std::default_delete<X>)?>>\(int\)', - 'fruit::Annotated<Annotation1,std::unique_ptr<X(,std::default_delete<X>)?>>\((void)?\)') + r'fruit::Annotated<Annotation1,std::unique_ptr<X(,std::default_delete<X>)?>>\(int\)', + r'fruit::Annotated<Annotation1,std::unique_ptr<X(,std::default_delete<X>)?>>\((void)?\)') ]) def test_register_factory_not_existing_constructor2(XIntFactoryAnnot, XIntFactoryAnnotRegex, XVoidFactoryAnnotRegex): source = ''' @@ -1736,8 +1736,8 @@ def test_register_factory_not_existing_constructor2_returning_value(XAnnot, XFac } ''' expect_compile_error( - 'FunctorSignatureDoesNotMatchError<XAnnot\(int\), XAnnot\((void)?\)>', - 'Unexpected functor signature', + r'FunctorSignatureDoesNotMatchError<XAnnot\(int\), XAnnot\((void)?\)>', + r'Unexpected functor signature', COMMON_DEFINITIONS, source, locals()) @@ -2114,8 +2114,8 @@ def test_provider_get_error_type_unique_pointer_pointer_not_provided(): } ''' expect_compile_error( - 'TypeNotProvidedError<std::unique_ptr<X(,std::default_delete<X>)?>\*>', - 'Trying to get an instance of T, but it is not provided by this Provider/Injector.', + r'TypeNotProvidedError<std::unique_ptr<X(,std::default_delete<X>)?>\*>', + r'Trying to get an instance of T, but it is not provided by this Provider/Injector.', COMMON_DEFINITIONS, source) @@ -2308,13 +2308,13 @@ def test_register_factory_abstract_class_with_no_virtual_destructor_error(WithAn } ''' expect_compile_error( - 'RegisterFactoryForUniquePtrOfAbstractClassWithNoVirtualDestructorError<I>', - 'registerFactory\(\) was called with a lambda that returns a std::unique_ptr<T>, but T is an abstract class', + r'RegisterFactoryForUniquePtrOfAbstractClassWithNoVirtualDestructorError<I>', + r'registerFactory\(\) was called with a lambda that returns a std::unique_ptr<T>, but T is an abstract class', COMMON_DEFINITIONS, source, locals(), ignore_warnings=True, disable_error_line_number_check=True) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_register_instance.py b/tests/test_register_instance.py index f449809..5e4390b 100755 --- a/tests/test_register_instance.py +++ b/tests/test_register_instance.py @@ -294,12 +294,12 @@ def test_bind_instance_non_normalized_type_error(XVariant): locals()) @pytest.mark.parametrize('XVariant,XVariantRegexp', [ - ('const X', 'const X'), - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('X&', 'X&'), - ('const X&', 'const X&'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), + ('const X', r'const X'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('X&', r'X&'), + ('const X&', r'const X&'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), ]) def test_bind_instance_non_normalized_type_error_with_annotation(XVariant, XVariantRegexp): source = ''' @@ -357,9 +357,9 @@ def test_bind_instance_non_normalized_type_error_two_explicit_type_arguments(XAn locals()) @pytest.mark.parametrize('XVariant,XVariantRegex', [ - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), ]) def test_register_instance_error_must_be_reference(XVariant, XVariantRegex): source = ''' @@ -378,9 +378,9 @@ def test_register_instance_error_must_be_reference(XVariant, XVariantRegex): locals()) @pytest.mark.parametrize('XVariant,XVariantRegex', [ - ('X*', 'X\*'), - ('const X*', 'const X\*'), - ('std::shared_ptr<X>', 'std::shared_ptr<X>'), + ('X*', r'X\*'), + ('const X*', r'const X\*'), + ('std::shared_ptr<X>', r'std::shared_ptr<X>'), ]) def test_register_instance_error_must_be_reference_with_annotation(XVariant, XVariantRegex): source = ''' @@ -492,5 +492,5 @@ def test_bind_instance_type_not_injectable_error(XVariant, XVariantRegex): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_register_provider.py b/tests/test_register_provider.py index d34803d..dde971c 100755 --- a/tests/test_register_provider.py +++ b/tests/test_register_provider.py @@ -37,7 +37,7 @@ COMMON_DEFINITIONS = ''' ('X()', 'X'), ('new X()', 'X*'), ]) -def test_register_provider_success(WithAnnot,ConstructX, XPtr): +def test_register_provider_success(WithAnnot, ConstructX, XPtr): source = ''' struct X : public ConstructionTracker<X> { int value = 5; @@ -122,8 +122,8 @@ def test_register_provider_abstract_class_with_no_virtual_destructor_error(WithA } ''' expect_compile_error( - 'ProviderReturningPointerToAbstractClassWithNoVirtualDestructorError<I>', - 'registerProvider\(\) was called with a lambda that returns a pointer to T, but T is an abstract class', + r'ProviderReturningPointerToAbstractClassWithNoVirtualDestructorError<I>', + r'registerProvider\(\) was called with a lambda that returns a pointer to T, but T is an abstract class', COMMON_DEFINITIONS, source, locals()) @@ -513,5 +513,5 @@ def test_register_provider_with_param_error_type_not_injectable(ConstructX, XPtr locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_required_types.py b/tests/test_required_types.py index ab375f6..c76c955 100755 --- a/tests/test_required_types.py +++ b/tests/test_required_types.py @@ -299,5 +299,5 @@ def test_required_const_annotated_forward_declared_success(): ''' expect_success(COMMON_DEFINITIONS, source) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_semistatic_map_hash_selection.py b/tests/test_semistatic_map_hash_selection.py index 6bf557a..7e53123 100644 --- a/tests/test_semistatic_map_hash_selection.py +++ b/tests/test_semistatic_map_hash_selection.py @@ -54,5 +54,5 @@ def test_semistatic_map_hash_selection(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_type_alignment.py b/tests/test_type_alignment.py index 39d8193..9d69d95 100644 --- a/tests/test_type_alignment.py +++ b/tests/test_type_alignment.py @@ -56,5 +56,5 @@ def test_everything(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/test_type_alignment_with_annotation.py b/tests/test_type_alignment_with_annotation.py index c830c4d..7e0fe21 100644 --- a/tests/test_type_alignment_with_annotation.py +++ b/tests/test_type_alignment_with_annotation.py @@ -65,5 +65,5 @@ def test_type_alignment_with_annotation(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/util/test_lambda_invoker.py b/tests/util/test_lambda_invoker.py index 321962f..e25214e 100644 --- a/tests/util/test_lambda_invoker.py +++ b/tests/util/test_lambda_invoker.py @@ -62,5 +62,5 @@ def test_invoke_some_args(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) diff --git a/tests/util/test_type_info.py b/tests/util/test_type_info.py index c1225e0..102e14c 100644 --- a/tests/util/test_type_info.py +++ b/tests/util/test_type_info.py @@ -90,5 +90,5 @@ def test_isTriviallyDestructible_false(): source, locals()) -if __name__== '__main__': +if __name__ == '__main__': main(__file__) |