@@ -0,0 +1,45 @@
1+{ runCommand, postcss-cli }:
2+
3+let
4+ inherit (postcss-cli) packageName version;
5+in
6+
7+runCommand "${packageName}-tests" { meta.timeout = 60; }
8+ ''
9+ # get version of installed program and compare with package version
10+ claimed_version="$(${postcss-cli}/bin/postcss --version)"
11+ if [[ "$claimed_version" != "${version}" ]]; then
12+ echo "Error: program version does not match package version ($claimed_version != ${version})"
13+ exit 1
14+ fi
15+
16+ # run basic help command
17+ ${postcss-cli}/bin/postcss --help > /dev/null
18+
19+ # basic autoprefixer test
20+ config_dir="$(mktemp -d)"
21+ clean_up() {
22+ rm -rf "$config_dir"
23+ }
24+ trap clean_up EXIT
25+ echo "
26+ module.exports = {
27+ plugins: {
28+ 'autoprefixer': { overrideBrowserslist: 'chrome 40' },
29+ },
30+ }
31+ " > "$config_dir/postcss.config.js"
32+ input='a{ user-select: none; }'
33+ expected_output='a{ -webkit-user-select: none; user-select: none; }'
34+ actual_output="$(echo $input | ${postcss-cli}/bin/postcss --no-map --config $config_dir)"
35+ if [[ "$actual_output" != "$expected_output" ]]; then
36+ echo "Error: autoprefixer did not output the correct CSS:"
37+ echo "$actual_output"
38+ echo "!="
39+ echo "$expected_output"
40+ exit 1
41+ fi
42+
43+ # needed for Nix to register the command as successful
44+ touch $out
45+ ''