Ensure nil is accepted as FS config (#1182)
In previous releases, passing a `nil` value as an FS config
did not cause any error. However, in 1.0.0-rc.1 this leads
to the creation of an invalid `adapter{fs: nil}`, which
eventually leads to a panic (nil):
(f *FileEntry) Stat(st *platform.Stat_t) =>
(r *lazyDir) file() =>
r.fs.OpenFile(".", os.O_RDONLY, 0)
with fs == nil
The backwards-compatible fix is to make Adapt()
return UnimplementedFS, and ensuring `nil` is a valid value
that config is able to handle.
However, we may want to consider returning an error somewhere,
because configuring a nil FS may be unintended.
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
@@ -360,6 +360,24 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
sysfs.Adapt(testFS2), // fs
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "WithFS nil",
|
||||
input: base.WithFS(nil),
|
||||
expected: requireSysContext(t,
|
||||
math.MaxUint32, // max
|
||||
nil, // args
|
||||
nil, // environ
|
||||
nil, // stdin
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
nil, // randSource
|
||||
&wt, 1, // walltime, walltimeResolution
|
||||
&nt, 1, // nanotime, nanotimeResolution
|
||||
nil, // nanosleep
|
||||
nil, // osyield
|
||||
nil, // fs
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "WithRandSource",
|
||||
input: base.WithRandSource(rand.Reader),
|
||||
|
||||
Reference in New Issue
Block a user