-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix bug around unix paths Unix paths were accidentally being treated as options when exporting the RSP file. This lead to the RSP file being invalid as it had paths that weren't available the local machine (or even valid paths when crossing between operating systems). The fix was fairly simple but testing it caused a decent amount of churn in the repository. Had to add APIs to make it possible to build up a compiler log in memory instead of off of disk. * more * more * more
- Loading branch information
Showing
27 changed files
with
500 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
"jaredpar", | ||
"msbuild", | ||
"Mvid", | ||
"NETCOREAPP", | ||
"NET", | ||
"netstandard", | ||
"ondisk", | ||
"Relogger", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#if NETCOREAPP | ||
#if NET | ||
using Xunit; | ||
|
||
namespace Basic.CompilerLog.UnitTests; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System.Text; | ||
using Basic.CompilerLog.Util; | ||
using DotUtils.StreamUtils; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Basic.CompilerLog.UnitTests; | ||
|
||
public class StringStreamTests | ||
{ | ||
private static readonly Encoding[] Encodings = | ||
[ | ||
Encoding.UTF8, | ||
Encoding.UTF32 | ||
]; | ||
|
||
private void RoundTripByteByByte(string input) | ||
{ | ||
foreach (var encoding in Encodings) | ||
{ | ||
using var inputStream = new StringStream(input, encoding); | ||
using var memoryStream = new MemoryStream(); | ||
while (inputStream.ReadByte() is int b && b != -1) | ||
{ | ||
memoryStream.WriteByte((byte)b); | ||
} | ||
|
||
memoryStream.Position = 0; | ||
var actual = encoding.GetString(memoryStream.ToArray()); | ||
Assert.Equal(input, actual); | ||
} | ||
} | ||
|
||
private void RoundTripCopy(string input) | ||
{ | ||
foreach (var encoding in Encodings) | ||
{ | ||
using var inputStream = new StringStream(input, encoding); | ||
using var memoryStream = new MemoryStream(); | ||
inputStream.CopyTo(memoryStream); | ||
|
||
memoryStream.Position = 0; | ||
var actual = encoding.GetString(memoryStream.ToArray()); | ||
Assert.Equal(input, actual); | ||
} | ||
} | ||
|
||
private void RoundTripReset(string input) | ||
{ | ||
foreach (var encoding in Encodings) | ||
{ | ||
using var inputStream = new StringStream(input, encoding); | ||
using var memoryStream = new MemoryStream(); | ||
inputStream.Position = 0; | ||
memoryStream.Position = 0; | ||
inputStream.CopyTo(memoryStream); | ||
|
||
memoryStream.Position = 0; | ||
var actual = encoding.GetString(memoryStream.ToArray()); | ||
Assert.Equal(input, actual); | ||
} | ||
} | ||
|
||
private void RoundTripAll(string input) | ||
{ | ||
RoundTripByteByByte(input); | ||
RoundTripCopy(input); | ||
RoundTripReset(input); | ||
} | ||
|
||
[Fact] | ||
public void Behaviors() | ||
{ | ||
var stream = new StringStream("hello", Encoding.UTF8); | ||
Assert.True(stream.CanRead); | ||
Assert.False(stream.CanWrite); | ||
Assert.False(stream.CanSeek); | ||
Assert.Throws<NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin)); | ||
Assert.Throws<NotSupportedException>(() => stream.Write(Array.Empty<byte>(), 0, 0)); | ||
Assert.Throws<NotSupportedException>(() => stream.SetLength(1)); | ||
stream.Flush(); // no-op | ||
} | ||
|
||
[Fact] | ||
public void PositionReset() | ||
{ | ||
var stream = new StringStream("hello", Encoding.UTF8); | ||
var bytes1 = stream.ReadToEnd(); | ||
stream.Position = 0; | ||
var bytes2 = stream.ReadToEnd(); | ||
Assert.Equal(bytes1, bytes2); | ||
} | ||
|
||
[Fact] | ||
public void PositionSetToMiddle() | ||
{ | ||
var stream = new StringStream("hello", Encoding.UTF8); | ||
var bytes1 = stream.ReadToEnd(); | ||
stream.Position = 0; | ||
Assert.Throws<NotSupportedException>(() => stream.Position = 1); | ||
} | ||
|
||
[Theory] | ||
[InlineData("Hello, world!")] | ||
[InlineData("")] | ||
[InlineData("lets try this value")] | ||
public void RoundTrip(string input) => RoundTripAll(input); | ||
|
||
[Fact] | ||
public void RoundTripGenerated() | ||
{ | ||
RoundTripAll(new string('a', 1000)); | ||
RoundTripAll(new string('a', 10_000)); | ||
} | ||
|
||
[Fact] | ||
public void ReadEmpty() | ||
{ | ||
var stream = new StringStream("hello world", Encoding.UTF8); | ||
Assert.Equal(0, stream.Read(Array.Empty<byte>(), 0, 0)); | ||
#if NET | ||
Assert.Equal(0, stream.Read(Array.Empty<byte>().AsSpan())); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.