GithubHelp home page GithubHelp logo

jpsim / yams Goto Github PK

View Code? Open in Web Editor NEW
1.1K 21.0 127.0 20.1 MB

A Sweet and Swifty YAML parser.

Home Page: https://jpsim.com/Yams

License: MIT License

Swift 45.41% C 52.84% Ruby 0.14% Objective-C 0.07% CMake 1.14% Starlark 0.40%
swift libyaml yaml ios macos linux

yams's Introduction

Yams

Yams

A sweet and swifty YAML parser built on LibYAML.

SwiftPM xcodebuild pod lib lint Nightly codecov

Installation

Building Yams requires Xcode 12.5+ or a Swift 5.4+ toolchain with the Swift Package Manager or CMake and Ninja.

CMake

CMake 3.17.2 or newer is required, along with Ninja 1.9.0 or newer.

When building for non-Apple platforms:

cmake -B /path/to/build -G Ninja -S /path/to/yams -DCMAKE_BUILD_TYPE=Release -DFoundation_DIR=/path/to/foundation/build/cmake/modules
cmake --build /path/to/build

To build for Apple platforms (macOS, iOS, tvOS, watchOS), there is no need to separately build Foundation because it is included as part of the SDK:

cmake -B /path/to/build -G Ninja -S /path/to/yams -DCMAKE_BUILD_TYPE=Release
cmake --build /path/to/build

Swift Package Manager

Add .package(url: "https://github.com/jpsim/Yams.git", from: "5.1.2") to your Package.swift file's dependencies.

CocoaPods

Add pod 'Yams' to your Podfile.

Carthage

Add github "jpsim/Yams" to your Cartfile.

Bazel

In your WORKSPACE file

YAMS_GIT_SHA = "SOME_SHA"
http_archive(
    name = "com_github_jpsim_yams",
    urls = [
        "https://github.com/jpsim/Yams/archive/%s.zip" % YAMS_GIT_SHA,
    ],
    strip_prefix = "Yams-%s" % YAMS_GIT_SHA,
)

Usage

Yams has three groups of conversion APIs: one for use with Codable types, another for Swift Standard Library types, and a third one for a Yams-native representation.

Codable types

  • Codable is an encoding & decoding strategy introduced in Swift 4 enabling easy conversion between YAML and other Encoders like JSONEncoder and PropertyListEncoder.
  • Lowest computational overhead, equivalent to Yams.Node.
  • Encoding: YAMLEncoder.encode(_:) Produces a YAML String from an instance of type conforming to Encodable.
  • Decoding: YAMLDecoder.decode(_:from:) Decodes an instance of type conforming to Decodable from YAML String or Data.
import Foundation
import Yams

struct S: Codable {
    var p: String
}

let s = S(p: "test")
let encoder = YAMLEncoder()
let encodedYAML = try encoder.encode(s)
encodedYAML == """
p: test

"""
let decoder = YAMLDecoder()
let decoded = try decoder.decode(S.self, from: encodedYAML)
s.p == decoded.p

Swift Standard Library types

  • The type of Swift Standard Library is inferred from the contents of the internal Yams.Node representation by matching regular expressions.
  • This method has the largest computational overhead When decoding YAML, because the type inference of all objects is done up-front.
  • It may be easier to use in such a way as to handle objects created from JSONSerialization or if the input is already standard library types (Any, Dictionary, Array, etc.).
  • Encoding: Yams.dump(object:) Produces a YAML String from an instance of Swift Standard Library types.
  • Decoding: Yams.load(yaml:) Produces an instance of Swift Standard Library types as Any from YAML String.
// [String: Any]
let dictionary: [String: Any] = ["key": "value"]
let mapYAML: String = try Yams.dump(object: dictionary)
mapYAML == """
key: value

"""
let loadedDictionary = try Yams.load(yaml: mapYAML) as? [String: Any]

// [Any]
let array: [Int] = [1, 2, 3]
let sequenceYAML: String = try Yams.dump(object: array)
sequenceYAML == """
- 1
- 2
- 3

"""
let loadedArray: [Int]? = try Yams.load(yaml: sequenceYAML) as? [Int]

// Any
let string = "string"
let scalarYAML: String = try Yams.dump(object: string)
scalarYAML == """
string

"""
let loadedString: String? = try Yams.load(yaml: scalarYAML) as? String

Yams.Node

  • Yams' native model representing Nodes of YAML which provides all functions such as detection and customization of the YAML format.
  • Depending on how it is used, computational overhead can be minimized.
  • Encoding: Yams.serialize(node:) Produces a YAML String from an instance of Node.
  • Decoding Yams.compose(yaml:) Produces an instance of Node from YAML String.
var map: Yams.Node = [
    "array": [
        1, 2, 3
    ]
]
map.mapping?.style = .flow
map["array"]?.sequence?.style = .flow
let yaml = try Yams.serialize(node: map)
yaml == """
{array: [1, 2, 3]}

"""
let node = try Yams.compose(yaml: yaml)
map == node

Integrating with Combine

When Apple's Combine framework is available, YAMLDecoder conforms to the TopLevelDecoder protocol, which allows it to be used with the decode(type:decoder:) operator:

import Combine
import Foundation
import Yams

func fetchBook(from url: URL) -> AnyPublisher<Book, Error> {
    URLSession.shared.dataTaskPublisher(for: url)
        .map(\.data)
        .decode(type: Book.self, decoder: YAMLDecoder())
        .eraseToAnyPublisher()
}

License

Both Yams and libYAML are MIT licensed.

yams's People

Contributors

1024jp avatar acecilia avatar azure-pipelines[bot] avatar brennanmke avatar brentleyjones avatar compnerd avatar czechboy0 avatar dependabot[bot] avatar finestructure avatar garymm avatar hartbit avatar hemet avatar jpsim avatar kateinoigakukun avatar keith avatar koenpunt avatar liamnichols avatar lukas-stuehrk avatar mattpolzin avatar mattt avatar maxdesiatov avatar norio-nomura avatar norio-nomura-test-forked-repository avatar rafiki270 avatar rlovelett avatar rnapier avatar tatewake avatar tejassharma96 avatar tinder-maxwellelliott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yams's Issues

Support deserializing, editing, and serializing with preserving Anchors(`&`) and Aliases(`*`)

On current implementation, information about Anchors(&) and Aliases(*) are lost while compose().
e.g.:

import Foundation
import Yams

let node = try Yams.compose(yaml: """
aliases:
  - &steps-for-linux
    - checkout
    - run: swift test
version: 2
jobs:
  linux_swift_4.0.3:
    docker:
      - image: norionomura/swiftlint:swift-4.0.3
    steps: *steps-for-linux

  linux_swift_4.1.1:
    docker:
      - image: norionomura/swiftlint:swift-4.1.1
    steps: *steps-for-linux

""")

