#7130 closed defect (fixed)

FileSystem.Read() error is not handled

Reported by: asmirnov Assignee:
Priority: P2 Milestone:
Module: Libadblockplus Keywords:
Cc: sergz Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://gitlab.com/eyeo/adblockplus/libadblockplus/merge_requests/31

Description

Environment

libadblockplus has FileSystem abstraction.
Read() call can result in error callback called:
https://gitlab.com/eyeo/adblockplus/libadblockplus/blob/master/include/AdblockPlus/IFileSystem.h#L85

There is a test for this (read with error):
https://gitlab.com/eyeo/adblockplus/libadblockplus/blob/master/test/FileSystemJsObject.cpp#L154

However it does not check if error is equal to undefined, but just checks if it's not equal to empty string.
The affected revision of libadblockplus is f2df538b1d66b982fba18a0bc36cf27c1b3bc716 and the most recent most likely.

How to reproduce

  1. Modify the test as follows:
    $git diff
    diff --git a/test/FileSystemJsObject.cpp b/test/FileSystemJsObject.cpp
    index 051febd..c2ca271 100644
    --- a/test/FileSystemJsObject.cpp
    +++ b/test/FileSystemJsObject.cpp
    @@ -158,6 +158,7 @@ TEST_F(FileSystemJsObjectTest, ReadError)
       std::string error;
       ReadFile(GetJsEngine(), content, error);
       ASSERT_NE("", error);
    +  ASSERT_NE("undefined", error);
       ASSERT_EQ("undefined", content);
     }
    
  2. Run the test with make test FILTER=FileSystemJsObject*
  3. Make sure the test fails

Observed behaviour

The test fails: error is equal to undefined.

Expected behaviour

The test does not fail and error is not equal to undefined.

Change History (2)

comment:1 Changed 12 months ago by sergz

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 12 months ago by sergz

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.