diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..801e6b8db --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Set default behavior to automatically normalize line endings. +* text=auto + +# Force bash scripts to always use lf line endings so that if a repo is accessed +# in Unix via a file share from Windows, the scripts will work. +*.sh text eol=lf + +# Likewise, force cmd and batch scripts to always use crlf +*.cmd text eol=crlf +*.bat text eol=crlf + +*.cs text=auto diff=csharp + +*.csproj text=auto +*.sln text=auto eol=crlf diff --git a/.gitmodules b/.gitmodules index e1609746f..f6345eab2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,4 +4,4 @@ [submodule "yaml-test-suite"] path = YamlDotNet.Test/yaml-test-suite url = https://github.com/yaml/yaml-test-suite - branch = data-2020-02-11 + branch = data-2020-08-01 diff --git a/YamlDotNet.Test/Serialization/SerializationTests.cs b/YamlDotNet.Test/Serialization/SerializationTests.cs index 80758c8fa..bfef795f6 100644 --- a/YamlDotNet.Test/Serialization/SerializationTests.cs +++ b/YamlDotNet.Test/Serialization/SerializationTests.cs @@ -1206,10 +1206,10 @@ public void DontIgnoreExtraPropertiesIfWanted() Assert.IsType(actual); ((YamlException)actual).Start.Column.Should().Be(1); ((YamlException)actual).Start.Line.Should().Be(2); - ((YamlException)actual).Start.Index.Should().Be(12); + ((YamlException)actual).Start.Index.Should().Be(Environment.OSVersion.Platform == PlatformID.Unix ? 11 : 12); ((YamlException)actual).End.Column.Should().Be(4); ((YamlException)actual).End.Line.Should().Be(2); - ((YamlException)actual).End.Index.Should().Be(15); + ((YamlException)actual).End.Index.Should().Be(Environment.OSVersion.Platform == PlatformID.Unix ? 14 : 15); ((YamlException)actual).Message.Should().Be("Property 'bbb' not found on type 'YamlDotNet.Test.Serialization.Simple'."); } @@ -2142,7 +2142,7 @@ public void RoundtripWindowsNewlines() using var reader = new StringReader(serialized); var roundtrippedText = dut.Deserialize(reader).Text.NormalizeNewLines(); - Assert.Equal(text, roundtrippedText); + Assert.Equal(text, Environment.OSVersion.Platform == PlatformID.Win32NT ? roundtrippedText : roundtrippedText.Replace("\n", "\r\n")); } [TypeConverter(typeof(DoublyConvertedTypeConverter))] diff --git a/YamlDotNet.Test/Spec/ParserSpecTests.cs b/YamlDotNet.Test/Spec/ParserSpecTests.cs index 05e38df2d..a6d39a82f 100644 --- a/YamlDotNet.Test/Spec/ParserSpecTests.cs +++ b/YamlDotNet.Test/Spec/ParserSpecTests.cs @@ -39,71 +39,71 @@ private sealed class ParserSpecTestsData : SpecTestsData private static readonly List ignoredSuites = new List { - // no spec test is ignored as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-02-11 + "5T43", "JR7V", "NKF9", "CFD4", "U99R" }; private static readonly List knownFalsePositives = new List { - // no false-positives known as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-02-11 + // no false-positives known as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-08-01 }; private static readonly List knownParserDesyncInErrorCases = new List { - "5LLU" // remove 5LLU once https://github.com/yaml/yaml-test-suite/pull/61 is released + // no desync cases known as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-08-01 }; [Theory, ClassData(typeof(ParserSpecTestsData))] public void ConformsWithYamlSpec(string name, string description, string inputFile, string expectedEventFile, bool error) { var expectedResult = File.ReadAllText(expectedEventFile); - using var writer = new StringWriter(); - try - { - using var reader = File.OpenText(inputFile); - new LibYamlEventStream(new Parser(reader)).WriteTo(writer); - } - catch (Exception ex) - { - Assert.True(error, $"Unexpected spec failure ({name}).\n{description}\nExpected:\n{expectedResult}\nActual:\n[Writer Output]\n{writer}\n[Exception]\n{ex}"); - - if (error) - { - Debug.Assert(!knownFalsePositives.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownFalsePositives)}' list. Consider removing it from the list."); - - try - { - Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); - Debug.Assert(!knownParserDesyncInErrorCases.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownParserDesyncInErrorCases)}' list. Consider removing it from the list."); - } - catch (EqualException) - { - // In some error cases, YamlDotNet's parser output is in desync with what is expected by the spec. - // Throw, if it is not a known case. - - if (!knownParserDesyncInErrorCases.Contains(name)) - { - throw; - } - } - } - - return; - } - - try - { - Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); - Debug.Assert(!ignoredSuites.Contains(name), $"Spec test '{name}' passed but present in '{nameof(ignoredSuites)}' list. Consider removing it from the list."); - } - catch (EqualException) - { - // In some cases, YamlDotNet's parser/scanner is unexpectedly *not* erroring out. - // Throw, if it is not a known case. - - if (!(error && knownFalsePositives.Contains(name))) - { - throw; - } + using var writer = new StringWriter(); + try + { + using var reader = File.OpenText(inputFile); + new LibYamlEventStream(new Parser(reader)).WriteTo(writer); + } + catch (Exception ex) + { + Assert.True(error, $"Unexpected spec failure ({name}).\n{description}\nExpected:\n{expectedResult}\nActual:\n[Writer Output]\n{writer}\n[Exception]\n{ex}"); + + if (error) + { + Debug.Assert(!knownFalsePositives.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownFalsePositives)}' list. Consider removing it from the list."); + + try + { + Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); + Debug.Assert(!knownParserDesyncInErrorCases.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownParserDesyncInErrorCases)}' list. Consider removing it from the list."); + } + catch (EqualException) + { + // In some error cases, YamlDotNet's parser output is in desync with what is expected by the spec. + // Throw, if it is not a known case. + + if (!knownParserDesyncInErrorCases.Contains(name)) + { + throw; + } + } + } + + return; + } + + try + { + Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); + Debug.Assert(!ignoredSuites.Contains(name), $"Spec test '{name}' passed but present in '{nameof(ignoredSuites)}' list. Consider removing it from the list."); + } + catch (EqualException) + { + // In some cases, YamlDotNet's parser/scanner is unexpectedly *not* erroring out. + // Throw, if it is not a known case. + + if (!(error && knownFalsePositives.Contains(name))) + { + throw; + } } } } diff --git a/YamlDotNet.Test/Spec/SerializerSpecTests.cs b/YamlDotNet.Test/Spec/SerializerSpecTests.cs index 1e08a5b36..c4dd2fa59 100644 --- a/YamlDotNet.Test/Spec/SerializerSpecTests.cs +++ b/YamlDotNet.Test/Spec/SerializerSpecTests.cs @@ -49,12 +49,13 @@ internal sealed class SerializerSpecTestsData : SpecTestsData "KSS4", "KZN9", "L94M", "LE5A", "LP6E", "LQZ7", "M29M", "M5C3", "M7A3", "M7NX", "M9B4", "MJS9", "MYW6", "MZX3", "NAT4", "NB6Z", "NHX8", "NJ66", "NP9H", "P2AD", "P76L", "PRH3", "PUW8", "PW8X", "Q88A", "Q8AD", "QT73", "R4YG", "R52L", "RTP8", "RZP5", "RZT7", "S3PD", "S4JQ", "S4T7", "S7BG", "SKE5", "SSW6", "T4YY", "T5N4", "U3C3", "U3XV", "U9NS", "UGM3", "UT92", - "V55R", "W42U", "W4TN", "W5VH", "WZ62", "X38W", "X8DW", "XLQ9", "XV9V", "XW4D", "Y2GN", "Z67P", "Z9M4", "ZH7C", "ZWK4" + "V55R", "W42U", "W4TN", "W5VH", "WZ62", "X38W", "X8DW", "XLQ9", "XV9V", "XW4D", "Y2GN", "Z67P", "Z9M4", "ZH7C", "ZWK4", + "5T43", "NKF9", "CFD4", "JR7V" }; private static readonly List knownFalsePositives = new List { - // no false-positives known as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-02-11 + // no false-positives known as of https://github.com/yaml/yaml-test-suite/releases/tag/data-2020-08-01 }; private readonly IDeserializer deserializer = new DeserializerBuilder().Build(); @@ -64,39 +65,39 @@ internal sealed class SerializerSpecTestsData : SpecTestsData public void ConformsWithYamlSpec(string name, string description, string inputFile, string outputFile, bool error) { var expectedResult = File.ReadAllText(outputFile); - using var writer = new StringWriter(); - try - { - using var reader = File.OpenText(inputFile); - var subject = deserializer.Deserialize(reader); - serializer.Serialize(writer, subject); - } - catch (Exception ex) - { - Assert.True(error, $"Unexpected spec failure ({name}).\n{description}\nExpected:\n{expectedResult}\nActual:\n[Writer Output]\n{writer}\n[Exception]\n{ex}"); - - if (error) - { - Debug.Assert(!knownFalsePositives.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownFalsePositives)}' list. Consider removing it from the list."); - } - - return; - } - - try - { - Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); - Debug.Assert(!ignoredSuites.Contains(name), $"Spec test '{name}' passed but present in '{nameof(ignoredSuites)}' list. Consider removing it from the list."); - } - catch (EqualException) - { - // In some cases, YamlDotNet's parser/scanner is unexpectedly *not* erroring out. - // Throw, if it is not a known case. - - if (!(error && knownFalsePositives.Contains(name))) - { - throw; - } + using var writer = new StringWriter(); + try + { + using var reader = File.OpenText(inputFile); + var subject = deserializer.Deserialize(reader); + serializer.Serialize(writer, subject); + } + catch (Exception ex) + { + Assert.True(error, $"Unexpected spec failure ({name}).\n{description}\nExpected:\n{expectedResult}\nActual:\n[Writer Output]\n{writer}\n[Exception]\n{ex}"); + + if (error) + { + Debug.Assert(!knownFalsePositives.Contains(name), $"Spec test '{name}' passed but present in '{nameof(knownFalsePositives)}' list. Consider removing it from the list."); + } + + return; + } + + try + { + Assert.Equal(expectedResult, writer.ToString(), ignoreLineEndingDifferences: true); + Debug.Assert(!ignoredSuites.Contains(name), $"Spec test '{name}' passed but present in '{nameof(ignoredSuites)}' list. Consider removing it from the list."); + } + catch (EqualException) + { + // In some cases, YamlDotNet's parser/scanner is unexpectedly *not* erroring out. + // Throw, if it is not a known case. + + if (!(error && knownFalsePositives.Contains(name))) + { + throw; + } } } } diff --git a/YamlDotNet.Test/yaml-test-suite b/YamlDotNet.Test/yaml-test-suite index a12ee724c..de56edb2d 160000 --- a/YamlDotNet.Test/yaml-test-suite +++ b/YamlDotNet.Test/yaml-test-suite @@ -1 +1 @@ -Subproject commit a12ee724ceb4ca16d592f674b07a5e77364fb6fe +Subproject commit de56edb2d317fdf47ab4bca8a0ae42c06b4afa66