Пример #1
0
    def test_msvc_build_command(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "14"

        # test build_type and arch override, for multi-config packages
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            cmd = tools.msvc_build_command(settings,
                                           "project.sln",
                                           build_type="Debug",
                                           arch="x86",
                                           output=self.output)
            self.assertEqual(len(w), 3)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)

        # tests errors if args not defined
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")
                tools.msvc_build_command(settings,
                                         "project.sln",
                                         output=self.output)
                self.assertEqual(len(w), 2)
                self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        settings.arch = "x86"
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter("always")
                tools.msvc_build_command(settings,
                                         "project.sln",
                                         output=self.output)
                self.assertEqual(len(w), 2)
                self.assertTrue(issubclass(w[0].category, DeprecationWarning))

        # successful definition via settings
        settings.build_type = "Debug"
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            cmd = tools.msvc_build_command(settings,
                                           "project.sln",
                                           output=self.output)
            self.assertEqual(len(w), 3)
            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)
Пример #2
0
    def test_msvc_build_command(self):
        settings = Settings.loads(get_default_settings_yml())
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "14"

        # test build_type and arch override, for multi-config packages
        cmd = tools.msvc_build_command(settings,
                                       "project.sln",
                                       build_type="Debug",
                                       arch="x86",
                                       output=self.output)
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)

        # tests errors if args not defined
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            tools.msvc_build_command(settings,
                                     "project.sln",
                                     output=self.output)

        settings.arch = "x86"
        with six.assertRaisesRegex(self, ConanException,
                                   "Cannot build_sln_command"):
            tools.msvc_build_command(settings,
                                     "project.sln",
                                     output=self.output)

        # successful definition via settings
        settings.build_type = "Debug"
        cmd = tools.msvc_build_command(settings,
                                       "project.sln",
                                       output=self.output)
        self.assertIn(
            'msbuild "project.sln" /p:Configuration="Debug" '
            '/p:UseEnv=false /p:Platform="x86"', cmd)
        self.assertIn('vcvarsall.bat', cmd)