lib.fileset: Minor changes
- Make fromSource's missing file error message more consistent with others, and add a test for it - Indent some function arguments - Fix an internal type
This commit is contained in:
parent
d3deaacfb4
commit
b514f0433c
@ -263,7 +263,7 @@ in {
|
|||||||
lib.fileset.fromSource: The source origin of the argument is of type ${typeOf path}, but it should be a path instead.''
|
lib.fileset.fromSource: The source origin of the argument is of type ${typeOf path}, but it should be a path instead.''
|
||||||
else if ! pathExists path then
|
else if ! pathExists path then
|
||||||
throw ''
|
throw ''
|
||||||
lib.fileset.fromSource: The source origin (${toString path}) of the argument does not exist.''
|
lib.fileset.fromSource: The source origin (${toString path}) of the argument is a path that does not exist.''
|
||||||
else if isFiltered then
|
else if isFiltered then
|
||||||
_fromSourceFilter path source.filter
|
_fromSourceFilter path source.filter
|
||||||
else
|
else
|
||||||
|
@ -381,7 +381,7 @@ rec {
|
|||||||
|
|
||||||
# Turn a fileset into a source filter function suitable for `builtins.path`
|
# Turn a fileset into a source filter function suitable for `builtins.path`
|
||||||
# Only directories recursively containing at least one files are recursed into
|
# Only directories recursively containing at least one files are recursed into
|
||||||
# Type: Path -> fileset -> (String -> String -> Bool)
|
# Type: fileset -> (String -> String -> Bool)
|
||||||
_toSourceFilter = fileset:
|
_toSourceFilter = fileset:
|
||||||
let
|
let
|
||||||
# Simplify the tree, necessary to make sure all empty directories are null
|
# Simplify the tree, necessary to make sure all empty directories are null
|
||||||
|
@ -1064,13 +1064,18 @@ rm -rf -- *
|
|||||||
## lib.fileset.fromSource
|
## lib.fileset.fromSource
|
||||||
|
|
||||||
# Check error messages
|
# Check error messages
|
||||||
expectFailure 'fromSource null' 'lib.fileset.fromSource: The source origin of the argument is of type null, but it should be a path instead.'
|
|
||||||
|
|
||||||
|
# String-like values are not supported
|
||||||
expectFailure 'fromSource (lib.cleanSource "")' 'lib.fileset.fromSource: The source origin of the argument is a string-like value \(""\), but it should be a path instead.
|
expectFailure 'fromSource (lib.cleanSource "")' 'lib.fileset.fromSource: The source origin of the argument is a string-like value \(""\), but it should be a path instead.
|
||||||
\s*Sources created from paths in strings cannot be turned into file sets, use `lib.sources` or derivations instead.'
|
\s*Sources created from paths in strings cannot be turned into file sets, use `lib.sources` or derivations instead.'
|
||||||
|
|
||||||
|
# Wrong type
|
||||||
|
expectFailure 'fromSource null' 'lib.fileset.fromSource: The source origin of the argument is of type null, but it should be a path instead.'
|
||||||
expectFailure 'fromSource (lib.cleanSource null)' 'lib.fileset.fromSource: The source origin of the argument is of type null, but it should be a path instead.'
|
expectFailure 'fromSource (lib.cleanSource null)' 'lib.fileset.fromSource: The source origin of the argument is of type null, but it should be a path instead.'
|
||||||
|
|
||||||
|
# fromSource on non-existent paths gives an error
|
||||||
|
expectFailure 'fromSource ./a' 'lib.fileset.fromSource: The source origin \('"$work"'/a\) of the argument is a path that does not exist.'
|
||||||
|
|
||||||
# fromSource on a path works and is the same as coercing that path
|
# fromSource on a path works and is the same as coercing that path
|
||||||
mkdir a
|
mkdir a
|
||||||
touch a/b c
|
touch a/b c
|
||||||
|
Loading…
Reference in New Issue
Block a user