let string = try Yams.serialize(node: node!)
print(string)

output:

aliases:
- - checkout
  - run: swift test
version: 2
jobs:
  linux_swift_4.0.3:
    docker:
    - image: norionomura/swiftlint:swift-4.0.3
    steps:
    - checkout
    - run: swift test
  linux_swift_4.1.1:
    docker:
    - image: norionomura/swiftlint:swift-4.1.1
    steps:
    - checkout
    - run: swift test

To preserve Anchors and Aliases, it will need to introducing Node.alias(String).

Unicode chars

It doesn't work with emojis and Japanese characters.

Parse quoted values as strings

Is it possible to configure Yams to parse a quoted value (single or double quotes) as a string, instead of trying to convert to an assumed Swift type?

version: "10.10" // want it to parse to "10.10" String instead of 10.1 Float

I know it's possible to use an explicit type tag as a workaround, but it would be nice to be able to just quote a value which I thought is the standard way of specifying strings in yaml.

version: !!str '10.10' // correctly parses as "10.10"

This would fix yonaskolb/XcodeGen#268

null/~/NULL/Null parsed as strings, not nil

I'm probably just holding it wrong but when I try to decode yml values with nil values - which I believe are represented as null | ~ | NULL | Null in yml - I get the corresponding Strings back and not nil:

    func test_null_yml() throws {
        let s = """
              n1: ~
              n2: null
              n3: NULL
              n4: Null
              n5:
            """
        struct Test: Decodable {
            let n1: String?
            let n2: String?
            let n3: String?
            let n4: String?
            let n5: String?
        }
        let t = try YAMLDecoder().decode(Test.self, from: s)
        XCTAssertNil(t.n1)  // XCTAssertNil failed: "~"
        XCTAssertNil(t.n2)  // XCTAssertNil failed: "null"
        XCTAssertNil(t.n3)  // XCTAssertNil failed: "NULL"
        XCTAssertNil(t.n4)  // XCTAssertNil failed: "Null"
        XCTAssertNil(t.n5)  // XCTAssertNil failed: ""
    }

This is with swift-4.2.1 and Yams

          "revision": "26ab35f50ea891e8edefcc9d975db2f6b67e1d68",
          "version": "1.0.1"

I see references to all these null tags in

XCTAssertEqual(resolver.resolveTag(of: "null"), .str)
and so I'm wondering: is there something wrong with my test setup above? Or is this perhaps a πŸ›?

[CI] Move to CircleCI

Since it is longer to wait for the time to start a new job than the build time, is it better to reduce the number of jobs?

Invalid Code Signature Identifier during upload to App Store Connect

Screen Shot 2019-10-22 at 5 34 16 PM

Ran into this issue when uploading a Mac app built with Xcode 11 to App Store Connect. After some digging I discovered that because the Yams Product Bundle Identifier was set to "Yams", Xcode was appending a random string to its code signature identifier during code signing, so it would longer match the original bundle identifier and would fail validation during upload.

The problem is solved by changing the Yams Product Bundle Identifier from "Yams" to something containing a period, e.g: "com.jpsim.Yams". I would suggest updating the Yams project file with this change to prevent anyone else from experiencing the same problem.

