#217 closed defect (released)
Can't create a test database using two source files
Reported by: | Charlie Hull | Owned by: | New Bugs |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Test Suite | Version: | SVN trunk |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | Microsoft Windows |
Description
Various tests are failing on Windows because lines like this don't work:
api_anydb.cc, line 1235:
Xapian::Database mydb1(get_database("apitest_simpledata",
"apitest_simpledata2"));
which causes errors to be thrown by line 175 of index_utils.cc when trying to index the second file. Happens with all types of database. Sometimes reports file can't be found, sometimes 'No error'. The path used appears to be correct (we run in xapian-core\tests\, the path used is ".\testdata\apitest_simpledata2.txt").
Attachments (2)
Change History (15)
comment:1 by , 17 years ago
Summary: | Can't create a test database using two source files → Can't create a test database using two source files |
---|---|
Version: | 1.0.4 → SVN HEAD |
comment:2 by , 17 years ago
comment:3 by , 17 years ago
Status: | new → assigned |
---|
comment:4 by , 17 years ago
The definition of operator! on a stream is that it's the same as fail(), and fail() returning true means "next operation will fail".
Stroustrup actually includes an example (page 638 of the 3rd edition) which does this:
std::ifstream from(argv[1]); if (!from) error("[...]");
He clearly expects a stream which fails to open to set its fail bit. So I think MSVC is buggy here, but at least we have a work around.
comment:5 by , 17 years ago
attachments.isobsolete: | 0 → 1 |
---|
comment:6 by , 17 years ago
Is just adding "input.clear()" before "input.open()" a sufficient fix? It sounds to me like it should be. If so, I'd rather do the minimal fix.
comment:8 by , 17 years ago
I've committed the fix of using "is_open". Is that not sufficient? It's not clear to me from the comments on this and bug#218.
comment:9 by , 17 years ago
No, we still need to call input.clear(), otherwise the file can be opened but not read successfully. I recommend we do input.clear() then check is_open() and good() as in my patch.
comment:10 by , 17 years ago
Actually, your patch checks !fail() rather than good().
But I don't see any benefit in doing either. The clear() method with no parameters is defined as setting the good bit and clearing the others, so either check is superfluous, unless the C++ library is buggy. Do you have reason to think that MSVC's clear() method is buggy? If it is, then this fix isn't going to work anyway.
I've added a call to clear(), for now at least.
comment:13 by , 17 years ago
Resolution: | fixed → released |
---|
comment:14 by , 17 years ago
Blocking: | 200 removed |
---|---|
Operating System: | → Microsoft Windows |
I think you're going to need to investigate this - the code looks OK to me, and works on Linux.
Incidentally, I don't see how the path used can be ".\testdata\apitest_simpledata2.txt" - the code in indexutils.cc adds "/", so it should be something like ".\testdata/apitest_simpledata2.txt" or maybe "./testdata/apitest_simpledata2.txt" (which should work fine - the MS CRT allows "/" or "\" as directory separator).