From faf4e7b2dcf97ecf366113949d4d2f70a2e96d67 Mon Sep 17 00:00:00 2001 From: ckie Date: Tue, 31 Oct 2023 14:44:49 +0200 Subject: [PATCH] formats.libconfig: fix unstable store path dependency in test Previously, this test would verify a writeText file with a constant content is at a precise store path, but this is not actually the case and the store path has changed maybe twice since the original "pkgs.formats: Add libconfig format generator" PR was started, the latest time being after it was merged. We now placehold the store path in expected.txt and substitute it just before we run the diff, alleviating the problem. --- .../libconfig/test/comprehensive/default.nix | 14 +++++++------- .../libconfig/test/comprehensive/expected.txt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/default.nix b/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/default.nix index 3715e2e840d26..7b0df23ee6639 100644 --- a/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/default.nix +++ b/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/default.nix @@ -6,12 +6,9 @@ let val = 1; }; - include_file = (writeText "libconfig-test-include" '' + include_file = writeText "libconfig-test-include" '' val=1; - '').overrideAttrs { - outputHashAlgo = "sha256"; - outputHashMode = "flat"; - }; + ''; expression = { simple_top_level_attr = "1.0"; @@ -63,12 +60,15 @@ in doCheck = true; checkPhase = '' - diff -U3 ${./expected.txt} ${libconfig-test-cfg} + cp ${./expected.txt} expected.txt + substituteInPlace expected.txt \ + --subst-var-by include_file "${include_file}" + diff -U3 ./expected.txt ${libconfig-test-cfg} ''; installPhase = '' mkdir $out - cp ${./expected.txt} $out/expected.txt + cp expected.txt $out cp ${libconfig-test-cfg} $out/libconfig-test.cfg cp ${libconfig-test-cfg.passthru.json} $out/libconfig-test.json ''; diff --git a/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/expected.txt b/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/expected.txt index 3e9b1af821f18..ef6e09f8111a4 100644 --- a/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/expected.txt +++ b/pkgs/pkgs-lib/formats/libconfig/test/comprehensive/expected.txt @@ -1,6 +1,6 @@ array1d=[1, 5, 2];array2d=([1, 2], [2, 1]);list1d=(1, "mixed!", 5, 2);list2d=(1, (1, 1.2, "foo"), ("bar", 1.2, 1));nasty_string="\"@ \\ ^*bf 0\";'''$";nested={attrset={has={a={integer={value=100;};};};};};simple_top_level_attr="1.0";some_floaty=29.95;weirderTypes={ -@include "/nix/store/jdz5yhzbbj4j77yrr7l20x1cs4kbwkj2-libconfig-test-include" +@include "@include_file@" array_of_ints=[0732, 0xa3, 1234];bigint=9223372036854775807;float=0.0012;hex=0x1fc3;list_of_weird_types=(3.141592654, 9223372036854775807, 0x1fc3, 027, 1.2e-32, 1.0);octal=027;pi=3.141592654;};