Fix rblf_file_exists, it should return true for a directory, too.
Fixes: 184278019 Test: internal Change-Id: I68c3274a4540dd36e047d6c2027766dbe75d38f8
This commit is contained in:
@@ -118,7 +118,7 @@ func fileExists(_ *starlark.Thread, b *starlark.Builtin, args starlark.Tuple,
|
||||
if err := starlark.UnpackPositionalArgs(b.Name(), args, kwargs, 1, &path); err != nil {
|
||||
return starlark.None, err
|
||||
}
|
||||
if stat, err := os.Stat(path); err != nil || stat.IsDir() {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return starlark.False, nil
|
||||
}
|
||||
return starlark.True, nil
|
||||
|
1
tools/rbcrun/testdata/file_ops.star
vendored
1
tools/rbcrun/testdata/file_ops.star
vendored
@@ -4,6 +4,7 @@ load("assert.star", "assert")
|
||||
|
||||
def test():
|
||||
myname = "file_ops.star"
|
||||
assert.true(rblf_file_exists("."), "./ exists ")
|
||||
assert.true(rblf_file_exists(myname), "the file %s does exist" % myname)
|
||||
assert.true(not rblf_file_exists("no_such_file"), "the file no_such_file does not exist")
|
||||
files = rblf_wildcard("*.star")
|
||||
|
Reference in New Issue
Block a user