Skip to content

Commit

Permalink
fix test hangs (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur authored Aug 5, 2022
1 parent 62ed705 commit d141c72
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task When_an_ipynb_is_run_and_no_error_is_produced_then_the_exit_co
}

[Fact]
public async Task When_an_ipynb_is_run_and_an_error_is_produced_from_a_cell_then_the_exit_code_is_1()
public async Task When_an_ipynb_is_run_and_an_error_is_produced_from_a_cell_then_the_exit_code_is_2()
{
var result = await _parser.InvokeAsync($"--notebook \"{_directory}/fail.ipynb\" --exit-after-run", console);

Expand Down
10 changes: 10 additions & 0 deletions src/dotnet-repl.Tests/ReplInteractionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
using Microsoft.DotNet.Interactive;
using Microsoft.Extensions.DependencyInjection;
using Pocket;
using Pocket.For.Xunit;
using Spectre.Console;
using Xunit;
using Xunit.Abstractions;
using CompositeDisposable = System.Reactive.Disposables.CompositeDisposable;

namespace dotnet_repl.Tests;

[CollectionDefinition("Do not parallelize", DisableParallelization = true)]
public class SerialTestCollectionDefinition
{

}

[LogToPocketLogger(@"c:\temp\dotnet-repl.test.log")]
[Xunit.Collection("Do not parallelize")]
public abstract class ReplInteractionTests : IDisposable
{
private readonly CompositeDisposable _disposables;
Expand Down
1 change: 0 additions & 1 deletion src/dotnet-repl.Tests/dotnet-repl.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>dotnet_repl.Tests</RootNamespace>

<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
12 changes: 7 additions & 5 deletions src/dotnet-repl/Repl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public Repl(

private LineEditorServiceProvider? LineEditorProvider { get; }

public void Start()
public async Task Start()
{
var ready = ReadyForInput.FirstAsync();
Task.Run(() => RunAsync(_ => { }));
ready.FirstAsync().Wait();
var ready = ReadyForInput.Replay();
var _ = Task.Run(() => RunAsync(_ => { }));
await ready.FirstAsync();
}

public async Task RunAsync(
Expand Down Expand Up @@ -144,14 +144,16 @@ public async Task RunAsync(

if (await result.KernelEvents.LastAsync() is CommandFailed failed)
{
setExitCode(1);
setExitCode(2);
}

if (exitAfterRun && queuedSubmissions.Count == 0)
{
break;
}
}

_readyForInput.OnCompleted();
}

private void SetTheme()
Expand Down

0 comments on commit d141c72

Please sign in to comment.