Fix rblf_file_exists, it should return true for a directory, too.

Fixes: 184278019
Test: internal
Change-Id: I68c3274a4540dd36e047d6c2027766dbe75d38f8
This commit is contained in:
Sasha Smundak
2021-08-05 17:33:15 -07:00
parent 4cc80241d3
commit 3c569799ca
2 changed files with 2 additions and 1 deletions

View File

@@ -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

View File

@@ -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")