(Looks like this behavior is new as of Xcode 11, another user reported a similar problem on Stackoverflow: https://stackoverflow.com/a/58293021)

`subscript(string:)` fails to lookup value if `Node` has non default `Resolver`

Since tag of Node is resolved by Resolver, If Resolver is different, tag will also be different.

try Yams.compose(yaml: "200")!.tag                // tag:yaml.org,2002:int
try Yams.compose(yaml: "200", .basic)!.tag        // tag:yaml.org,2002:str

Yams uses not only values but also tags for checking equality of Node.

let node1 = try Yams.compose(yaml: "200")
let node2 = try Yams.compose(yaml: "200", .basic)
node1 == node2                                    // false

Since current implementation of subscript(string:) creates Node from String with default Resolver, if target Node has different Resolver, subscript will fail to lookup value.

Node("200").tag                                  // tag:yaml.org,2002:int
let yaml = "200: value"
let node3 = try Yams.compose(yaml: yaml)         // "200" is resolved to tag:yaml.org,2002:int
let key1 = Node("200", Tag(.int))
let key2 = Node("200", Tag(.str))
node3?[key1]?.string                             // "value"
node3?[key2]?.string                             // nil
node3?["200"]?.string                            // "value"
let node4 = try Yams.compose(yaml: yaml, .basic) // "200" is resolved to tag:yaml.org,2002:str
node4?[key1]?.string                             // nil
node4?[key2]?.string                             // "value"
node4?["200"]?.string                            // nil

This behavior causes the issue #99

Some tests fail with Swift 5.0 on macOS

$ xcrun --toolchain org.swift.5020181225a swift test
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Sources/Yams/Parser.swift:139:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
        data.withUnsafeBytes { bytes in
             ^
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:139:28: warning: 'init(bytes:)' is deprecated: use `init(_:)` instead
        _testRoundTrip(of: Data(bytes: [0xDE, 0xAD, 0xBE, 0xEF]), expectedYAML: "3q2+7w==\n")
                           ^
[3/3] Linking ./.build/x86_64-apple-macosx/debug/YamsPackageTests.xctest/Contents/MacOS/YamsPackageTests
Test Suite 'All tests' started at 2018-12-26 19:32:12.867
Test Suite 'YamsPackageTests.xctest' started at 2018-12-26 19:32:12.867
Test Suite 'ConstructorTests' started at 2018-12-26 19:32:12.867
Test Case '-[YamsTests.ConstructorTests testBinary]' started.
Test Case '-[YamsTests.ConstructorTests testBinary]' passed (0.240 seconds).
Test Case '-[YamsTests.ConstructorTests testBool]' started.
Test Case '-[YamsTests.ConstructorTests testBool]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testFloat]' started.
Test Case '-[YamsTests.ConstructorTests testFloat]' passed (0.002 seconds).
Test Case '-[YamsTests.ConstructorTests testInt]' started.
Test Case '-[YamsTests.ConstructorTests testInt]' passed (0.004 seconds).
Test Case '-[YamsTests.ConstructorTests testMap]' started.
Test Case '-[YamsTests.ConstructorTests testMap]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testMerge]' started.
Test Case '-[YamsTests.ConstructorTests testMerge]' passed (0.003 seconds).
Test Case '-[YamsTests.ConstructorTests testNull]' started.
Test Case '-[YamsTests.ConstructorTests testNull]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testOmap]' started.
Test Case '-[YamsTests.ConstructorTests testOmap]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testPairs]' started.
Test Case '-[YamsTests.ConstructorTests testPairs]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testQuotationMark]' started.
Test Case '-[YamsTests.ConstructorTests testQuotationMark]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testSeq]' started.
Test Case '-[YamsTests.ConstructorTests testSeq]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testSet]' started.
Test Case '-[YamsTests.ConstructorTests testSet]' passed (0.002 seconds).
Test Case '-[YamsTests.ConstructorTests testTimestamp]' started.
Test Case '-[YamsTests.ConstructorTests testTimestamp]' passed (0.007 seconds).
Test Case '-[YamsTests.ConstructorTests testTimestampWithNanosecond]' started.
Test Case '-[YamsTests.ConstructorTests testTimestampWithNanosecond]' passed (0.001 seconds).
Test Case '-[YamsTests.ConstructorTests testValue]' started.
Test Case '-[YamsTests.ConstructorTests testValue]' passed (0.003 seconds).
Test Suite 'ConstructorTests' passed at 2018-12-26 19:32:13.136.
	 Executed 15 tests, with 0 failures (0 unexpected) in 0.267 (0.269) seconds
Test Suite 'EmitterTests' started at 2018-12-26 19:32:13.136
Test Case '-[YamsTests.EmitterTests testAllowUnicode]' started.
Test Case '-[YamsTests.EmitterTests testAllowUnicode]' passed (0.001 seconds).
Test Case '-[YamsTests.EmitterTests testLineBreaks]' started.
Test Case '-[YamsTests.EmitterTests testLineBreaks]' passed (0.000 seconds).
Test Case '-[YamsTests.EmitterTests testMapping]' started.
Test Case '-[YamsTests.EmitterTests testMapping]' passed (0.001 seconds).
Test Case '-[YamsTests.EmitterTests testScalar]' started.
Test Case '-[YamsTests.EmitterTests testScalar]' passed (0.000 seconds).
Test Case '-[YamsTests.EmitterTests testSequence]' started.
Test Case '-[YamsTests.EmitterTests testSequence]' passed (0.000 seconds).
Test Case '-[YamsTests.EmitterTests testSortKeys]' started.
Test Case '-[YamsTests.EmitterTests testSortKeys]' passed (0.001 seconds).
Test Suite 'EmitterTests' passed at 2018-12-26 19:32:13.141.
	 Executed 6 tests, with 0 failures (0 unexpected) in 0.005 (0.005) seconds
Test Suite 'EncoderTests' started at 2018-12-26 19:32:13.141
Test Case '-[YamsTests.EncoderTests testDecodingConcreteTypeParameter]' started.
Test Case '-[YamsTests.EncoderTests testDecodingConcreteTypeParameter]' passed (0.004 seconds).
Test Case '-[YamsTests.EncoderTests testDictionary]' started.
Test Case '-[YamsTests.EncoderTests testDictionary]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingBase64Data]' started.
Test Case '-[YamsTests.EncoderTests testEncodingBase64Data]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingClassWhichSharesEncoderWithSuper]' started.
Test Case '-[YamsTests.EncoderTests testEncodingClassWhichSharesEncoderWithSuper]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingDate]' started.
Test Case '-[YamsTests.EncoderTests testEncodingDate]' passed (0.002 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingDateMillisecondsSince1970]' started.
Test Case '-[YamsTests.EncoderTests testEncodingDateMillisecondsSince1970]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelDeepStructuredType]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelDeepStructuredType]' passed (0.003 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelEmptyClass]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelEmptyClass]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelEmptyStruct]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelEmptyStruct]' passed (0.000 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelNullableType]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:115: error: -[YamsTests.EncoderTests testEncodingTopLevelNullableType] : failed - Failed to decode EnhancedBool from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
true
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:116: error: -[YamsTests.EncoderTests testEncodingTopLevelNullableType] : failed - Failed to decode EnhancedBool from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
false
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:117: error: -[YamsTests.EncoderTests testEncodingTopLevelNullableType] : failed - Failed to decode EnhancedBool from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
null
   ^)))
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelNullableType]' failed (0.009 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueClass]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:39: error: -[YamsTests.EncoderTests testEncodingTopLevelSingleValueClass] : failed - Failed to decode Counter from YAML by error: typeMismatch(Swift.Int, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Int but found Scalar instead.", underlyingError: nil))
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueClass]' failed (0.004 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueEnum]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:30: error: -[YamsTests.EncoderTests testEncodingTopLevelSingleValueEnum] : failed - Failed to decode Switch from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
false
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:31: error: -[YamsTests.EncoderTests testEncodingTopLevelSingleValueEnum] : failed - Failed to decode Switch from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
true
   ^)))
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueEnum]' failed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueStruct]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelSingleValueStruct]' passed (0.003 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredClass]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredClass]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredSingleClass]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredSingleClass]' passed (0.003 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredSingleStruct]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredSingleStruct]' passed (0.002 seconds).
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredStruct]' started.
Test Case '-[YamsTests.EncoderTests testEncodingTopLevelStructuredStruct]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testInterceptDecimal]' started.
Test Case '-[YamsTests.EncoderTests testInterceptDecimal]' passed (0.002 seconds).
Test Case '-[YamsTests.EncoderTests testInterceptURL]' started.
Test Case '-[YamsTests.EncoderTests testInterceptURL]' passed (0.001 seconds).
Test Case '-[YamsTests.EncoderTests testNestedContainerCodingPaths]' started.
Test Case '-[YamsTests.EncoderTests testNestedContainerCodingPaths]' passed (0.002 seconds).
Test Case '-[YamsTests.EncoderTests testNodeTypeMismatch]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:289: error: -[YamsTests.EncoderTests testNodeTypeMismatch] : failed - unexpected error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
hello
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:289: error: -[YamsTests.EncoderTests testNodeTypeMismatch] : failed - unexpected error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
- hello
   ^)))
