mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Macros] Use SWIFT_DUMP_PLUGIN_MESSAGING to test exectuable plugins
And stop using '-dump-macro-expansions'
This commit is contained in:
@@ -11,16 +11,23 @@
|
||||
// RUN: -o %t/mock-plugin \
|
||||
// RUN: %t/plugin.c
|
||||
|
||||
// RUN: %swift-target-frontend \
|
||||
// RUN: SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \
|
||||
// RUN: -typecheck -verify \
|
||||
// RUN: -swift-version 5 \
|
||||
// RUN: -load-plugin-executable %t/mock-plugin#TestPlugin \
|
||||
// RUN: -dump-macro-expansions \
|
||||
// RUN: -module-name MyApp \
|
||||
// RUN: %t/test.swift \
|
||||
// RUN: 2>&1 | tee %t/macro-expansions.txt
|
||||
|
||||
// RUN: %FileCheck -strict-whitespace %s < %t/macro-expansions.txt
|
||||
|
||||
// CHECK: ->(plugin:[[#PID:]]) {"getCapability":{}}
|
||||
// CHECK: <-(plugin:[[#PID]]) {"getCapabilityResult":{"capability":{"protocolVersion":1}}}
|
||||
// CHECK: ->(plugin:[[#PID]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"testString","typeName":"TestStringMacro"},"syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"BUILD_DIR{{.+}}test.swift","line":5,"offset":301},"source":"#testString(123)"}}}
|
||||
// CHECK: <-(plugin:[[#PID]]) {"expandFreestandingMacroResult":{"diagnostics":[],"expandedSource":"\"123\"\n + \"foo \""}}
|
||||
// CHECK: ->(plugin:[[#PID]]) {"expandFreestandingMacro":{"discriminator":"$s{{.+}}","macro":{"moduleName":"TestPlugin","name":"testStringWithError","typeName":"TestStringWithErrorMacro"},"syntax":{"kind":"expression","location":{"column":19,"fileID":"MyApp/test.swift","fileName":"BUILD_DIR{{.+}}test.swift","line":6,"offset":336},"source":"#testStringWithError(321)"}}}
|
||||
// CHECK: <-(plugin:[[#PID]]) {"expandFreestandingMacroResult":{"diagnostics":[{"fixIts":[],"highlights":[],"message":"message from plugin","notes":[],"position":{"fileName":"BUILD_DIR{{.*}}test.swift","offset":336},"severity":"error"}],"expandedSource":"\"bar\""}}
|
||||
|
||||
//--- test.swift
|
||||
@freestanding(expression) macro testString(_: Any) -> String = #externalMacro(module: "TestPlugin", type: "TestStringMacro")
|
||||
@freestanding(expression) macro testStringWithError(_: Any) -> String = #externalMacro(module: "TestPlugin", type: "TestStringWithErrorMacro")
|
||||
@@ -31,15 +38,6 @@ func test() {
|
||||
// expected-error @-1 {{message from plugin}}
|
||||
}
|
||||
|
||||
// CHECK: ------------------------------
|
||||
// CHECK-NEXT: {{^}}"123"
|
||||
// CHECK-NEXT: {{^}} + "foo "
|
||||
// CHECK-NEXT: ------------------------------
|
||||
|
||||
// CHECK: ------------------------------
|
||||
// CHECK-NEXT: {{^}}"bar"
|
||||
// CHECK-NEXT: ------------------------------
|
||||
|
||||
//--- plugin.c
|
||||
#include "swift-c/MockPlugin/MockPlugin.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user