depot/third_party/nixpkgs/pkgs/build-support/trivial-builders/test/writeShellApplication.nix
Default email 2c76a4cb41 Project import generated by Copybara.
GitOrigin-RevId: c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad
2023-11-16 04:20:00 +00:00

29 lines
686 B
Nix

/*
Run with:
cd nixpkgs
nix-build -A tests.trivial-builders.writeShellApplication
*/
{ lib, writeShellApplication, runCommand }:
let
pkg = writeShellApplication {
name = "test-script";
excludeShellChecks = [ "SC2016" ];
text = ''
echo -e '#!/usr/bin/env bash\n' \
'echo "$SHELL"' > /tmp/something.sh # this line would normally
# ...cause shellcheck error
'';
};
in
assert pkg.meta.mainProgram == "test-script";
runCommand "test-writeShellApplication" { } ''
echo Testing if writeShellApplication builds without shellcheck error...
target=${lib.getExe pkg}
touch $out
''