-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break the tests dependency on the compiler plugin proto.
The tests can't be completely isolated from all upstream protos because they do need to use descriptor.proto, but this breaks the last dependency on an upstream file to continue minimizing the risk of the tests breaking from an upstream change.
- Loading branch information
Showing
10 changed files
with
1,737 additions
and
2,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
Protos/SwiftProtobufPluginLibraryTests/module_mappings.pbascii
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Protos/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test_import.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Protos/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test_import.proto - test proto | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
// ----------------------------------------------------------------------------- | ||
/// | ||
/// Test proto for Tests/SwiftProtobufPluginLibraryTests/Test_Descriptor.swift | ||
/// | ||
// ----------------------------------------------------------------------------- | ||
|
||
syntax = "proto2"; | ||
|
||
package swift_descriptor_test.import; | ||
|
||
message Version { | ||
optional int32 major = 1; | ||
optional int32 minor = 2; | ||
optional int32 patch = 3; | ||
optional string suffix = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
Reference/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test_import.pb.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// DO NOT EDIT. | ||
// swift-format-ignore-file | ||
// swiftlint:disable all | ||
// | ||
// Generated by the Swift generator plugin for the protocol buffer compiler. | ||
// Source: pluginlib_descriptor_test_import.proto | ||
// | ||
// For information on using the generated types, please see the documentation: | ||
// https://github.com/apple/swift-protobuf/ | ||
|
||
// Protos/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test_import.proto - test proto | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
// ----------------------------------------------------------------------------- | ||
/// | ||
/// Test proto for Tests/SwiftProtobufPluginLibraryTests/Test_Descriptor.swift | ||
/// | ||
// ----------------------------------------------------------------------------- | ||
|
||
import Foundation | ||
import SwiftProtobuf | ||
|
||
// If the compiler emits an error on this type, it is because this file | ||
// was generated by a version of the `protoc` Swift plug-in that is | ||
// incompatible with the version of SwiftProtobuf to which you are linking. | ||
// Please ensure that you are building against the same version of the API | ||
// that was used to generate this file. | ||
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { | ||
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} | ||
typealias Version = _2 | ||
} | ||
|
||
struct SwiftDescriptorTest_Import_Version: Sendable { | ||
// SwiftProtobuf.Message conformance is added in an extension below. See the | ||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for | ||
// methods supported on all messages. | ||
|
||
var major: Int32 { | ||
get {return _major ?? 0} | ||
set {_major = newValue} | ||
} | ||
/// Returns true if `major` has been explicitly set. | ||
var hasMajor: Bool {return self._major != nil} | ||
/// Clears the value of `major`. Subsequent reads from it will return its default value. | ||
mutating func clearMajor() {self._major = nil} | ||
|
||
var minor: Int32 { | ||
get {return _minor ?? 0} | ||
set {_minor = newValue} | ||
} | ||
/// Returns true if `minor` has been explicitly set. | ||
var hasMinor: Bool {return self._minor != nil} | ||
/// Clears the value of `minor`. Subsequent reads from it will return its default value. | ||
mutating func clearMinor() {self._minor = nil} | ||
|
||
var patch: Int32 { | ||
get {return _patch ?? 0} | ||
set {_patch = newValue} | ||
} | ||
/// Returns true if `patch` has been explicitly set. | ||
var hasPatch: Bool {return self._patch != nil} | ||
/// Clears the value of `patch`. Subsequent reads from it will return its default value. | ||
mutating func clearPatch() {self._patch = nil} | ||
|
||
var suffix: String { | ||
get {return _suffix ?? String()} | ||
set {_suffix = newValue} | ||
} | ||
/// Returns true if `suffix` has been explicitly set. | ||
var hasSuffix: Bool {return self._suffix != nil} | ||
/// Clears the value of `suffix`. Subsequent reads from it will return its default value. | ||
mutating func clearSuffix() {self._suffix = nil} | ||
|
||
var unknownFields = SwiftProtobuf.UnknownStorage() | ||
|
||
init() {} | ||
|
||
fileprivate var _major: Int32? = nil | ||
fileprivate var _minor: Int32? = nil | ||
fileprivate var _patch: Int32? = nil | ||
fileprivate var _suffix: String? = nil | ||
} | ||
|
||
// MARK: - Code below here is support for the SwiftProtobuf runtime. | ||
|
||
fileprivate let _protobuf_package = "swift_descriptor_test.import" | ||
|
||
extension SwiftDescriptorTest_Import_Version: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { | ||
static let protoMessageName: String = _protobuf_package + ".Version" | ||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ | ||
1: .same(proto: "major"), | ||
2: .same(proto: "minor"), | ||
3: .same(proto: "patch"), | ||
4: .same(proto: "suffix"), | ||
] | ||
|
||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws { | ||
while let fieldNumber = try decoder.nextFieldNumber() { | ||
// The use of inline closures is to circumvent an issue where the compiler | ||
// allocates stack space for every case branch when no optimizations are | ||
// enabled. https://github.com/apple/swift-protobuf/issues/1034 | ||
switch fieldNumber { | ||
case 1: try { try decoder.decodeSingularInt32Field(value: &self._major) }() | ||
case 2: try { try decoder.decodeSingularInt32Field(value: &self._minor) }() | ||
case 3: try { try decoder.decodeSingularInt32Field(value: &self._patch) }() | ||
case 4: try { try decoder.decodeSingularStringField(value: &self._suffix) }() | ||
default: break | ||
} | ||
} | ||
} | ||
|
||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws { | ||
// The use of inline closures is to circumvent an issue where the compiler | ||
// allocates stack space for every if/case branch local when no optimizations | ||
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and | ||
// https://github.com/apple/swift-protobuf/issues/1182 | ||
try { if let v = self._major { | ||
try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) | ||
} }() | ||
try { if let v = self._minor { | ||
try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) | ||
} }() | ||
try { if let v = self._patch { | ||
try visitor.visitSingularInt32Field(value: v, fieldNumber: 3) | ||
} }() | ||
try { if let v = self._suffix { | ||
try visitor.visitSingularStringField(value: v, fieldNumber: 4) | ||
} }() | ||
try unknownFields.traverse(visitor: &visitor) | ||
} | ||
|
||
static func ==(lhs: SwiftDescriptorTest_Import_Version, rhs: SwiftDescriptorTest_Import_Version) -> Bool { | ||
if lhs._major != rhs._major {return false} | ||
if lhs._minor != rhs._minor {return false} | ||
if lhs._patch != rhs._patch {return false} | ||
if lhs._suffix != rhs._suffix {return false} | ||
if lhs.unknownFields != rhs.unknownFields {return false} | ||
return true | ||
} | ||
} |
Oops, something went wrong.