mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Swift: tag -> pragma in codegen
For the use the former tags are meant for, pragma is a more meaningful name. It now also accepts both strings and lists of strings.
This commit is contained in:
@@ -458,13 +458,13 @@ def test_test_properties_skipped(opts, generate_tests):
|
||||
write(opts.ql_test_output / "Derived" / "test.swift")
|
||||
assert generate_tests([
|
||||
schema.Class("Base", derived={"Derived"}, properties=[
|
||||
schema.SingleProperty("x", "string", tags=["no_qltest", "foo"]),
|
||||
schema.RepeatedProperty("y", "int", tags=["bar", "no_qltest"]),
|
||||
schema.SingleProperty("x", "string", pragmas=["skip_qltest", "foo"]),
|
||||
schema.RepeatedProperty("y", "int", pragmas=["bar", "skip_qltest"]),
|
||||
]),
|
||||
schema.Class("Derived", bases={"Base"}, properties=[
|
||||
schema.PredicateProperty("a", tags=["no_qltest"]),
|
||||
schema.PredicateProperty("a", pragmas=["skip_qltest"]),
|
||||
schema.OptionalProperty(
|
||||
"b", "int", tags=["bar", "no_qltest", "baz"]),
|
||||
"b", "int", pragmas=["bar", "skip_qltest", "baz"]),
|
||||
]),
|
||||
]) == {
|
||||
"Derived/Derived.ql": ql.ClassTester(class_name="Derived"),
|
||||
@@ -474,7 +474,7 @@ def test_test_properties_skipped(opts, generate_tests):
|
||||
def test_test_base_class_skipped(opts, generate_tests):
|
||||
write(opts.ql_test_output / "Derived" / "test.swift")
|
||||
assert generate_tests([
|
||||
schema.Class("Base", derived={"Derived"}, tags=["no_qltest", "foo"], properties=[
|
||||
schema.Class("Base", derived={"Derived"}, pragmas=["skip_qltest", "foo"], properties=[
|
||||
schema.SingleProperty("x", "string"),
|
||||
schema.RepeatedProperty("y", "int"),
|
||||
]),
|
||||
@@ -488,7 +488,7 @@ def test_test_final_class_skipped(opts, generate_tests):
|
||||
write(opts.ql_test_output / "Derived" / "test.swift")
|
||||
assert generate_tests([
|
||||
schema.Class("Base", derived={"Derived"}),
|
||||
schema.Class("Derived", bases={"Base"}, tags=["no_qltest", "foo"], properties=[
|
||||
schema.Class("Derived", bases={"Base"}, pragmas=["skip_qltest", "foo"], properties=[
|
||||
schema.SingleProperty("x", "string"),
|
||||
schema.RepeatedProperty("y", "int"),
|
||||
]),
|
||||
|
||||
@@ -217,32 +217,81 @@ A:
|
||||
]
|
||||
|
||||
|
||||
def test_property_with_explicit_type_and_tags(load):
|
||||
def test_property_with_explicit_type_and_pragmas(load):
|
||||
ret = load("""
|
||||
A:
|
||||
x:
|
||||
type: string*
|
||||
_tags: [foo, bar]
|
||||
_pragma: [foo, bar]
|
||||
""")
|
||||
assert ret.classes == [
|
||||
schema.Class(root_name, derived={'A'}),
|
||||
schema.Class('A', bases={root_name}, properties=[
|
||||
schema.RepeatedProperty('x', 'string', tags=["foo", "bar"]),
|
||||
schema.RepeatedProperty('x', 'string', pragmas=["foo", "bar"]),
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
def test_class_with_tags(load):
|
||||
def test_property_with_explicit_type_and_one_pragma(load):
|
||||
ret = load("""
|
||||
A:
|
||||
x:
|
||||
type: string*
|
||||
_pragma: foo
|
||||
""")
|
||||
assert ret.classes == [
|
||||
schema.Class(root_name, derived={'A'}),
|
||||
schema.Class('A', bases={root_name}, properties=[
|
||||
schema.RepeatedProperty('x', 'string', pragmas=["foo"]),
|
||||
]),
|
||||
]
|
||||
|
||||
|
||||
def test_property_with_explicit_type_and_unknown_metadata(load):
|
||||
with pytest.raises(schema.Error):
|
||||
load("""
|
||||
A:
|
||||
x:
|
||||
type: string*
|
||||
_what_is_this: [foo, bar]
|
||||
""")
|
||||
|
||||
|
||||
def test_property_with_dict_without_explicit_type(load):
|
||||
with pytest.raises(schema.Error):
|
||||
load("""
|
||||
A:
|
||||
x:
|
||||
typo: string*
|
||||
""")
|
||||
|
||||
|
||||
|
||||
def test_class_with_pragmas(load):
|
||||
ret = load("""
|
||||
A:
|
||||
x: string*
|
||||
_tags: [foo, bar]
|
||||
_pragma: [foo, bar]
|
||||
""")
|
||||
assert ret.classes == [
|
||||
schema.Class(root_name, derived={'A'}),
|
||||
schema.Class('A', bases={root_name}, properties=[
|
||||
schema.RepeatedProperty('x', 'string'),
|
||||
], tags=["foo", "bar"]),
|
||||
], pragmas=["foo", "bar"]),
|
||||
]
|
||||
|
||||
|
||||
def test_class_with_one_pragma(load):
|
||||
ret = load("""
|
||||
A:
|
||||
x: string*
|
||||
_pragma: foo
|
||||
""")
|
||||
assert ret.classes == [
|
||||
schema.Class(root_name, derived={'A'}),
|
||||
schema.Class('A', bases={root_name}, properties=[
|
||||
schema.RepeatedProperty('x', 'string'),
|
||||
], pragmas=["foo"]),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user