コード例 #1
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
 def test_extend_with_other_options(self):
     options = CMakeOptions()
     options.define('FOO', 'foo')
     options.define('BAR', True)
     derived = CMakeOptions()
     derived.extend(options)
     self.assertIn('-DFOO=foo', derived)
     self.assertIn('-DBAR=TRUE', derived)
コード例 #2
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
    def test_operations(self):

        options1 = CMakeOptions()
        options1.define("OPT1_1", 'VAL1')
        options1.define("OPT1_2", 'VAL2')

        options2 = CMakeOptions()
        options2.define("OPT2_1", 'VAL3')

        options = options1 + options2
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3"])

        options_added = options + ["-CUSTOM", "12"]
        self.assertIsInstance(options_added, CMakeOptions)
        self.assertEqual(list(options_added), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-CUSTOM", "12"])

        options += options2
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-DOPT2_1=VAL3"])

        options += ["-G", "Ninja"]
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-DOPT2_1=VAL3",
            "-G", "Ninja"])

        list_options = ["-G", "Ninja"]
        list_options += options1
        self.assertIsInstance(list_options, list)
        self.assertEqual(list_options, [
            "-G", "Ninja",
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2"])
コード例 #3
0
ファイル: test_cmake.py プロジェクト: 18233135268/swift
    def test_operations(self):

        options1 = CMakeOptions()
        options1.define("OPT1_1", 'VAL1')
        options1.define("OPT1_2", 'VAL2')

        options2 = CMakeOptions()
        options2.define("OPT2_1", 'VAL3')

        options = options1 + options2
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3"])

        options_added = options + ["-CUSTOM", "12"]
        self.assertIsInstance(options_added, CMakeOptions)
        self.assertEqual(list(options_added), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-CUSTOM", "12"])

        options += options2
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-DOPT2_1=VAL3"])

        options += ["-G", "Ninja"]
        self.assertIsInstance(options, CMakeOptions)
        self.assertEqual(list(options), [
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2",
            "-DOPT2_1=VAL3",
            "-DOPT2_1=VAL3",
            "-G", "Ninja"])

        list_options = ["-G", "Ninja"]
        list_options += options1
        self.assertIsInstance(list_options, list)
        self.assertEqual(list_options, [
            "-G", "Ninja",
            "-DOPT1_1=VAL1",
            "-DOPT1_2=VAL2"])
コード例 #4
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
 def test_contains(self):
     options = CMakeOptions()
     self.assertTrue('-DFOO=foo' not in options)
     options.define('FOO', 'foo')
     self.assertTrue('-DFOO=foo' in options)
コード例 #5
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
 def test_extend_with_tuples(self):
     options = CMakeOptions()
     options.extend([('FOO', 'foo'), ('BAR', True)])
     self.assertIn('-DFOO=foo', options)
     self.assertIn('-DBAR=TRUE', options)
コード例 #6
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
 def test_booleans_are_translated(self):
     options = CMakeOptions()
     options.define('A_BOOLEAN_OPTION', True)
     options.define('ANOTHER_BOOLEAN_OPTION', False)
     self.assertIn('-DA_BOOLEAN_OPTION=TRUE', options)
     self.assertIn('-DANOTHER_BOOLEAN_OPTION=FALSE', options)
コード例 #7
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
 def test_initial_options_with_tuples(self):
     options = CMakeOptions([('FOO', 'foo'), ('BAR', True)])
     self.assertIn('-DFOO=foo', options)
     self.assertIn('-DBAR=TRUE', options)
コード例 #8
0
ファイル: test_cmake.py プロジェクト: stjordanis/swift-2
    def test_define(self):
        options = CMakeOptions()

        options.define('OPT1:STRING', 'foo')

        options.define('OPT2:BOOL', True)
        options.define('OPT3:BOOL', 1)
        options.define('OPT4:BOOL', 'True')
        options.define('OPT5:BOOL', 'true')
        options.define('OPT6:BOOL', 'YES')
        options.define('OPT7:BOOL', '1')

        options.define('OPT8:BOOL', False)
        options.define('OPT9:BOOL', 0)
        options.define('OPT10:BOOL', 'false')
        options.define('OPT11:BOOL', 'False')
        options.define('OPT12:BOOL', 'No')
        options.define('OPT13:BOOL', '0')

        options.define('OPT14', 12)
        options.define('OPT15', '')
        options.define('OPT16', None)
        options.define('OPT17:PATH', 'foo')

        self.assertRaises(ValueError, options.define, 'ERR', ["FOO"])
        self.assertRaises(ValueError, options.define, 'ERR', {"FOO": 1})

        self.assertRaises(ValueError, options.define, 'ERR:BOOL', None)
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', 3)
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', 'foo')
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', [1])

        self.assertEqual(list(options), [
            '-DOPT1:STRING=foo',
            '-DOPT2:BOOL=TRUE',
            '-DOPT3:BOOL=TRUE',
            '-DOPT4:BOOL=TRUE',
            '-DOPT5:BOOL=TRUE',
            '-DOPT6:BOOL=TRUE',
            '-DOPT7:BOOL=TRUE',
            '-DOPT8:BOOL=FALSE',
            '-DOPT9:BOOL=FALSE',
            '-DOPT10:BOOL=FALSE',
            '-DOPT11:BOOL=FALSE',
            '-DOPT12:BOOL=FALSE',
            '-DOPT13:BOOL=FALSE',
            '-DOPT14=12',
            '-DOPT15=',
            '-DOPT16=',
            '-DOPT17:PATH=foo'])
コード例 #9
0
ファイル: test_cmake.py プロジェクト: 18233135268/swift
    def test_define(self):
        options = CMakeOptions()

        options.define('OPT1:STRING', 'foo')

        options.define('OPT2:BOOL', True)
        options.define('OPT3:BOOL', 1)
        options.define('OPT4:BOOL', 'True')
        options.define('OPT5:BOOL', 'true')
        options.define('OPT6:BOOL', 'YES')
        options.define('OPT7:BOOL', '1')

        options.define('OPT8:BOOL', False)
        options.define('OPT9:BOOL', 0)
        options.define('OPT10:BOOL', 'false')
        options.define('OPT11:BOOL', 'False')
        options.define('OPT12:BOOL', 'No')
        options.define('OPT13:BOOL', '0')

        options.define('OPT14', 12)
        options.define('OPT15', '')
        options.define('OPT16', None)
        options.define('OPT17:PATH', 'foo')

        self.assertRaises(ValueError, options.define, 'ERR', ["FOO"])
        self.assertRaises(ValueError, options.define, 'ERR', {"FOO": 1})

        self.assertRaises(ValueError, options.define, 'ERR:BOOL', None)
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', 3)
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', 'foo')
        self.assertRaises(ValueError, options.define, 'ERR:BOOL', [1])

        self.assertEqual(list(options), [
            '-DOPT1:STRING=foo',
            '-DOPT2:BOOL=TRUE',
            '-DOPT3:BOOL=TRUE',
            '-DOPT4:BOOL=TRUE',
            '-DOPT5:BOOL=TRUE',
            '-DOPT6:BOOL=TRUE',
            '-DOPT7:BOOL=TRUE',
            '-DOPT8:BOOL=FALSE',
            '-DOPT9:BOOL=FALSE',
            '-DOPT10:BOOL=FALSE',
            '-DOPT11:BOOL=FALSE',
            '-DOPT12:BOOL=FALSE',
            '-DOPT13:BOOL=FALSE',
            '-DOPT14=12',
            '-DOPT15=',
            '-DOPT16=',
            '-DOPT17:PATH=foo'])