From 5bbe67bf67b5728bf2c0ed8228853c661a39606d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 26 Sep 2023 19:12:58 +0200 Subject: lib.fileset: Mention trace functions in the file set evaluation error --- lib/fileset/README.md | 1 - lib/fileset/internal.nix | 4 +++- lib/fileset/tests.sh | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/fileset/README.md b/lib/fileset/README.md index 2ef7b81e8850..d4c80e9433e4 100644 --- a/lib/fileset/README.md +++ b/lib/fileset/README.md @@ -207,6 +207,5 @@ Here's a list of places in the library that need to be updated in the future: - > The file set library is currently somewhat limited but is being expanded to include more functions over time. in [the manual](../../doc/functions/fileset.section.md) -- Once a tracing function exists, `__noEval` in [internal.nix](./internal.nix) should mention it - If/Once a function to convert `lib.sources` values into file sets exists, the `_coerce` and `toSource` functions should be updated to mention that function in the error when such a value is passed - If/Once a function exists that can optionally include a path depending on whether it exists, the error message for the path not existing in `_coerce` should mention the new function diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index ebfe69b010de..d18e37e9d6e6 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -106,7 +106,9 @@ rec { ]; _noEvalMessage = '' - lib.fileset: Directly evaluating a file set is not supported. Use `lib.fileset.toSource` to turn it into a usable source instead.''; + lib.fileset: Directly evaluating a file set is not supported. + To turn it into a usable source, use `lib.fileset.toSource`. + To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.''; # The empty file set without a base path _emptyWithoutBase = { diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index 80fa21961ffb..6c6379d07349 100755 --- a/lib/fileset/tests.sh +++ b/lib/fileset/tests.sh @@ -327,8 +327,12 @@ expectFailure 'toSource { root = ./.; fileset = "/some/path"; }' 'lib.fileset.to expectFailure 'toSource { root = ./.; fileset = ./a; }' 'lib.fileset.toSource: `fileset` \('"$work"'/a\) does not exist.' # File sets cannot be evaluated directly -expectFailure 'union ./. ./.' 'lib.fileset: Directly evaluating a file set is not supported. Use `lib.fileset.toSource` to turn it into a usable source instead.' -expectFailure '_emptyWithoutBase' 'lib.fileset: Directly evaluating a file set is not supported. Use `lib.fileset.toSource` to turn it into a usable source instead.' +expectFailure 'union ./. ./.' 'lib.fileset: Directly evaluating a file set is not supported. +\s*To turn it into a usable source, use `lib.fileset.toSource`. +\s*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.' +expectFailure '_emptyWithoutBase' 'lib.fileset: Directly evaluating a file set is not supported. +\s*To turn it into a usable source, use `lib.fileset.toSource`. +\s*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.' # Past versions of the internal representation are supported expectEqual '_coerce ": value" { _type = "fileset"; _internalVersion = 0; _internalBase = ./.; }' \ -- cgit 1.4.1