Test Case '-[YamsTests.EncoderTests testNodeTypeMismatch]' failed (0.003 seconds).
Test Case '-[YamsTests.EncoderTests testSuperEncoderCodingPaths]' started.
Test Case '-[YamsTests.EncoderTests testSuperEncoderCodingPaths]' passed (0.002 seconds).
Test Case '-[YamsTests.EncoderTests testValuesInKeyedContainer]' started.
Test Case '-[YamsTests.EncoderTests testValuesInKeyedContainer]' passed (0.006 seconds).
Test Case '-[YamsTests.EncoderTests testValuesInSingleValueContainer]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:180: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Bool from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
true
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:181: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Bool from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
false
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:184: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Int8 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
-128
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:184: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Int8 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
127
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:185: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Int16 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
-32768
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:185: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Int16 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
32767
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:188: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt from YAML by error: valueNotFound(Swift.UInt, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected UInt value but found Scalar(string: \"읰\", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1)) instead.", underlyingError: nil))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:189: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt8 from YAML by error: valueNotFound(Swift.UInt8, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected UInt8 value but found Scalar(string: \"읰\", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1)) instead.", underlyingError: nil))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:189: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt8 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
255
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:190: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt16 from YAML by error: valueNotFound(Swift.UInt16, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected UInt16 value but found Scalar(string: \"읰\", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1)) instead.", underlyingError: nil))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:190: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt16 from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
65535
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:191: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt32 from YAML by error: valueNotFound(Swift.UInt32, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected UInt32 value but found Scalar(string: \"읰\", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1)) instead.", underlyingError: nil))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:192: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode UInt64 from YAML by error: valueNotFound(Swift.UInt64, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected UInt64 value but found Scalar(string: \"읰\", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1)) instead.", underlyingError: nil))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:194: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Float from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
.inf
   ^)))
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/EncoderTests.swift:195: error: -[YamsTests.EncoderTests testValuesInSingleValueContainer] : failed - Failed to decode Double from YAML by error: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid YAML.", underlyingError: Optional(1:4: error: reader: control characters are not allowed:
.inf
   ^)))
Test Case '-[YamsTests.EncoderTests testValuesInSingleValueContainer]' failed (0.010 seconds).
Test Case '-[YamsTests.EncoderTests testValuesInUnkeyedContainer]' started.
Test Case '-[YamsTests.EncoderTests testValuesInUnkeyedContainer]' passed (0.001 seconds).
Test Suite 'EncoderTests' failed at 2018-12-26 19:32:13.209.
	 Executed 25 tests, with 23 failures (0 unexpected) in 0.066 (0.068) seconds
Test Suite 'MarkTests' started at 2018-12-26 19:32:13.209
Test Case '-[YamsTests.MarkTests testLocatableDeprecationMessageForSwiftLint]' started.
Test Case '-[YamsTests.MarkTests testLocatableDeprecationMessageForSwiftLint]' passed (0.001 seconds).
Test Suite 'MarkTests' passed at 2018-12-26 19:32:13.210.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'NodeTests' started at 2018-12-26 19:32:13.210
Test Case '-[YamsTests.NodeTests testArray]' started.
Test Case '-[YamsTests.NodeTests testArray]' passed (0.001 seconds).
Test Case '-[YamsTests.NodeTests testExpressibleByArrayLiteral]' started.
Test Case '-[YamsTests.NodeTests testExpressibleByArrayLiteral]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testExpressibleByDictionaryLiteral]' started.
Test Case '-[YamsTests.NodeTests testExpressibleByDictionaryLiteral]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testExpressibleByFloatLiteral]' started.
Test Case '-[YamsTests.NodeTests testExpressibleByFloatLiteral]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testExpressibleByIntegerLiteral]' started.
Test Case '-[YamsTests.NodeTests testExpressibleByIntegerLiteral]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testExpressibleByStringLiteral]' started.
Test Case '-[YamsTests.NodeTests testExpressibleByStringLiteral]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testMappingBehavesLikeADictionary]' started.
Test Case '-[YamsTests.NodeTests testMappingBehavesLikeADictionary]' passed (0.001 seconds).
Test Case '-[YamsTests.NodeTests testScalar]' started.
Test Case '-[YamsTests.NodeTests testScalar]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testSequenceBehavesLikeAnArray]' started.
Test Case '-[YamsTests.NodeTests testSequenceBehavesLikeAnArray]' passed (0.001 seconds).
Test Case '-[YamsTests.NodeTests testSubscriptMapping]' started.
Test Case '-[YamsTests.NodeTests testSubscriptMapping]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testSubscriptSequence]' started.
Test Case '-[YamsTests.NodeTests testSubscriptSequence]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testSubscriptWithNonDefaultResolver]' started.
Test Case '-[YamsTests.NodeTests testSubscriptWithNonDefaultResolver]' passed (0.000 seconds).
Test Case '-[YamsTests.NodeTests testTypedAccessorProperties]' started.
Test Case '-[YamsTests.NodeTests testTypedAccessorProperties]' passed (0.001 seconds).
Test Suite 'NodeTests' passed at 2018-12-26 19:32:13.217.
	 Executed 13 tests, with 0 failures (0 unexpected) in 0.006 (0.006) seconds
Test Suite 'PerformanceTests' started at 2018-12-26 19:32:13.217
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingCompose]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/PerformanceTests.swift:92: Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingCompose]' measured [Time, seconds] average: 0.012, relative standard deviation: 17.768%, values: [0.014658, 0.010010, 0.011343, 0.014352, 0.009674, 0.009873, 0.015215, 0.013424, 0.010828, 0.009920], performanceMetricID:com.apple.XCTPerformanceMetric_WallClockTime, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingCompose]' passed (0.406 seconds).
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingLoad]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/PerformanceTests.swift:66: Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingLoad]' measured [Time, seconds] average: 0.016, relative standard deviation: 7.909%, values: [0.019358, 0.015514, 0.015583, 0.014824, 0.015543, 0.015097, 0.015140, 0.016230, 0.015351, 0.015128], performanceMetricID:com.apple.XCTPerformanceMetric_WallClockTime, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingLoad]' passed (0.413 seconds).
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingSwiftDecodable]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/PerformanceTests.swift:118: Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingSwiftDecodable]' measured [Time, seconds] average: 0.013, relative standard deviation: 17.285%, values: [0.015417, 0.013634, 0.011615, 0.013201, 0.014060, 0.011517, 0.011462, 0.011756, 0.019267, 0.012169], performanceMetricID:com.apple.XCTPerformanceMetric_WallClockTime, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100
Test Case '-[YamsTests.PerformanceTests testSourceKittenIssue289UsingSwiftDecodable]' passed (0.388 seconds).
Test Suite 'PerformanceTests' passed at 2018-12-26 19:32:14.424.
	 Executed 3 tests, with 0 failures (0 unexpected) in 1.207 (1.208) seconds
