Skip to content

Commit

Permalink
tests for both netfx and netcore
Browse files Browse the repository at this point in the history
  • Loading branch information
dzsquared committed Jan 19, 2024
1 parent 1afc6d3 commit 8a5a613
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ jobs:
run: |
.\disableStrongName.ps1
- name: Run tests
- name: Run tests Windows
if: matrix.os == 'windows-latest'
run: dotnet test

- name: Run tests Linux
if: matrix.os == 'ubuntu-latest'
run: dotnet test /p:TargetFramework=net6.0
2 changes: 1 addition & 1 deletion Test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">$(EnlistmentRoot)\obj\$([MSBuild]::MakeRelative('$(EnlistmentRoot)\', $(MSBuildProjectDirectory)))</BaseIntermediateOutputPath>

<!-- Test on netcore to cover all platforms -->
<TargetFrameworks>$(NetCoreVersion)</TargetFrameworks>
<TargetFrameworks>$(NetfxVersion);$(NetCoreVersion)</TargetFrameworks>

<!-- The TargetGroup can be used to express condition that are common to more than one TargetFramework (currently not used)-->
<TargetGroup Condition="'$(TargetFramework)'=='netstandard2.0' Or '$(TargetFramework)'=='netstandard2.1' Or '$(TargetFramework)'=='netstandard2.2'">netstandard</TargetGroup>
Expand Down
13 changes: 13 additions & 0 deletions Test/SqlDom/LexingEntryPointsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public void GetTokenStreamWithErrorTestImpl(TSqlParser parser)
[SqlStudioTestCategory(Category.UnitTest)]
public void LexingErrorHandler()
{
#if NET
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
{
ParserTestUtils.ExecuteTestForAllParsers(delegate(TSqlParser parser)
Expand All @@ -215,6 +216,18 @@ public void LexingErrorHandler()
}
}, false);
}
#else
ParserTestUtils.ExecuteTestForAllParsers(delegate(TSqlParser parser)
{
using (TextReader sr = new StreamReader(Path.Combine(System.Environment.GetEnvironmentVariable("windir"), @"system32\notepad.exe")))
{
IList<ParseError> errors;
parser.GetTokenStream(sr, out errors);
ParserTestUtils.LogErrors(errors);
Assert.AreEqual<int>(1, errors.Count);
}
}, false);
#endif
}


Expand Down
6 changes: 6 additions & 0 deletions Test/SqlDom/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ public static string GetStringFromResource(string resourceName)
result = sr.ReadToEnd();
}

#if NET
// Convert line endings from \n to \r\n
if (System.Environment.NewLine == "\n")
result = result.ReplaceLineEndings("\r\n");
#endif

return result;
}
Expand Down Expand Up @@ -379,9 +381,11 @@ public static TSqlFragment ParseFromResource(TSqlParser parser, string sourceFil
source = sr.ReadToEnd();
}

#if NET
// Convert line endings from \n to \r\n
if (System.Environment.NewLine == "\n")
source = source.ReplaceLineEndings("\r\n");
#endif

using(TextReader tr = new StringReader(source))
{
Expand All @@ -397,9 +401,11 @@ public static IList<TSqlParserToken> ParseTokensFromResource(TSqlParser parser,
source = sr.ReadToEnd();
}

#if NET
// Convert line endings from \n to \r\n
if (System.Environment.NewLine == "\n")
source = source.ReplaceLineEndings("\r\n");
#endif

using (TextReader tr = new StringReader(source))
{
Expand Down

0 comments on commit 8a5a613

Please sign in to comment.