Files
swift-mirror/validation-test/Reflection/reflect_extension_parent_class.swift
Duo Wang 9a62251826 [test][Reflection] Fix tests under remote-run (#90279)
`remote-run` walks each whole command-line argument and any
`REMOTE_RUN_CHILD_*` env-var value, and uploads paths that start with
`--output-prefix` (which lit sets to `%t`). This is purely a textual
match on argv elements. For the two tests modified in this PR, helper
dylibs do not appear on the command line and are therefore not uploaded
to the remote host under remote-run.

This PR fixes that by:
- `reflect_extension_parent_class.swift`: set a dummy env var to the
dylib path. remote-run's `EnvVarProcessor` runs every
`REMOTE_RUN_CHILD_*` value through the same upload logic as argv, so the
dylib gets rsynced
  the remote process.
- `reflect_Enum_values_resilient.swift`: same fix with
`libresilient_enums.dylib`.
2026-07-10 12:31:33 -07:00

62 lines
2.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-build-swift-dylib(%t/%target-library-name(Base)) %t/base.swift -emit-module -emit-module-path %t/Base.swiftmodule -module-name Base
// RUN: %target-codesign %t/%target-library-name(Base)
// RUN: %target-build-swift -lswiftSwiftReflectionTest %t/main.swift -L %t -I %t -lBase -o %t/reflect_extension_parent_class %target-rpath(%t)
// RUN: %target-codesign %t/reflect_extension_parent_class
// RUN: env %env-_EXTRA_DYLIB=%t/%target-library-name(Base) %target-run %target-swift-reflection-test %t/reflect_extension_parent_class | tee /dev/stderr | %FileCheck %s --dump-input=fail
// REQUIRES: executable_test
// REQUIRES: reflection_test_support
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: asan
// UNSUPPORTED: device_run
// Verifies that reflection can resolve types declared inside a cross-module
// extension — i.e., types whose parent (the extended type) lives in a
// different module than the extension itself.
//--- base.swift
public struct Outer {
public init() {}
}
//--- main.swift
import Base
import SwiftReflectionTest
extension Outer {
public class Inner<Content> {
public let field: Content
public init(_ v: Content) { self.field = v }
}
// Non-generic struct in an unconstrained cross-module extension.
public struct Plain {
public let flag: Int = 99
}
}
reflect(any: Outer.Inner<Int>(42))
// CHECK: Reflecting an existential.
// CHECK: Type reference:
// CHECK: (bound_generic_class (extension in reflect_extension_parent_class):Base.Outer.Inner
// CHECK: Mangled name: $s4Base5OuterV{{.*}}extension_parent_classE5InnerC{{.*}}
// CHECK: Demangled name: (extension in reflect_extension_parent_class):Base.Outer.Inner<Swift.Int>
reflect(any: Outer.Plain())
// CHECK: Reflecting an existential.
// CHECK: Type reference:
// CHECK: (struct (extension in reflect_extension_parent_class):Base.Outer.Plain
// CHECK: Mangled name: $s4Base5OuterV{{.*}}extension_parent_classE5PlainV{{.*}}
// CHECK: Demangled name: (extension in reflect_extension_parent_class):Base.Outer.Plain
doneReflecting()