def test_settings_model(self): # First level setting 'cppstd' is no longer supported settings = Settings.loads(get_default_settings_yml()) settings.cppstd = "11" with six.assertRaisesRegex(self, ConanV2Exception, "Setting 'cppstd' is deprecated"): settings_preprocessor.preprocess(settings=settings)
def test_custom_base_runtime_set(self): self.settings.build_type = "Debug" with pytest.raises(ConanException) as e: self.settings.compiler.runtime = "MT" preprocess(self.settings) assert "Invalid setting 'MT' is not a valid 'settings.compiler.runtime' value" \ in str(e.value)
def process_settings(self, cache, preprocess=True): self.processed_settings = cache.settings.copy() self.processed_settings.values = Values.from_list( list(self.settings.items())) if preprocess: settings_preprocessor.preprocess(self.processed_settings) # Redefine the profile settings values with the preprocessed ones # FIXME: Simplify the values.as_list() self.settings = OrderedDict( self.processed_settings.values.as_list()) # Preprocess also scoped settings for pkg, pkg_settings in self.package_settings.items(): pkg_profile = Profile() pkg_profile.settings = self.settings pkg_profile.update_settings(pkg_settings) try: pkg_profile.process_settings(cache=cache, preprocess=True) except Exception as e: pkg_profile = [ "{}={}".format(k, v) for k, v in pkg_profile.settings.items() ] raise ConanException( "Error in resulting settings for package" " '{}': {}\n{}".format(pkg, e, '\n'.join(pkg_profile)))
def process_settings(self, cache, preprocess=True): self.processed_settings = cache.settings.copy() self.processed_settings.values = Values.from_list(list(self.settings.items())) if preprocess: settings_preprocessor.preprocess(self.processed_settings) # Redefine the profile settings values with the preprocessed ones # FIXME: Simplify the values.as_list() self.settings = OrderedDict(self.processed_settings.values.as_list())
def load_graph(self, reference, create_reference, profile, build_mode, check_updates, update, remote_name, recorder, workspace): def _inject_require(conanfile, reference): """ test_package functionality requires injecting the tested package as requirement before running the install """ require = conanfile.requires.get(reference.name) if require: require.conan_reference = require.range_reference = reference else: conanfile.requires(str(reference)) conanfile._conan_user = reference.user conanfile._conan_channel = reference.channel # Computing the full dependency graph cache_settings = self._client_cache.settings.copy() cache_settings.values = profile.settings_values settings_preprocessor.preprocess(cache_settings) processed_profile = ProcessedProfile(cache_settings, profile, create_reference) if isinstance(reference, list): # Install workspace with multiple root nodes conanfile = self._loader.load_virtual(reference, processed_profile) elif isinstance(reference, ConanFileReference): # create without test_package and install <ref> conanfile = self._loader.load_virtual([reference], processed_profile) else: output = ScopedOutput("PROJECT", self._output) if reference.endswith(".py"): conanfile = self._loader.load_conanfile(reference, output, processed_profile, consumer=True) if create_reference: # create with test_package _inject_require(conanfile, create_reference) else: conanfile = self._loader.load_conanfile_txt( reference, output, processed_profile) build_mode = BuildMode(build_mode, self._output) root_node = Node(None, conanfile) deps_graph = self._load_graph( root_node, check_updates, update, build_mode=build_mode, remote_name=remote_name, profile_build_requires=profile.build_requires, recorder=recorder, workspace=workspace, processed_profile=processed_profile) build_mode.report_matches() return deps_graph, conanfile, cache_settings
def test_settings_model(self, use_settings_v1): # First level setting 'cppstd' is no longer supported settings = Settings.loads(get_default_settings_yml(force_v1=use_settings_v1)) if use_settings_v1: settings.cppstd = "11" with six.assertRaisesRegex(self, ConanV2Exception, "Setting 'cppstd' is deprecated"): settings_preprocessor.preprocess(settings=settings) else: with six.assertRaisesRegex(self, ConanException, "'settings.cppstd' doesn't exist"): settings.cppstd = "11" settings_preprocessor.preprocess(settings=settings)
def load_simple_graph(self, reference, profile, recorder): # Loads a graph without computing the binaries. It is necessary for # export-pkg command, not hitting the server # # https://github.com/conan-io/conan/issues/3432 builder = DepsGraphBuilder(self._proxy, self._output, self._loader, self._resolver, workspace=None, recorder=recorder) cache_settings = self._client_cache.settings.copy() cache_settings.values = profile.settings_values settings_preprocessor.preprocess(cache_settings) processed_profile = ProcessedProfile(cache_settings, profile, create_reference=None) conanfile = self._loader.load_virtual([reference], processed_profile) graph = builder.load_graph(conanfile, check_updates=False, update=False, remote_name=None, processed_profile=processed_profile) return graph
def custom_base_runtime_set_test(self): self.settings.build_type = "Debug" self.settings.compiler.runtime = "MT" preprocess(self.settings) self.assertEqual(self.settings.compiler.runtime, "MT")
def different_base_compiler_test(self): self.settings.compiler = "gcc" self.settings.build_type = "Debug" preprocess(self.settings) self.assertIsNone(self.settings.compiler.get_safe("runtime"))
def debug_build_type_runtime_test(self): self.settings.build_type = "Debug" preprocess(self.settings) self.assertEqual(self.settings.compiler.runtime, "MDd")
def release_build_type_runtime_test(self): self.settings.build_type = "Release" preprocess(self.settings) self.assertEqual(self.settings.compiler.runtime, "MD")
def test_different_base_compiler(self): self.settings.compiler = "gcc" self.settings.build_type = "Debug" preprocess(self.settings) assert self.settings.compiler.get_safe("runtime") is None
def test_debug_build_type_runtime(self): self.settings.build_type = "Debug" preprocess(self.settings) assert self.settings.compiler.runtime_type == "Debug"
def test_release_build_type_runtime(self): self.settings.build_type = "Release" preprocess(self.settings) assert self.settings.compiler.runtime_type == "Release"