From 07290f1eb63c1550957982421921e7e5d7911c0d Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 15 Aug 2022 17:06:39 -0300 Subject: [PATCH] omnisharp-roslyn: add tests --- .../tools/omnisharp-roslyn/default.nix | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/omnisharp-roslyn/default.nix b/pkgs/development/tools/omnisharp-roslyn/default.nix index 31d0b5343569..505f19c5427c 100644 --- a/pkgs/development/tools/omnisharp-roslyn/default.nix +++ b/pkgs/development/tools/omnisharp-roslyn/default.nix @@ -5,11 +5,13 @@ , lib , patchelf , stdenv +, runCommand +, expect }: let inherit (dotnetCorePackages) sdk_6_0; in -buildDotnetModule rec { +let finalPackage = buildDotnetModule rec { pname = "omnisharp-roslyn"; version = "1.39.1"; @@ -72,6 +74,43 @@ buildDotnetModule rec { rm $out/lib/omnisharp-roslyn/System.Configuration.ConfigurationManager.dll ''; + passthru.tests = { + no-sdk = runCommand "no-sdk" { nativeBuildInputs = [ finalPackage expect ]; meta.timeout = 60; } '' + HOME=$TMPDIR + expect <<"EOF" + spawn OmniSharp + expect_before timeout { + send_error "timeout!\n" + exit 1 + } + expect "\"ERROR\",\"Name\":\"OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider\"" + expect eof + catch wait result + if { [lindex $result 3] == 0 } { + exit 1 + } + EOF + touch $out + ''; + + with-sdk = runCommand "with-sdk" { nativeBuildInputs = [ finalPackage sdk_6_0 expect ]; meta.timeout = 60; } '' + HOME=$TMPDIR + expect <<"EOF" + spawn OmniSharp + expect_before timeout { + send_error "timeout!\n" + exit 1 + } + expect "{\"Event\":\"started\"," + send \x03 + expect eof + catch wait result + exit [lindex $result 3] + EOF + touch $out + ''; + }; + meta = with lib; { description = "OmniSharp based on roslyn workspaces"; homepage = "https://github.com/OmniSharp/omnisharp-roslyn"; @@ -83,4 +122,4 @@ buildDotnetModule rec { maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ]; mainProgram = "OmniSharp"; }; -} +}; in finalPackage