about summary refs log tree commit diff
path: root/pkgs/test/dotnet/structured-attrs/default.nix
blob: cf96fef8dbdcce25034185ace9a74ba63c7b9a29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ lib
, dotnet-sdk
, buildPackages # buildDotnetModule
, testers
, runCommand
}:
let
  # Note: without structured attributes, we can’t use derivation arguments that
  # contain spaces unambiguously because arguments are passed as space-separated
  # environment variables.
  copyrightString = "Public domain 🅮";

  inherit (buildPackages) buildDotnetModule;

  app = buildDotnetModule {
    name = "structured-attrs-test-application";
    src = ./src;
    nugetDeps = ./nuget-deps.nix;
    dotnetFlags = [ "--property:Copyright=${copyrightString}" ];
    env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
    __structuredAttrs = true;
  };
in
{
  no-structured-attrs = testers.testBuildFailure (app.overrideAttrs {
    __structuredAttrs = false;
  });

  check-output = testers.testEqualContents {
    assertion = "buildDotnetModule sets AssemblyCopyrightAttribute with structured attributes";
    expected = builtins.toFile "expected-copyright.txt" copyrightString;
    actual = runCommand "dotnet-structured-attrs-test" { } ''
      ${app}/bin/Application >"$out"
    '';
  };
}