def setUp(self): package_options = PackageOptions.loads("""{static: [True, False], optimized: [2, 3, 4], path: ANY}""") values = PackageOptionValues() values.add_option("static", True) values.add_option("optimized", 3) values.add_option("path", "NOTDEF") package_options.values = values self.sut = Options(package_options)
def pattern_unmatch_test(self): boost_values = PackageOptionValues() boost_values.add_option("fake_option", "FuzzBuzz") options = {"OpenSSL.*": boost_values} down_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "3"), ("path", "NOTDEF"), ("static", "True"), ("OpenSSL.*:fake_option", "FuzzBuzz"), ])
def test_pattern_unmatch(self): boost_values = PackageOptionValues() boost_values.add_option("fake_option", "FuzzBuzz") options = {"OpenSSL.*": boost_values} down_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "3"), ("path", "NOTDEF"), ("static", "True"), ("OpenSSL.*:fake_option", "FuzzBuzz"), ])
def pattern_ignore_test(self): boost_values = PackageOptionValues() boost_values.add_option("fake_option", "FuzzBuzz") options = {"Boost.*": boost_values} down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") output = TestBufferConanOutput() self.sut.propagate_upstream(options, down_ref, own_ref, output) self.assertEqual(self.sut.values.as_list(), [ ("optimized", "3"), ("path", "NOTDEF"), ("static", "True"), ("Boost.*:fake_option", "FuzzBuzz"), ])
def all_positive_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("path", "FuzzBuzz") options = {"*": boost_values} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "3"), ("path", "FuzzBuzz"), ("static", "False"), ("*:path", "FuzzBuzz"), ("*:static", "False"), ])
def test_propagate_in_pacakge_options(self): package_options = PackageOptions.loads("""{opt: [None, "a", "b"],}""") values = PackageOptionValues() package_options.values = values package_options.propagate_upstream({'opt': None}, None, None, []) self.assertEqual(package_options.values.items(), [('opt', 'None'), ])
def multi_pattern_error_test(self): boost_values = PackageOptionValues() boost_values.add_option("optimized", 4) boost_values2 = PackageOptionValues() boost_values2.add_option("optimized", 2) options = {"Boost.*": boost_values, "*": boost_values2} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") output = TestBufferConanOutput() with self.assertRaises(ConanException): self.sut.propagate_upstream(options, down_ref, own_ref, output)
def multi_pattern_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("path", "FuzzBuzz") boost_values2 = PackageOptionValues() boost_values2.add_option("optimized", 2) options = {"Boost.*": boost_values, "*": boost_values2} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [ ("optimized", "2"), ("path", "FuzzBuzz"), ("static", "False"), ('*:optimized', '2'), ("Boost.*:path", "FuzzBuzz"), ("Boost.*:static", "False"), ])
def multi_pattern_error_test(self): boost_values = PackageOptionValues() boost_values.add_option("optimized", 4) boost_values2 = PackageOptionValues() boost_values2.add_option("optimized", 2) options = {"Boost.*": boost_values, "*": boost_values2} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [('optimized', '4'), ('path', 'NOTDEF'), ('static', 'True'), ('*:optimized', '2'), ('Boost.*:optimized', '4')])
def test_propagate_in_options(self): package_options = PackageOptions.loads("""{opt: [None, "a", "b"],}""") values = PackageOptionValues() values.add_option("opt", "a") package_options.values = values sut = Options(package_options) other_options = PackageOptionValues() other_options.add_option("opt", None) options = {"whatever.*": other_options} down_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(sut.values.as_list(), [("opt", "a"), ("whatever.*:opt", "None"), ])
def setUp(self): package_options = PackageOptions.loads("""{static: [True, False], optimized: [2, 3, 4], path: ANY}""") values = PackageOptionValues() values.add_option("static", True) values.add_option("optimized", 3) values.add_option("path", "NOTDEF") package_options.values = values self.sut = Options(package_options)
def multi_pattern_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("path", "FuzzBuzz") boost_values2 = PackageOptionValues() boost_values2.add_option("optimized", 2) options = {"Boost.*": boost_values, "*": boost_values2} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "2"), ("path", "FuzzBuzz"), ("static", "False"), ('*:optimized', '2'), ("Boost.*:path", "FuzzBuzz"), ("Boost.*:static", "False"), ])
def test_all_positive(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("path", "FuzzBuzz") options = {"*": boost_values} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "3"), ("path", "FuzzBuzz"), ("static", "False"), ("*:path", "FuzzBuzz"), ("*:static", "False"), ])
def multi_pattern_error_test(self): boost_values = PackageOptionValues() boost_values.add_option("optimized", 4) boost_values2 = PackageOptionValues() boost_values2.add_option("optimized", 2) options = {"Boost.*": boost_values, "*": boost_values2} own_ref = ConanFileReference.loads("Boost.Assert/0.1@diego/testing") down_ref = ConanFileReference.loads("Consumer/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [('optimized', '4'), ('path', 'NOTDEF'), ('static', 'True'), ('*:optimized', '2'), ('Boost.*:optimized', '4')])
def basic_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("thread", True) boost_values.add_option("thread.multi", "off") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", True) hello1_values = PackageOptionValues() hello1_values.add_option("static", False) hello1_values.add_option("optimized", 4) options = { "Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values } down_ref = ConanFileReference.loads("Hello0/0.1@diego/testing") own_ref = ConanFileReference.loads("Hello1/0.1@diego/testing") output = TestBufferConanOutput() self.sut.propagate_upstream(options, down_ref, own_ref, output) self.assertEqual(self.sut.values.as_list(), [("optimized", "4"), ("path", "NOTDEF"), ("static", "False"), ("Boost:static", "False"), ("Boost:thread", "True"), ("Boost:thread.multi", "off"), ("Poco:deps_bundled", "True")]) boost_values = PackageOptionValues() boost_values.add_option("static", 2) boost_values.add_option("thread", "Any") boost_values.add_option("thread.multi", "on") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", "What") hello1_values = PackageOptionValues() hello1_values.add_option("static", True) hello1_values.add_option("optimized", "2") options2 = { "Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values } down_ref = ConanFileReference.loads("Hello2/0.1@diego/testing") self.sut.propagate_upstream(options2, down_ref, own_ref, output) self.assertIn( """WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option optimized to 2 but it was already assigned to 4 by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option static to True but it was already assigned to False by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:static to 2 but it was already assigned to False by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:thread to Any but it was already assigned to True by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:thread.multi to on but it was already assigned to off by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Poco:deps_bundled to What but it was already assigned to True by Hello0/0.1@diego/testing""", str(output)) self.assertEqual( self.sut.values.dumps(), """optimized=4 path=NOTDEF static=False Boost:static=False Boost:thread=True Boost:thread.multi=off Poco:deps_bundled=True""")
def basic_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("thread", True) boost_values.add_option("thread.multi", "off") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", True) hello1_values = PackageOptionValues() hello1_values.add_option("static", False) hello1_values.add_option("optimized", 4) options = {"Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values} down_ref = ConanFileReference.loads("Hello0/0.1@diego/testing") own_ref = ConanFileReference.loads("Hello1/0.1@diego/testing") output = TestBufferConanOutput() self.sut.propagate_upstream(options, down_ref, own_ref, output) self.assertEqual(self.sut.values.as_list(), [("optimized", "4"), ("path", "NOTDEF"), ("static", "False"), ("Boost:static", "False"), ("Boost:thread", "True"), ("Boost:thread.multi", "off"), ("Poco:deps_bundled", "True")]) boost_values = PackageOptionValues() boost_values.add_option("static", 2) boost_values.add_option("thread", "Any") boost_values.add_option("thread.multi", "on") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", "What") hello1_values = PackageOptionValues() hello1_values.add_option("static", True) hello1_values.add_option("optimized", "2") options2 = {"Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values} down_ref = ConanFileReference.loads("Hello2/0.1@diego/testing") self.sut.propagate_upstream(options2, down_ref, own_ref, output) self.assertIn("""WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option optimized to 2 but it was already assigned to 4 by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option static to True but it was already assigned to False by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:static to 2 but it was already assigned to False by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:thread to Any but it was already assigned to True by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Boost:thread.multi to on but it was already assigned to off by Hello0/0.1@diego/testing WARN: Hello2/0.1@diego/testing tried to change Hello1/0.1@diego/testing option Poco:deps_bundled to What but it was already assigned to True by Hello0/0.1@diego/testing""", str(output)) self.assertEqual(self.sut.values.dumps(), """optimized=4 path=NOTDEF static=False Boost:static=False Boost:thread=True Boost:thread.multi=off Poco:deps_bundled=True""")
def basic_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("thread", True) boost_values.add_option("thread.multi", "off") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", True) hello1_values = PackageOptionValues() hello1_values.add_option("static", False) hello1_values.add_option("optimized", 4) options = { "Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values } down_ref = ConanFileReference.loads("Hello0/0.1@diego/testing") own_ref = ConanFileReference.loads("Hello1/0.1@diego/testing") output = TestBufferConanOutput() self.sut.propagate_upstream(options, down_ref, own_ref, output) self.assertEqual(self.sut.values.as_list(), [("optimized", "4"), ("path", "NOTDEF"), ("static", "False"), ("Boost:static", "False"), ("Boost:thread", "True"), ("Boost:thread.multi", "off"), ("Poco:deps_bundled", "True")]) boost_values = PackageOptionValues() boost_values.add_option("static", 2) boost_values.add_option("thread", "Any") boost_values.add_option("thread.multi", "on") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", "What") hello1_values = PackageOptionValues() hello1_values.add_option("static", True) hello1_values.add_option("optimized", "2") options2 = { "Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values } down_ref = ConanFileReference.loads("Hello2/0.1@diego/testing") with self.assertRaisesRegexp( ConanException, "Hello2/0.1@diego/testing tried to change " "Hello1/0.1@diego/testing option optimized to 2"): self.sut.propagate_upstream(options2, down_ref, own_ref, output) self.assertEqual( self.sut.values.dumps(), """optimized=4 path=NOTDEF static=False Boost:static=False Boost:thread=True Boost:thread.multi=off Poco:deps_bundled=True""")
def basic_test(self): boost_values = PackageOptionValues() boost_values.add_option("static", False) boost_values.add_option("thread", True) boost_values.add_option("thread.multi", "off") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", True) hello1_values = PackageOptionValues() hello1_values.add_option("static", False) hello1_values.add_option("optimized", 4) options = {"Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values} down_ref = ConanFileReference.loads("Hello0/0.1@diego/testing") own_ref = ConanFileReference.loads("Hello1/0.1@diego/testing") self.sut.propagate_upstream(options, down_ref, own_ref) self.assertEqual(self.sut.values.as_list(), [("optimized", "4"), ("path", "NOTDEF"), ("static", "False"), ("Boost:static", "False"), ("Boost:thread", "True"), ("Boost:thread.multi", "off"), ("Poco:deps_bundled", "True")]) boost_values = PackageOptionValues() boost_values.add_option("static", 2) boost_values.add_option("thread", "Any") boost_values.add_option("thread.multi", "on") poco_values = PackageOptionValues() poco_values.add_option("deps_bundled", "What") hello1_values = PackageOptionValues() hello1_values.add_option("static", True) hello1_values.add_option("optimized", "2") options2 = {"Boost": boost_values, "Poco": poco_values, "Hello1": hello1_values} down_ref = ConanFileReference.loads("Hello2/0.1@diego/testing") with self.assertRaisesRegexp(ConanException, "Hello2/0.1@diego/testing tried to change " "Hello1/0.1@diego/testing option optimized to 2"): self.sut.propagate_upstream(options2, down_ref, own_ref) self.assertEqual(self.sut.values.dumps(), """optimized=4 path=NOTDEF static=False Boost:static=False Boost:thread=True Boost:thread.multi=off Poco:deps_bundled=True""")