Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80009bd

Browse filesBrowse files
committed
Run script packages tests out of process
1 parent 56eae0a commit 80009bd
Copy full SHA for 80009bd

File tree

3 files changed

+30
-16
lines changed
Filter options

3 files changed

+30
-16
lines changed

‎src/.vscode/settings.json

Copy file name to clipboard
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"coverage-gutters.lcovname": "coverage.info"
3-
}
2+
"coverage-gutters.lcovname": "coverage.info",
3+
"dotnetCoreExplorer.searchpatterns": "**/bin/Debug/net5.0/Dotnet.Script.Tests.dll"
4+
}

‎src/Dotnet.Script.Tests/ScriptPackagesTests.cs

Copy file name to clipboardExpand all lines: src/Dotnet.Script.Tests/ScriptPackagesTests.cs
+20-14Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public ScriptPackagesTests(ITestOutputHelper testOutputHelper)
2525
[Fact]
2626
public void ShouldHandleScriptPackageWithMainCsx()
2727
{
28-
var result = Execute("WithMainCsx/WithMainCsx.csx");
29-
Assert.StartsWith("Hello from netstandard2.0", result);
28+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithMainCsx", "--no-cache");
29+
Assert.Equal(0, exitcode);
30+
Assert.StartsWith("Hello from netstandard2.0", output);
3031
}
3132

32-
[Fact]
33+
//[Fact]
3334
public void ShouldThrowMeaningfulExceptionWhenScriptPackageIsMissing()
3435
{
3536
using (var scriptFolder = new DisposableFolder())
@@ -60,37 +61,42 @@ public void ShouldThrowMeaningfulExceptionWhenScriptPackageIsMissing()
6061
[Fact]
6162
public void ShouldHandleScriptWithAnyTargetFramework()
6263
{
63-
var result = Execute("WithAnyTargetFramework/WithAnyTargetFramework.csx");
64-
Assert.StartsWith("Hello from any target framework", result);
64+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithAnyTargetFramework", "--no-cache");
65+
Assert.Equal(0, exitcode);
66+
Assert.StartsWith("Hello from any target framework", output);
6567
}
6668

6769
[Fact]
6870
public void ShouldHandleScriptPackageWithNoEntryPointFile()
6971
{
70-
var result = Execute("WithNoEntryPointFile/WithNoEntryPointFile.csx");
71-
Assert.Contains("Hello from Foo.csx", result);
72-
Assert.Contains("Hello from Bar.csx", result);
72+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithNoEntryPointFile", "--no-cache");
73+
Assert.Equal(0, exitcode);
74+
Assert.Contains("Hello from Foo.csx", output);
75+
Assert.Contains("Hello from Bar.csx", output);
7376
}
7477

7578
[Fact]
7679
public void ShouldHandleScriptPackageWithScriptPackageDependency()
7780
{
78-
var result = Execute("WithScriptPackageDependency/WithScriptPackageDependency.csx");
79-
Assert.StartsWith("Hello from netstandard2.0", result);
81+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithScriptPackageDependency", "--no-cache");
82+
Assert.Equal(0, exitcode);
83+
Assert.StartsWith("Hello from netstandard2.0", output);
8084
}
8185

8286
[Fact]
8387
public void ShouldThrowExceptionWhenReferencingUnknownPackage()
8488
{
85-
var result = Execute("WithInvalidPackageReference/WithInvalidPackageReference.csx");
86-
Assert.StartsWith("Unable to restore packages from", result);
89+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithInvalidPackageReference", "--no-cache");
90+
Assert.NotEqual(0, exitcode);
91+
Assert.StartsWith("Unable to restore packages from", output);
8792
}
8893

8994
[Fact]
9095
public void ShouldHandleScriptPackageWithSubFolder()
9196
{
92-
var result = Execute("WithSubFolder/WithSubFolder.csx");
93-
Assert.StartsWith("Hello from Bar.csx", result);
97+
var (output, exitcode) = ScriptTestRunner.Default.ExecuteWithScriptPackage("WithSubFolder", "--no-cache");
98+
Assert.Equal(0, exitcode);
99+
Assert.StartsWith("Hello from Bar.csx", output);
94100
}
95101

96102
[Fact]

‎src/Dotnet.Script.Tests/ScriptTestRunner.cs

Copy file name to clipboardExpand all lines: src/Dotnet.Script.Tests/ScriptTestRunner.cs
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public int ExecuteInProcess(string arguments = null)
4242
return result;
4343
}
4444

45+
public (string output, int exitcode) ExecuteWithScriptPackage(string fixture, string arguments = null, string workingDirectory = null)
46+
{
47+
var pathToScriptPackageFixtures = TestPathUtils.GetPathToTestFixtureFolder("ScriptPackage");
48+
var pathToFixture = Path.Combine(pathToScriptPackageFixtures, fixture, $"{fixture}.csx");
49+
return ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments($"{pathToFixture} {arguments}"), workingDirectory);
50+
}
51+
4552
public int ExecuteFixtureInProcess(string fixture, string arguments = null)
4653
{
4754
var pathToFixture = TestPathUtils.GetPathToTestFixture(fixture);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.