Test Suite 'RepresenterTests' started at 2018-12-26 19:32:14.425
Test Case '-[YamsTests.RepresenterTests testArray]' started.
Test Case '-[YamsTests.RepresenterTests testArray]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testBool]' started.
Test Case '-[YamsTests.RepresenterTests testBool]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testData]' started.
Test Case '-[YamsTests.RepresenterTests testData]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testDate]' started.
Test Case '-[YamsTests.RepresenterTests testDate]' passed (0.001 seconds).
Test Case '-[YamsTests.RepresenterTests testDictionary]' started.
Test Case '-[YamsTests.RepresenterTests testDictionary]' passed (0.001 seconds).
Test Case '-[YamsTests.RepresenterTests testDouble]' started.
Test Case '-[YamsTests.RepresenterTests testDouble]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testFloat]' started.
Test Case '-[YamsTests.RepresenterTests testFloat]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testInteger]' started.
Test Case '-[YamsTests.RepresenterTests testInteger]' passed (0.001 seconds).
Test Case '-[YamsTests.RepresenterTests testOptional]' started.
Test Case '-[YamsTests.RepresenterTests testOptional]' passed (0.000 seconds).
Test Case '-[YamsTests.RepresenterTests testString]' started.
Test Case '-[YamsTests.RepresenterTests testString]' passed (0.000 seconds).
Test Suite 'RepresenterTests' passed at 2018-12-26 19:32:14.429.
	 Executed 10 tests, with 0 failures (0 unexpected) in 0.004 (0.004) seconds
Test Suite 'ResolverTests' started at 2018-12-26 19:32:14.429
Test Case '-[YamsTests.ResolverTests testBasic]' started.
Test Case '-[YamsTests.ResolverTests testBasic]' passed (0.000 seconds).
Test Case '-[YamsTests.ResolverTests testCustomize]' started.
<unknown>:0: error: -[YamsTests.ResolverTests testCustomize] : failed: caught error: The operation couldn’t be completed. (Yams.YamlError error 0.)
Test Case '-[YamsTests.ResolverTests testCustomize]' failed (0.006 seconds).
Test Case '-[YamsTests.ResolverTests testDefault]' started.
Test Case '-[YamsTests.ResolverTests testDefault]' passed (0.001 seconds).
Test Suite 'ResolverTests' failed at 2018-12-26 19:32:14.436.
	 Executed 3 tests, with 1 failure (1 unexpected) in 0.007 (0.007) seconds
Test Suite 'SpecTests' started at 2018-12-26 19:32:14.436
Test Case '-[YamsTests.SpecTests testEmptyString]' started.
Test Case '-[YamsTests.SpecTests testEmptyString]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testMultibyteCharacters]' started.
Test Case '-[YamsTests.SpecTests testMultibyteCharacters]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_10_NodeForSammySosaAppearsTwiceInThisDocument]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_10_NodeForSammySosaAppearsTwiceInThisDocument]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_11_MappingBetweenSequences]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_11_MappingBetweenSequences]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_12_CompactNestedMapping]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_12_CompactNestedMapping]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_13_Inliterals_NewlinesArePreserved]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_13_Inliterals_NewlinesArePreserved]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_14_InTheFoldedScalars_NewlinesBecomeSpaces]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_14_InTheFoldedScalars_NewlinesBecomeSpaces]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_15_InTheFoldedScalars_NewlinesBecomeSpaces]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_15_InTheFoldedScalars_NewlinesBecomeSpaces]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_16_IndentationDeterminesScope]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_16_IndentationDeterminesScope]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_17_QuotedScalars]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_17_QuotedScalars]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_18_MultiLineFlowScalars]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_18_MultiLineFlowScalars]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_19_Integers]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_19_Integers]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_1_SequenceOfScalars]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_1_SequenceOfScalars]' passed (0.000 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_20_FloatingPoint]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_20_FloatingPoint]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_23_VariousExplicitTags]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_23_VariousExplicitTags]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_27_Invoice]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_27_Invoice]' passed (0.006 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_28_LogFile]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_28_LogFile]' passed (0.007 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_2_MappingScalarsToScalars]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_2_MappingScalarsToScalars]' passed (0.002 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_3_MappingScalarsToSequences]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_3_MappingScalarsToSequences]' passed (0.002 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_4_SequenceOfMappings]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_4_SequenceOfMappings]' passed (0.002 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_5_SequenceOfSequences]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_5_SequenceOfSequences]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_6_MappingOfMappings]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_6_MappingOfMappings]' passed (0.002 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_7_TwoDocumentsInAStream]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_7_TwoDocumentsInAStream]' passed (0.001 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_8_PlayByPlayFeedFromAGame]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_8_PlayByPlayFeedFromAGame]' passed (0.002 seconds).
Test Case '-[YamsTests.SpecTests testSpecExample2_9_SingleDocumentWithTwoComments]' started.
Test Case '-[YamsTests.SpecTests testSpecExample2_9_SingleDocumentWithTwoComments]' passed (0.001 seconds).
Test Suite 'SpecTests' passed at 2018-12-26 19:32:14.472.
	 Executed 25 tests, with 0 failures (0 unexpected) in 0.034 (0.036) seconds
Test Suite 'StringTests' started at 2018-12-26 19:32:14.472
Test Case '-[YamsTests.StringTests testConfirmBehaviorOfStandardLibraryAPI]' started.
Test Case '-[YamsTests.StringTests testConfirmBehaviorOfStandardLibraryAPI]' passed (0.000 seconds).
Test Case '-[YamsTests.StringTests testSubstringAtLine]' started.
Test Case '-[YamsTests.StringTests testSubstringAtLine]' passed (0.000 seconds).
Test Case '-[YamsTests.StringTests testUTF16LineNumberColumnAndContentsAtOffset]' started.
Test Case '-[YamsTests.StringTests testUTF16LineNumberColumnAndContentsAtOffset]' passed (0.000 seconds).
Test Case '-[YamsTests.StringTests testUTF8LineNumberColumnAndContentsAtOffset]' started.
Test Case '-[YamsTests.StringTests testUTF8LineNumberColumnAndContentsAtOffset]' passed (0.000 seconds).
Test Suite 'StringTests' passed at 2018-12-26 19:32:14.473.
	 Executed 4 tests, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'YamlErrorTests' started at 2018-12-26 19:32:14.474
