Skip to content

Commit 642b93d

Browse files
committed
[Tests] Fix round-trip test to build with target libraries.
The round-trip test was relying on a host library, but that only works where we aren't cross-compiling. Using a target library instead was a little more complicated than it looked because libswiftDemangling doesn't get built for the target. However, it *is* part of the other Swift libraries on the host, but there's an extra namespace shoehorned in.
1 parent 232b538 commit 642b93d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/TypeRoundTrip/Inputs/RoundTrip/RoundTrip.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ using namespace swift;
1212

1313
static std::string nameForMetadata(const Metadata *md)
1414
{
15-
Demangle::StackAllocatedDemangler<1024> dem;
15+
Demangle::__runtime::StackAllocatedDemangler<1024> dem;
1616
auto nodeTree = _swift_buildDemanglingForMetadata(md, dem);
1717
if (!nodeTree)
1818
return "<unknown>";
1919

20-
std::string result = Demangle::nodeToString(nodeTree);
20+
std::string result = Demangle::__runtime::nodeToString(nodeTree);
2121
return result;
2222
}
2323

@@ -26,11 +26,11 @@ extern "C" SWIFT_CC(swift) void roundTripType(const Metadata *md) {
2626
const std::string mdName = ::nameForMetadata(md);
2727

2828
// Convert it to a Node tree
29-
Demangle::StackAllocatedDemangler<1024> dem;
29+
Demangle::__runtime::StackAllocatedDemangler<1024> dem;
3030
auto nodeTree = _swift_buildDemanglingForMetadata(md, dem);
3131

3232
// Mangle that
33-
std::string mangledName = Demangle::mangleNode(nodeTree);
33+
std::string mangledName = Demangle::__runtime::mangleNode(nodeTree);
3434

3535
// Look up the result
3636
auto result = swift_getTypeByMangledName(MetadataState::Abstract,

test/TypeRoundTrip/round-trip.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-clang -std=c++14 %target-rtti-opt %target-pic-opt %target-msvc-runtime-opt -g -c %S/Inputs/RoundTrip/RoundTrip.cpp -I%swift_obj_root/include -I%swift_src_root/include -I%swift_src_root/stdlib/include -I%swift_src_root/stdlib/public/runtime -I%llvm_src_root/include -I%llvm_obj_root/include -o %t/RoundTrip.o
2+
// RUN: %target-clang -std=c++14 %target-rtti-opt %target-pic-opt %target-msvc-runtime-opt -DSWIFT_INLINE_NAMESPACE=__runtime -g -c %S/Inputs/RoundTrip/RoundTrip.cpp -I%swift_obj_root/include -I%swift_src_root/include -I%swift_src_root/stdlib/include -I%swift_src_root/stdlib/public/runtime -I%llvm_src_root/include -I%llvm_obj_root/include -o %t/RoundTrip.o
33
// RUN: %target-build-swift -g -static -emit-module-path %t/RoundTrip.swiftmodule -emit-module -emit-library -module-name RoundTrip -o %t/%target-static-library-name(RoundTrip) %S/Inputs/RoundTrip/RoundTrip.swift %t/RoundTrip.o
44
// RUN: echo "// AUTOGENERATED" > %t/all-tests.swift
55
// RUN: for module in %S/Inputs/testcases/*.swift; do modname=$(basename $module .swift); echo "import $modname" >> %t/all-tests.swift; done
66
// RUN: echo "func runAllTests() throws {" >> %t/all-tests.swift
77
// RUN: for module in %S/Inputs/testcases/*.swift; do modname=$(basename $module .swift); %target-build-swift -g -static -emit-module-path %t/$modname.swiftmodule -emit-module -emit-library -module-name $modname -o %t/%target-static-library-name($modname) -I%t -L%t $module -lRoundTrip; echo " print(\"--- $modname\")" >> %t/all-tests.swift; echo " $modname.test()" >> %t/all-tests.swift; echo " print(\"\")" >> %t/all-tests.swift; echo "-l$modname" >> %t/link.txt; done
88
// RUN: echo "}" >> %t/all-tests.swift
9-
// RUN: %target-build-swift -g -I%t -o %t/round-trip %s %t/all-tests.swift -L%t -L%swift_obj_root/lib -L%swift_obj_root/lib/swift %target-cxx-lib $(cat %t/link.txt) -lRoundTrip -lswiftDemangling -lswiftReflection
9+
// RUN: %target-build-swift -g -I%t -o %t/round-trip %s %t/all-tests.swift -L%t %target-cxx-lib $(cat %t/link.txt) -lRoundTrip -lswiftReflection
1010
// RUN: %target-codesign %t/round-trip
1111
// RUN: %target-run %t/round-trip | %FileCheck %s
1212

0 commit comments

Comments
 (0)