Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/Utils/update-verify-tests/remarks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: not %target-swift-frontend-verify -typecheck %t/test.swift -Rmodule-api-import 2>%t/output.txt
// RUN: %update-verify-tests < %t/output.txt
// RUN: %target-swift-frontend-verify -typecheck %t/test.swift -Rmodule-api-import
// RUN: %diff %t/test.swift %t/test.swift.expected

//--- test.swift
public typealias Foo = String

public typealias Bar = Optional<Int> // expected-remark@+1{{asdf}}

//--- test.swift.expected
// expected-remark@+1{{struct 'String' is imported via 'Swift'}}
public typealias Foo = String

// expected-remark@+2{{struct 'Int' is imported via 'Swift'}}
// expected-remark@+1{{generic enum 'Optional' is imported via 'Swift'}}
public typealias Bar = Optional<Int>

64 changes: 64 additions & 0 deletions test/Utils/update-verify-tests/update-existing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: not %target-swift-frontend-verify -typecheck %t/test.swift 2>%t/output.txt
// RUN: %update-verify-tests < %t/output.txt
// RUN: %target-swift-frontend-verify -typecheck %t/test.swift
// RUN: %diff %t/test.swift %t/test.swift.expected

//--- test.swift
func foo() {
let a = 2 // expected-error@+1{{asdf}}
b = a // expected-error@+1{{asdf}}
}

func bar() {
a = 2 // expected-error@+1{{asdf}}
}

func baz() {
// expected-error@+2{{cannot find 'a' in scope}}
// expected-error@+1{{cannot find 'a'}}
let b = a; let c = a; // expected-error{{asdf}}
}

func qux() {
let b = a; let c = a; // expected-error{{asdf}}
}

func foobar() {
var b = 1
b = a; b = a; // expected-error{{asdf}}
}

//--- test.swift.expected
func foo() {
// expected-note@+1{{'a' declared here}}
let a = 2 // expected-error@+1{{cannot find 'b' in scope; did you mean 'a'?}}
b = a
}

func bar() {
// expected-error@+1{{cannot find 'a' in scope}}
a = 2
}

func baz() {
// expected-error@+3{{cannot find 'a' in scope}}
// expected-error@+2{{cannot find 'a'}}
// expected-note@+1{{'b' declared here}}
let b = a; let c = a;
}

func qux() {
// expected-note@+2{{'b' declared here}}
// expected-error@+1{{cannot find 'a' in scope}}
let b = a; let c = a; // expected-error{{cannot find 'a' in scope; did you mean 'b'?}}
}

func foobar() {
// expected-note@+1 2{{'b' declared here}}
var b = 1
b = a; b = a; // expected-error 2{{cannot find 'a' in scope; did you mean 'b'?}}
}

7 changes: 4 additions & 3 deletions utils/update_verify_tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def render(self):
res = self.content.replace("{{DIAG}}", self.diag.render())
if not res.strip():
return ""
return res
return res.rstrip() + "\n"


class Diag:
Expand Down Expand Up @@ -185,7 +185,7 @@ def render(self):


expected_diag_re = re.compile(
r"//(\s*)expected-([a-zA-Z-]*)(note|warning|error)(-re)?(@[+-]?\d+)?(:\d+)?(\s*)(\d+)?\{\{(.*)\}\}"
r"//(\s*)expected-([a-zA-Z-]*)(note|warning|error|remark)(-re)?(@[+-]?\d+)?(:\d+)?(\s*)(\d+)?\{\{(.*)\}\}"
)
expected_expansion_diag_re = re.compile(
r"//(\s*)expected-([a-zA-Z-]*)(expansion)(-re)?(@[+-]?\d+)(:\d+)(\s*)(\d+)?\{\{(.*)"
Expand Down Expand Up @@ -398,7 +398,7 @@ def remove_dead_diags(lines):
remove_line(line, lines)
else:
assert line.diag.is_from_source_file
for other_diag in line.targeting_diags:
for other_diag in line.diag.target.targeting_diags:
if (
other_diag.is_from_source_file
or other_diag.count == 0
Expand All @@ -409,6 +409,7 @@ def remove_dead_diags(lines):
continue
line.diag.take(other_diag)
remove_line(other_diag.line, lines)
break


def fold_expansions(lines):
Expand Down