From cb1f7e2dc7840f3016914e5702c575dfb2a8a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 10 Oct 2019 13:48:36 +0200 Subject: [PATCH 1/3] Fix platform dependency in buffered reader test Tests for the line-buffered reader added in 7b1ff38 were subtly dependent on the execution environment due to differing end-of-line markers on Windows and Unix-based systems. Because StreamReader discards all newlines when reading line-by-line, LineBufferedReader used a StringBuilder to patch the peeked lines back together with the remaining contents of the file being read. As StringBuilder.AppendLine uses the environment-specific newline delimiter, the delimiters after the peeked-but-unconsumed lines can therefore be substituted by the platform-specific variants, causing the test failures due to the overly-simplified way they were written. Reformulate the test to avoid such issues from resurfacing again by splitting lines by \r or \n and then testing each line individually. Additionally remove all raw literals in favour of explicitly mixing various line delimiter character sequences for additional coverage. --- .../Beatmaps/IO/LineBufferedReaderTest.cs | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs index b582ca0a6f..25517ad615 100644 --- a/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/LineBufferedReaderTest.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.IO; using System.Text; using NUnit.Framework; @@ -14,9 +15,7 @@ namespace osu.Game.Tests.Beatmaps.IO [Test] public void TestReadLineByLine() { - const string contents = @"line 1 -line 2 -line 3"; + const string contents = "line 1\rline 2\nline 3"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) @@ -31,9 +30,7 @@ line 3"; [Test] public void TestPeekLineOnce() { - const string contents = @"line 1 -peek this -line 3"; + const string contents = "line 1\r\npeek this\nline 3"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) @@ -49,9 +46,7 @@ line 3"; [Test] public void TestPeekLineMultipleTimes() { - const string contents = @"peek this once -line 2 -peek this a lot"; + const string contents = "peek this once\nline 2\rpeek this a lot"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) @@ -70,8 +65,7 @@ peek this a lot"; [Test] public void TestPeekLineAtEndOfStream() { - const string contents = @"first line -second line"; + const string contents = "first line\r\nsecond line"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) @@ -100,8 +94,7 @@ second line"; [Test] public void TestReadToEndNoPeeks() { - const string contents = @"first line -second line"; + const string contents = "first line\r\nsecond line"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) @@ -113,20 +106,19 @@ second line"; [Test] public void TestReadToEndAfterReadsAndPeeks() { - const string contents = @"this line is gone -this one shouldn't be -these ones -definitely not"; + const string contents = "this line is gone\rthis one shouldn't be\r\nthese ones\ndefinitely not"; using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents))) using (var bufferedReader = new LineBufferedReader(stream)) { Assert.AreEqual("this line is gone", bufferedReader.ReadLine()); Assert.AreEqual("this one shouldn't be", bufferedReader.PeekLine()); - const string ending = @"this one shouldn't be -these ones -definitely not"; - Assert.AreEqual(ending, bufferedReader.ReadToEnd()); + + var endingLines = bufferedReader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + Assert.AreEqual(3, endingLines.Length); + Assert.AreEqual("this one shouldn't be", endingLines[0]); + Assert.AreEqual("these ones", endingLines[1]); + Assert.AreEqual("definitely not", endingLines[2]); } } } From 44853c262c8573fc1161bfab9fe27c0abfa56a8a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 11 Oct 2019 13:55:58 +0900 Subject: [PATCH 2/3] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index fa940a7c89..0a831eceb2 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -62,6 +62,6 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4e3130b64c..c2888c8e21 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -26,7 +26,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index fb6d5107ff..8ad7a58e36 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -118,8 +118,8 @@ - - + + From d44acf20b40b75e9cc92ac2feb8c3d6f2779b1cc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2019 05:33:15 +0000 Subject: [PATCH 3/3] Bump ppy.osu.Framework.NativeLibs from 2019.1010.0 to 2019.1011.0 Bumps [ppy.osu.Framework.NativeLibs](https://github.com/ppy/osu-framework) from 2019.1010.0 to 2019.1011.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.1010.0...2019.1011.0) Signed-off-by: dependabot-preview[bot] --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index 8ad7a58e36..7532bd5100 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -124,6 +124,6 @@ - +