Test Case '-[YamsTests.YamlErrorTests testNextRootThrowsOnInvalidYaml]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/YamlErrorTests.swift:74: error: -[YamsTests.YamlErrorTests testNextRootThrowsOnInvalidYaml] : XCTAssertEqual failed: ("Optional(Yams.Node.scalar(Yams.Node.Scalar(string: "흀翾", tag: , style: Yams.Node.Scalar.Style.plain, mark: Optional(1:1))))") is not equal to ("Optional(Yams.Node.scalar(Yams.Node.Scalar(string: "", tag: tag:yaml.org,2002:str, style: Yams.Node.Scalar.Style.literal, mark: nil)))") - 
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/YamlErrorTests.swift:76: error: -[YamsTests.YamlErrorTests testNextRootThrowsOnInvalidYaml] : XCTAssertThrowsError failed: did not throw an error - 
Test Case '-[YamsTests.YamlErrorTests testNextRootThrowsOnInvalidYaml]' failed (0.001 seconds).
Test Case '-[YamsTests.YamlErrorTests testScannerErrorMayHaveNullContext]' started.
Test Case '-[YamsTests.YamlErrorTests testScannerErrorMayHaveNullContext]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testSingleRootThrowsOnInvalidYaml]' started.
/Users/norio/github/swift-dev/SourceKitten/Carthage/Checkouts/Yams/Tests/YamsTests/YamlErrorTests.swift:91: error: -[YamsTests.YamlErrorTests testSingleRootThrowsOnInvalidYaml] : XCTAssertThrowsError failed: did not throw an error - 
Test Case '-[YamsTests.YamlErrorTests testSingleRootThrowsOnInvalidYaml]' failed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testSingleRootThrowsOnMultipleDocuments]' started.
Test Case '-[YamsTests.YamlErrorTests testSingleRootThrowsOnMultipleDocuments]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testUndefinedAliasCausesError]' started.
Test Case '-[YamsTests.YamlErrorTests testUndefinedAliasCausesError]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testYamlErrorEmitter]' started.
Test Case '-[YamsTests.YamlErrorTests testYamlErrorEmitter]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testYamlErrorParser]' started.
Test Case '-[YamsTests.YamlErrorTests testYamlErrorParser]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testYamlErrorReader]' started.
Test Case '-[YamsTests.YamlErrorTests testYamlErrorReader]' passed (0.000 seconds).
Test Case '-[YamsTests.YamlErrorTests testYamlErrorScanner]' started.
Test Case '-[YamsTests.YamlErrorTests testYamlErrorScanner]' passed (0.000 seconds).
Test Suite 'YamlErrorTests' failed at 2018-12-26 19:32:14.478.
	 Executed 9 tests, with 3 failures (0 unexpected) in 0.004 (0.004) seconds
Test Suite 'YamsPackageTests.xctest' failed at 2018-12-26 19:32:14.478.
	 Executed 114 tests, with 27 failures (1 unexpected) in 1.600 (1.611) seconds
Test Suite 'All tests' failed at 2018-12-26 19:32:14.478.
	 Executed 114 tests, with 27 failures (1 unexpected) in 1.600 (1.611) seconds
xcrun --toolchain org.swift.5020181225a swift test  20.24s user 2.76s system 193% cpu 11.877 total

Update API documentation

  • Re-enable API document generation on Azure Pipelines
  • Keep documentation on each major versions (master, yams-1.0-branch, …)

Clarify version of YAML specification supported.

I think it would help the README if it added a couple sentences clarifying the degree of YAML spec compliance, if this is known.

I ask because I have what I believe is a valid YAML 1.0 document. It begins with the first line as follows: %YAML:1.0. I think this should be okay because section 3.2.3.3 in the YAML spec says the following:

A version 1.0 processor should accept documents with an explicit β€œ%YAML:1.0” directive, as well as documents lacking a β€œYAML” directive.

But Yams chokes on it. I don't know if I'm misunderstanding the situation, if this is a fault in the underlying libYAML parser, or if the YAML spec is, like the pirate's code, more what you'd call "guidelines" than actual rules.

