Until CLIon supports newer Swift, and Swift Package Manager versions, and SPM fixes https://bugs.swift.org/browse/SR-12912 I opt in to doing this hackery for test resources.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
This commit is contained in:
parent
2cd55ef5ab
commit
d662ad3d22
|
@ -6,17 +6,11 @@ import PackageDescription
|
|||
let package = Package(
|
||||
name: "GeoIP2",
|
||||
products: [
|
||||
.library(
|
||||
name: "GeoIP2",
|
||||
targets: ["Api"]
|
||||
),
|
||||
.library(
|
||||
name: "DBReader",
|
||||
targets: ["DBReader"]
|
||||
),
|
||||
.library(name: "GeoIP2", targets: ["Api"])
|
||||
],
|
||||
dependencies: [],
|
||||
targets: [
|
||||
// MARK : Sources
|
||||
.target(name: "IndexReader", dependencies: ["Decoder", "MetadataReader"]),
|
||||
.target(name: "DataSection", dependencies: ["Decoder", "MetadataReader"]),
|
||||
.target(name: "MetadataReader", dependencies: ["Decoder"]),
|
||||
|
@ -24,35 +18,45 @@ let package = Package(
|
|||
.target(name: "DBReader", dependencies: ["IndexReader", "DataSection", "MetadataReader", "Decoder"]),
|
||||
.target(name: "Api", dependencies: ["DBReader", "Decoder", "MetadataReader", "IndexReader"]),
|
||||
|
||||
// MARK : Temporary hackery until CLion supports new Swift Package Manager with its Resources handling.
|
||||
.target(name: "TestResources", dependencies: [], path: "Tests/TestResources"),
|
||||
// MARK : "unit" tests. They will be actual unit tests one day.
|
||||
.testTarget(
|
||||
name: "IndexReaderTests",
|
||||
dependencies: ["IndexReader", "MetadataReader"],
|
||||
name: "IndexReaderTests",
|
||||
dependencies: ["TestResources", "IndexReader", "MetadataReader"],
|
||||
path: "Tests/Unit/IndexReaderTests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "DataSectionTests",
|
||||
dependencies: ["DataSection", "MetadataReader"],
|
||||
name: "DataSectionTests",
|
||||
dependencies: ["TestResources", "DataSection", "MetadataReader"],
|
||||
path: "Tests/Unit/DataSectionTests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "MetadataReaderTests",
|
||||
dependencies: ["MetadataReader", "Decoder"],
|
||||
name: "MetadataReaderTests",
|
||||
dependencies: ["TestResources", "MetadataReader", "Decoder"],
|
||||
path: "Tests/Unit/MetadataReaderTests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "DecoderTests",
|
||||
dependencies: ["Decoder"],
|
||||
name: "DecoderTests",
|
||||
dependencies: ["TestResources", "Decoder"],
|
||||
path: "Tests/Unit/DecoderTests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "DBReaderTests",
|
||||
dependencies: ["DBReader"],
|
||||
name: "DBReaderTests",
|
||||
dependencies: ["TestResources", "DBReader"],
|
||||
path: "Tests/Unit/DBReaderTests"
|
||||
),
|
||||
.testTarget(
|
||||
name: "ApiTests",
|
||||
dependencies: ["Api", "Decoder", "IndexReader","DBReader", "MetadataReader"],
|
||||
name: "ApiTests",
|
||||
dependencies: ["TestResources", "Api", "Decoder", "IndexReader", "DBReader", "MetadataReader"],
|
||||
path: "Tests/Unit/ApiTests"
|
||||
),
|
||||
|
||||
// MARK : System tests
|
||||
.testTarget(
|
||||
name: "GeoIP2_FileBased",
|
||||
dependencies: ["TestResources", "Api"],
|
||||
path: "Tests/System/FileBased"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
|
||||
class Wut: XCTestCase {
|
||||
|
||||
func testWut() {
|
||||
print(bundle.path(
|
||||
forResource: "GeoLite2-ASN_20200526/GeoLite2-ASN",
|
||||
ofType: "mmdb"
|
||||
))
|
||||
// print(Bundle.main.bundlePath)
|
||||
// print(Bundle.main.resourcePath)
|
||||
// print(Bundle.main.privateFrameworksPath)
|
||||
// print(Bundle.main.builtInPlugInsPath)
|
||||
// print(Bundle.main.executablePath)
|
||||
// print(Bundle.main.sharedFrameworksPath)
|
||||
// print(Bundle.main.sharedSupportPath)
|
||||
// XCTAssertTrue(false)
|
||||
// let bundle = Bundle(for: Wut.self)
|
||||
// bundle.path(forResource: <#T##String?##Swift.String?#>, ofType: <#T##String?##Swift.String?#>)
|
||||
// print(bundle)
|
||||
}
|
||||
|
||||
}
|
Before Width: | Height: | Size: 60 MiB After Width: | Height: | Size: 60 MiB |
|
@ -1,8 +1,7 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
extension XCTestCase {
|
||||
|
||||
public extension XCTestCase {
|
||||
static var bundle: Bundle {
|
||||
get {
|
||||
guard let currentFileUrl = URL(string: #file) else { return Bundle.main }
|
||||
|
@ -14,5 +13,4 @@ extension XCTestCase {
|
|||
}
|
||||
|
||||
var bundle: Bundle { get { return XCTestCase.bundle } }
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import class Api.ReaderFactory
|
||||
@testable import struct MetadataReader.Metadata
|
||||
import enum Api.DatabaseType
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import struct MetadataReader.Metadata
|
||||
@testable import class Api.Reader
|
||||
import enum Decoder.Payload
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
import TestResources
|
||||
extension XCTestCase {
|
||||
|
||||
static var bundle: Bundle {
|
||||
get {
|
||||
guard let currentFileUrl = URL(string: #file) else { return Bundle.main }
|
||||
guard let testBundle = Bundle(path: currentFileUrl.deletingLastPathComponent().path) else {
|
||||
return Bundle.main
|
||||
}
|
||||
return testBundle
|
||||
}
|
||||
}
|
||||
|
||||
var bundle: Bundle { get { return XCTestCase.bundle } }
|
||||
|
||||
private static var countryFilePath: String {
|
||||
get {
|
||||
guard let countryFilePath = bundle.path(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import XCTest
|
||||
|
||||
import TestResources
|
||||
#if !canImport(ObjectiveC)
|
||||
public func allTests() -> [XCTestCaseEntry] {
|
||||
return [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import DBReader
|
||||
import enum Decoder.Payload
|
||||
import enum IndexReader.IpAddress
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Database and Contents Copyright (c) 2020 MaxMind, Inc.
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula.
|
||||
|
||||
This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/.
|
|
@ -1,20 +0,0 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
extension XCTestCase {
|
||||
|
||||
var bundle: Bundle {
|
||||
get {
|
||||
guard let currentFileUrl = URL(string: #file) else {
|
||||
return Bundle.main
|
||||
}
|
||||
|
||||
guard let testBundle = Bundle(path: currentFileUrl.deletingLastPathComponent().path) else {
|
||||
return Bundle.main
|
||||
}
|
||||
|
||||
return testBundle
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import XCTest
|
||||
|
||||
import TestResources
|
||||
#if !canImport(ObjectiveC)
|
||||
public func allTests() -> [XCTestCaseEntry] {
|
||||
return [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
import class MetadataReader.Reader
|
||||
import Decoder
|
||||
@testable import DataSection
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Database and Contents Copyright (c) 2020 MaxMind, Inc.
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula.
|
||||
|
||||
This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/.
|
|
@ -1,18 +0,0 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
extension XCTestCase {
|
||||
|
||||
static var bundle: Bundle {
|
||||
get {
|
||||
guard let currentFileUrl = URL(string: #file) else { return Bundle.main }
|
||||
guard let testBundle = Bundle(path: currentFileUrl.deletingLastPathComponent().path) else {
|
||||
return Bundle.main
|
||||
}
|
||||
return testBundle
|
||||
}
|
||||
}
|
||||
|
||||
var bundle: Bundle { get { return XCTestCase.bundle } }
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class ControlByteInterpreterTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class DataTypeTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionResolveDefinitionSizeTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionResolvePayloadSizeTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionResolveTypeTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class ControlByteTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class DataTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class DecoderTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class NumericTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretArrayTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretDataCacheContainerTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretDoubleTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretFloatTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretInt32Test: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretMapTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretPointerTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretUInt16Test: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretUInt32Test: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretUInt64Test: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class FunctionInterpretUtf8StringTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class PayloadInterpreterTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class PayloadTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import Decoder
|
||||
|
||||
class StringTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
import class MetadataReader.Reader
|
||||
@testable import IndexReader
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import IndexReader
|
||||
|
||||
class IpAddressTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import IndexReader
|
||||
|
||||
class LookupDirectionTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import IndexReader
|
||||
|
||||
class NodeTest: XCTestCase {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Database and Contents Copyright (c) 2020 MaxMind, Inc.
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula.
|
||||
|
||||
This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/.
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import MetadataReader
|
||||
|
||||
class FunctionDecodeTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import MetadataReader
|
||||
|
||||
class MarkerLookupTest: XCTestCase {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
import TestResources
|
||||
@testable import class MetadataReader.Reader
|
||||
@testable import struct MetadataReader.Metadata
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Database and Contents Copyright (c) 2020 MaxMind, Inc.
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula.
|
||||
|
||||
This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/.
|
|
@ -1,18 +0,0 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
extension XCTestCase {
|
||||
|
||||
static var bundle: Bundle {
|
||||
get {
|
||||
guard let currentFileUrl = URL(string: #file) else { return Bundle.main }
|
||||
guard let testBundle = Bundle(path: currentFileUrl.deletingLastPathComponent().path) else {
|
||||
return Bundle.main
|
||||
}
|
||||
return testBundle
|
||||
}
|
||||
}
|
||||
|
||||
var bundle: Bundle { get { return XCTestCase.bundle } }
|
||||
|
||||
}
|
Loading…
Reference in New Issue