< Summary

Information
Class: Anichron.Worker.Ingestion.Proxy.SystemProcessLauncher
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/SystemProcessLauncher.cs
Tag: 19_45211875487
Line coverage
81%
Covered lines: 22
Uncovered lines: 5
Coverable lines: 27
Total lines: 43
Line coverage: 81.4%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RunAsync()100%2281.48%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/SystemProcessLauncher.cs

#LineLine coverage
 1using System.Diagnostics;
 2
 3namespace Anichron.Worker.Ingestion.Proxy;
 4
 5internal sealed class SystemProcessLauncher : IProcessLauncher
 6{
 7    public async Task<ProcessResult> RunAsync(string fileName, IReadOnlyList<string> arguments, CancellationToken ct)
 28    {
 29        using var process = new Process();
 210        process.StartInfo = new ProcessStartInfo
 211        {
 212            FileName = fileName,
 213            RedirectStandardOutput = true,
 214            RedirectStandardError = true,
 215            UseShellExecute = false,
 216            CreateNoWindow = true,
 217        };
 1418        foreach (var arg in arguments)
 419            process.StartInfo.ArgumentList.Add(arg);
 20
 221        process.Start();
 22        // Start draining pipes immediately — must be consumed to prevent the child process
 23        // from blocking on a full pipe buffer. Cancellation is signalled only via WaitForExitAsync.
 224        await using var standardOutput = new MemoryStream();
 225        var stdoutTask = process.StandardOutput.BaseStream.CopyToAsync(standardOutput, CancellationToken.None);
 226        var stderrTask = process.StandardError.ReadToEndAsync(CancellationToken.None);
 27        try
 228        {
 229            await process.WaitForExitAsync(ct);
 230            await stdoutTask;
 231            var standardError = await stderrTask;
 232            return new ProcessResult(process.ExitCode, standardOutput.ToArray(), standardError);
 33        }
 034        catch (OperationCanceledException)
 035        {
 36            // Kill the process tree so GPU encoder children (e.g. vaenc) are not orphaned.
 037            process.Kill(entireProcessTree: true);
 38            // Drain fully before returning — the killed process closes its pipes immediately.
 039            await Task.WhenAll(stdoutTask, stderrTask);
 040            throw;
 41        }
 242    }
 43}

Methods/Properties

RunAsync()