mirror of
https://github.com/NixOS/nix.git
synced 2025-12-11 19:41:04 +01:00
Make nix path-info follow the JSON guildelines
This commit is contained in:
parent
1ad13a1423
commit
5f73c6b416
9 changed files with 65 additions and 30 deletions
|
|
@ -4,36 +4,44 @@ source common.sh
|
|||
|
||||
echo foo > "$TEST_ROOT"/foo
|
||||
foo=$(nix store add-file "$TEST_ROOT"/foo)
|
||||
fooBase=$(basename "$foo")
|
||||
|
||||
echo bar > "$TEST_ROOT"/bar
|
||||
bar=$(nix store add-file "$TEST_ROOT"/bar)
|
||||
barBase=$(basename "$bar")
|
||||
|
||||
echo baz > "$TEST_ROOT"/baz
|
||||
baz=$(nix store add-file "$TEST_ROOT"/baz)
|
||||
bazBase=$(basename "$baz")
|
||||
nix-store --delete "$baz"
|
||||
|
||||
diff --unified --color=always \
|
||||
<(nix path-info --json --json-format 2 "$foo" "$bar" "$baz" |
|
||||
jq --sort-keys 'map_values(.narHash)') \
|
||||
jq --sort-keys '.info | map_values(.narHash)') \
|
||||
<(jq --sort-keys <<-EOF
|
||||
{
|
||||
"$foo": {
|
||||
"$fooBase": {
|
||||
"algorithm": "sha256",
|
||||
"format": "base16",
|
||||
"hash": "42fb4031b525feebe2f8b08e6e6a8e86f34e6a91dd036ada888e311b9cc8e690"
|
||||
},
|
||||
"$bar": {
|
||||
"$barBase": {
|
||||
"algorithm": "sha256",
|
||||
"format": "base16",
|
||||
"hash": "f5f8581aef5fab17100b629cf35aa1d91328d5070b054068f14fa93e7fa3b614"
|
||||
},
|
||||
"$baz": null
|
||||
"$bazBase": null
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
# Test that storeDir is returned in the JSON output
|
||||
# Test that storeDir is returned in the JSON output in individual store objects
|
||||
nix path-info --json --json-format 2 "$foo" | jq -e \
|
||||
--arg foo "$foo" \
|
||||
--arg fooBase "$fooBase" \
|
||||
--arg storeDir "${NIX_STORE_DIR:-/nix/store}" \
|
||||
'.[$foo].storeDir == $storeDir'
|
||||
'.info[$fooBase].storeDir == $storeDir'
|
||||
|
||||
# And also at the top -evel
|
||||
echo | nix path-info --json --json-format 2 --stdin | jq -e \
|
||||
--arg storeDir "${NIX_STORE_DIR:-/nix/store}" \
|
||||
'.storeDir == $storeDir'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue