Skip to content

Commit af79bc2

Browse files
committed
test: introduce a helper for building mock plugins
Introduce a helper for mock plugins as `-rpath` is not a portable construct. This allows running more of the macro tests on Windows.
1 parent cfd070f commit af79bc2

5 files changed

+28
-28
lines changed

test/Macros/lit.local.cfg

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
# '-enable-experimental-feature Macros' requires an asserts build.
22
if 'asserts' not in config.available_features:
33
config.unsupported = True
4+
5+
config.subsitutions = list(config.substitutions)
6+
7+
def get_target_os():
8+
import re
9+
(run_cpu, run_vendor, run_os, run_version) = re.match('([^-]+)-([^-]+)-([^0-9]+)(.*)', config.variant_triple).groups()
10+
return run_os
11+
12+
if get_target_os() in ['windows-msvc']:
13+
config.substitutions.insert(
14+
0,
15+
(
16+
'%swift-build-cxx-plugin',
17+
'%clang -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin'
18+
)
19+
)
20+
else:
21+
config.substitutions.insert(
22+
0,
23+
(
24+
'%swift-build-cxx-plugin',
25+
'%clang -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin -Xlinker -rpath -Xlinker %swift-lib-dir'
26+
)
27+
)

test/Macros/macro_plugin_basic.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: split-file %s %t
55

6-
// RUN: %clang \
7-
// RUN: -isysroot %host_sdk \
8-
// RUN: -I %swift_src_root/include \
9-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
10-
// RUN: -Wl,-rpath,%swift-lib-dir \
11-
// RUN: -o %t/mock-plugin \
12-
// RUN: %t/plugin.c
6+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/plugin.c
137

148
// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \
159
// RUN: -typecheck -verify \

test/Macros/macro_plugin_error.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: split-file %s %t
55

6-
// RUN: %clang \
7-
// RUN: -isysroot %host_sdk \
8-
// RUN: -I %swift_src_root/include \
9-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
10-
// RUN: -Wl,-rpath,%swift-lib-dir \
11-
// RUN: -o %t/mock-plugin \
12-
// RUN: %t/plugin.c
6+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/plugin.c
137

148
// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \
159
// RUN: -typecheck -verify \

test/Macros/macro_plugin_searchorder.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@
4040
// RUN: -g -no-toolchain-stdlib-rpath
4141

4242
//#-- For -load-plugin-executable
43-
// RUN: %clang \
44-
// RUN: -isysroot %host_sdk \
45-
// RUN: -I %swift_src_root/include \
46-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
47-
// RUN: -Wl,-rpath,%swift-lib-dir \
48-
// RUN: -o %t/libexec/MacroDefinitionPlugin \
49-
// RUN: %t/src/MacroDefinition.c
43+
// RUN: %swift-build-cxx-plugin -o %t/libexec/MacroDefinitionPlugin %t/src/MacroDefinition.c
5044

5145
//#-- Expect -load-plugin-library
5246
// RUN: %target-build-swift %t/src/test.swift \

test/Macros/macro_swiftdeps.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616
// RUN: -g -no-toolchain-stdlib-rpath
1717

1818
//#-- Prepare the macro executable plugin.
19-
// RUN: %clang \
20-
// RUN: -isysroot %host_sdk \
21-
// RUN: -I %swift_src_root/include \
22-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
23-
// RUN: -Wl,-rpath,%swift-lib-dir \
24-
// RUN: -o %t/mock-plugin \
25-
// RUN: %t/src/plugin.c
19+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/src/plugin.c
2620

2721
//#-- Prepare the macro library.
2822
// RUN: %target-swift-frontend \

0 commit comments

Comments
 (0)