(FWIW, At the moment I'm just stripping the first line and everything works after that.)

When built with Carthage, version is 0.0.0

I've been trying to use the Stylist framework which has a dependency on Yams. Stylist is expecting version 1.0.0 of Yams, but when the apps tries to start, it returns this message:

dyld: Library not loaded: @rpath/Yams.framework/Yams
Referenced from: /Users/derekclarkson/Library/Developer/CoreSimulator/Devices/5951E8ED-55B2-4E70-BDE3-0858F47C7C40/data/Containers/Bundle/Application/9FD14F8C-C4D8-4735-AAC0-46D5C61F74A4/Crux.app/Frameworks/Stylist.framework/Stylist
Reason: Incompatible library version: Stylist requires version 1.0.0 or later, but Yams provides version 0.0.0

I've no idea at this time why Yams is reporting 0.0.0 as a version.

lost quote when dump a double string

image

The origin string is VERSION: "1.0", so yams will parse the 1.0 to string value. It is right.
But when dump the object to string, it lost the quote: VERSION: 1.0, so the yams will make the 1.0 as a double value.

Is it a bug?

`YAMLEncoder` outputs a result that is delayed by 1 second when encoding `Date` with nanoseconds greater than 999499997

DateFormatter doesn't support time more precise than milliseconds, and smaller digits will be rounded to milliseconds.
Since DateComponents having a value of 999499997 or greater in nanosecond generates Date in which nanosecond is 999500036 or greater, DateFormatter rounds up and advances the result by 1 second.

POC:

import Foundation

let iso8601WithFractionalSecondFormatter: DateFormatter = {
    let formatter = DateFormatter()
    formatter.locale = Locale(identifier: "en_US_POSIX")
    formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSS'Z"
    formatter.timeZone = TimeZone(secondsFromGMT: 0)
    return formatter
}()

let gregorian = Calendar(identifier: .gregorian)
let utc = TimeZone(identifier: "UTC")!
let components = gregorian.dateComponents(in: utc, from: Date())

func check(from components: DateComponents, with nanosecond: Int) {
    print("--")
    print("Dircted nanosecond: \(nanosecond)")
    var components = components
    components.nanosecond = nanosecond
    let date = components.date!
    print("Actual nanosecond : \(gregorian.dateComponents(in: utc, from: date).nanosecond!)")
    print("Date: \(iso8601WithFractionalSecondFormatter.string(from: date))")
}

check(from: components, with: 999499976)
check(from: components, with: 999499977)

Result:

--
Dircted nanosecond: 999499976
Actual nanosecond : 999499917
Date: 2019-06-25T14:35:36.999Z
--
Dircted nanosecond: 999499977
Actual nanosecond : 999500036
Date: 2019-06-25T14:35:37.000Z

We should drop nanosecond from Date before passing to DateFormatter when using nanosecond precision.

New version

Hi. Any chance of getting a new tagged version, so that a build can be installed via SwiftPM that supports Swift 3.1 on Linux?

Linting fails with SwiftLint v. 0.17.0

SwiftLint v. 0.17.0 has a new rule identifier_name which fails in Yams/Tests/YamsTests/TestHelper.swift:46:2. Running the linter is a run script in the build phases and because of that it's not possible to build the project. Funnily enough this also breaks Carthage builds and therefore building SwiftLint itself, which has Yams as one of its dependencies (via SourceKitten) πŸ˜ƒ

Yams.serialize converts string in ' to number

Following on #116 when trying to serialise something likevalue: '10.0' the output will be value: 10.0.

Unfortunately doing value: !!str '10.0' still results in the output being number, tested with " and the same happens.

Example updating:

let updatedNode = try node.represented()
let serialized = try Yams.serialize(node: updatedNode)
try path.write(serialized)

Allow decode from data

I couldn't find a mention of the word data in Readme.md and just wondering if there's a significant reason that decodeFrom is only available with string not data?

project fails to build via xcodebuild when including Yams via SPM

I've created an empty project, and using the new Swift Package Manager features in Xcode 11, added Yams as a Package Dependency to a macOS app. Building in Xcode works fine, but building via xcodebuild fails with the error: <unknown>:0: error: module map file '/Users/robinsenior/src/personal/tests/YamsTest/build/GeneratedModuleMaps/macosx/CYaml.modulemap' not found

I've tried doing this same thing with other yaml parsing libraries with no problem. I suspect it's due to Yams' cyaml usage, but I don't know if it's a limitation of xcodebuild.

Empty string parsed as <null>

If you try to specify an empty string as a value it's parsed as <null> instead of an empty string

yaml file:

string1: "string"
string2: string
emptyString: ""
let string = getFile()
let yaml = try Yams.load(yaml: string)
let dictionary = yaml as! [String: Any]
print(dictionary["emptyString"]!) // prints "<null>" instead of ""

Yams does not throw for duplicate keys

I would expect the following yaml structure to be invalid because of duplicate key bar

foo:
  bar:
    text: "Hello"
  bar:
    text: "World"

This instead will process fine and one of the keys will win.

Feature request - Unknown fields

I have a YAML file that contains a field named: delete_rule. This field is optional.
I made a mistake and wrote deleteRule in the YAML file. Given that the field is optional this does not cause any alert or warning.

My feature request is to have either a callback or notification that would be called/send in case of unknown fields. This will allow me to issue a warning.

Are multiline values supported?

I wonder whether multiline values like

key: |
    value1
    value2

are supported by your library. I always get parse errors trying to read such YAML files.

Won't compile under Xcode 10.2

When using Carthage and Xcode 10.2 Yams fails to compile. I tried loading the project into Xcode and building and it threw errors on enums with associated values. Further digging led me to realm/SwiftLint#2231 which looks like it might be the problem.

Not sure how to fix this as yet.

Is it possible to use Dictionary as decoding type?

Hi, sorry for any inconveniences beforehand, and many thanks for Yams πŸ‘

I'm trying to decode the dictionary like so:

import Yams
let yaml = "'200': ok"
let decodedYaml = try YAMLDecoder().decode([String: String].self, from: yaml)

And getting crash:

Fatal error: Error raised at top level: Swift.DecodingError.keyNotFound(Swift._DictionaryCodingKey(stringValue: "200", intValue: Optional(200)), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key _DictionaryCodingKey(stringValue: "200", intValue: Optional(200)) ("200").", underlyingError: nil)): file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.74.1/src/swift/stdlib/public/core/ErrorType.swift, line 187

Am I doing it wrong, and how it should be then? Are there any chances this would be supported by Yams in future?

While if using JSONDecoder, this works fine and dictionary is decoded without issues:

let json = "{\"200\": \"OK\"}"
let decodedJson = try JSONDecoder().decode([String: String].self, from: json)

E.g. I have custom protocol that both JSONDecoder and YAMLDecoder are conforming but there is no magic, e.g. for json one:

extension JSONDecoder: StringDecoder {
    public func decode<T>(_ type: T.Type, from string: String) throws -> T where T : Decodable {
        guard let data = string.data(using: .utf8) else {
            throw DecodingError("Unable to extract data from string in utf8 encoding")
        }
        return try self.decode(T.self, from: data)
    }
}

P.S. Actually I just simplified it for example and I had to decode many [String: SomeGeneric<CustomType>] entries :[

Support implicit conversion from scalar to Swift types

e.g.

extension Node {
    public var any: Any {
        switch self {
        case let .scalar(string):
            if let int = Int(string) {
                return int
            } else if let double = Double(string) {
                return double
            }
            switch string.lowercased() {
            case "true": return true
            case "false": return false
            case "null": return NSNull()
            default: return string
            }
        case let .mapping(dictionary):
            var result = [String:Any](minimumCapacity: dictionary.count)
            dictionary.forEach { result[$0] = $1.any }
            return result
        case let .sequence(array):
            return array.map { $0.any }
        }
    }
}

Prefer indentation before flow style array nested in mapping.

Hi, many thanks for Yams.

I'm using Yams to dump Encodable struct to file via YamlEncoder.
I found a little glitch that the malformed indentation before the flow style array elements that nested in mapping.
This isn't corrupted yaml syntax, but it's preferable to indent it.

Example

struct Test: Encodable {
    var foo: String
    var bar: Int
    var dict: [String: [String]]
}

let test = Test(
    foo: "foo",
    bar: 100,
    dict: [
        "baz": ["A", "B", "C"],
        "qux": ["1", "2"]
    ]
)

print(try YAMLEncoder().encode(test))

Current behavior

foo: foo
bar: 100
dict:
  baz:
  - A
  - B
  - C
  qux:
  - 1
  - 2

Expected

foo: foo
bar: 100
dict:
  baz:
    - A
    - B
    - C
  qux:
    - 1
    - 2

Environments

  • Library version: 2.0.0

  • Swift version: 5.1

  • Xcode version: 11.2.1

Yams.dump dumps numerical String values as Number

this seems to be similar to #174 though i'm not sure it's the same issue.

let dict = ["1.0": "2."]
print(try! Yams.dump(object: dict))

expected output: '1.0': '2.'
actual output: 1.0: 2.

maybe this is an accepted limitation?

if so, i'd love to know if there is a sane way to correctly dump dicts of an unknown structure. i can only think of deep-mapping them to Nodes and setting styles based on the Strings' contents...

Issues building with Xcode from a SwiftPM package

Hi πŸ‘‹

I included this fantastic package as a dependency in a project of mine. On creating the Xcode project through swift package generate-xcodeproj I am no longer able to build with Xcode and getting a bunch of unknown symbol errors.

The issue appears to lie with the following snippet in Parser.swift, Emitter.swift and YamlError.swift.

#if SWIFT_PACKAGE
import CYaml
#endif

If I remove the environment check everything seems to work fine in Xcode and via swift run on the commandline.

I'm sure there's a reason for its existence πŸ™ˆ Can this be worked around somehow?

Thanks! 😊

[YAMLDecoder]Throw error instead of crashing when expecting scalar

Thanks for the lib! I noticed that when trying to use YAMLDecoder, if the expected type for a key is a scalar but the YAML contains an array or an object, the code crashes.

  • Version: 0.5.0

  • Test code:

import Yams

struct TestObject: Decodable {
    let test: String
}

do {
    let string = """
    test:
        - a
        - b
    """
    let object = try YAMLDecoder().decode(TestObject.self, from: string, userInfo: [:])
    print("object: \(object)")
} catch {
    print("error: \(error)")
}
  • Expected result: The decode method should throw an error
  • Actual result: The code crashes on Constructor.swift line 240:
assert(node.isScalar)
return node.scalar!.string

Allow custom Node representations when dumping

Main Idea

When calling Yams.dump(object: someDict), there is no option to choose how to transform the someDict into a tree of Nodes.

Internally, Yams.dump will recursively traverse the dictionary/object and call represented() on each
instance it encounters (provided it conforms to NodeRepresentable) to transform each item into a Node. But that transformation isn't customisable, so for example if we want strings to be double-quoted when dumped as YAML, we don't have an easy way to do that.

This issue is to discuss the idea of providing such a customisation point for dumping.

Goal: Mirroring the customisation point of Yams.load(…, Constructor(…)) for Yams.dump

Note that When parsing a YAML string into a Swift Dictionary using Yams.load, there's already a way to customize the parsing, using a custom Resolver and Constructor, for example to choose to only parse "true" and "false" as Booleans but not "yes" or "no" like what's done in SwiftLint

The idea would be to provide a similar customisation point to dumping/serializing as this customisation point we already have for parsing/loading.

Rationale

This need for customisation arised in a PR in SwiftGen, where we needed to dump Strings and Booleans in a different way, so that when our dictionary contains a mix of true (Boolean) and "true" (String) it would be dumped differently and that when read back using Yams.load we'd get back the same Boolean and Strings as the original.

We found a solution with the help of @norio-nomura β€” by re-implementing the recursive transformation of our dictionary into a tree of Node in our customRepresent(…), instead of letting dump call the default dict.represent() β€” but it would be cool to have that kind of possibility built-in without having to manually reimplement the recursion code and risk missing something.

Alternatives considered

Here are all the possibles way I've thought about to fix our issue in that SwiftGen PR to differentiate "true" as String vs true as Boolean in dumped YAML:

  1. either to add a parameter to dump to allow quoteAllStrings: Bool : that would only allo that specific customisation of quoting all strings to differentiate them from Bool, but would not allow arbitrary customisation aside from that
  2. add a customRepresenterMap: [Any.Type: (Any) -> Node] parameter to dump/serialize so we can just pass a map like [String.self: { s in s.quotedRepresent() }] if we want to customize only some types, without end-users of YAML having to re-implement the whole recursive for dictionaries and arrays etc. That's the idea behind the current issue/discussion
  3. or declare a protocol CustomNodeRepresentable which would be used instead of NodeRepresentable if the type conforms to it, fallbacking to NodeRepresentable otherwise. But that last solution would mean that we couldn't call Yams.dump sometimes with one representation, sometimes with another, in the same codebase… so I'm not a fan and would prefer a solution like 2., to have something similar to what we have with Resolver/Constructor on the parsing side…

Solution

Solution 2 that I'm pitching here would probably be the best one β€” mirroring the solution already existing for Yams.load+Constructor/ScalarMap β€” and should not be that hard to implement, by:

  • changing the protocol NodeRepresentable to add a func represented(customRepresentation: [Any.Type: (Any) -> Node])
  • provide a default implementation for func represented() that would call represented(customRepresentation: [:]) with an empty custom representation map, so that we keep backward compatibility
  • change the methods in Yams calling represented() (especially dump(…) and serialize(…) to take a customRepresentation map as parameter and pass it recursively to the calls to represented(…) they make

Another advantage of that solution, unlike the one we used, is that in apps and libs code bases having some custom types that would be made conform to NodeRepresentable, those custom types would also be able to recursively forward that custom map down the road (unlike the case let representable as NodeRepresentable: return try representable.represented() fallback we have in our solution)

Going further: exposing some common customization points

I think both the custom Constructor/ScalarMap used in SwiftLint (mainly the one parsing ENV variables for strings and the one only parsing "true" and "false" as booleans) could benefit not only to SwiftLint but to other projects using YAMS, so making them public would be nice.

Similarly, if we do this customisation point for dump/serialize, it could be nice to publicly expose some common alternative maps, like one to dump all Strings as single or double-quoted β€” as this risk of Boolean vs String confusion can happen to other projects using YAMS too, not just SwiftGen β€” so that people won't have to re-implement those common alternatives over and over, and would only implement their custom maps if they need something really uncommon.

dump failed if there is a nil value

image
I am using Swift 5.1 and Xcode 11.2.1.

I try to debug the Yams, and it throw a error:

private func represent(_ value: Any) throws -> Node {
    if let string = value as? String {
        return Node(string)
    } else if let representable = value as? NodeRepresentable {
        return try representable.represented()
    }
    throw YamlError.representer(problem: "Failed to represent \(value)")  // -> print "Failed to represent nil"
}

extension Optional: NodeRepresentable {
    public func represented() throws -> Node {
        switch self {
        case let .some(wrapped):
            return try represent(wrapped)  // <-- The ALIAS's value hit this case, but it is nil. As it is a .some<nil>
        case .none:
            return Node("null", Tag(.null))
        }
    }
}

Is it a bug?

Array order

Hey, great library!

I'm using it currently to read in a YML file of an array of objects, sort the objects into a normalized order, and then write the YML back to the file. However, the output encoded YML does not have the same order as the array I have in memory.

Is that expected?

Thanks!

Linking CYaml

Hi

This is not directly an issue with YAMS specifically, but I'm having trouble running a CI tool that depends on this due to CYaml. My Package.swift is here https://github.com/yonaskolb/SwagGen

When it's built with swift build I can do .build/debug/SwagGen and it runs fine. But if I move it out of there, and delete build directory, it will not run as libCYaml.dylib is not present and it's referenced by an absolute path:

dyld: Library not loaded: /Users/Yonas/Developer/SwagGen/.build/debug/libCYaml.dylib
  Referenced from: /Users/Yonas/Developer/SwagGen/.build/debug/test/SwagGen
  Reason: image not found

Do you know a way around this? Bundling up CYaml into the app? linking to a global framework instead relative path? Or another solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.