Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#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)

patch17.patch (402 bytes ) - added by Charlie Hull 16 years ago.
Need to check input.is_open(), not just input
patch18.patch (514 bytes ) - added by Charlie Hull 16 years ago.
Clear the state of input() before reusing

Download all attachments as: .zip

Change History (15)

comment:1 by Charlie Hull, 16 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.4SVN HEAD

comment:2 by Olly Betts, 16 years ago

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).

comment:3 by Charlie Hull, 16 years ago

Status: newassigned

comment:4 by Olly Betts, 16 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.

by Charlie Hull, 16 years ago

Attachment: patch18.patch added

Need to check input.is_open(), not just input

comment:5 by Charlie Hull, 16 years ago

attachments.isobsolete: 01

comment:6 by Richard Boulton, 16 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:7 by Richard Boulton, 16 years ago

* Bug 218 has been marked as a duplicate of this bug. *

comment:8 by Olly Betts, 16 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 Charlie Hull, 16 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 Olly Betts, 16 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:11 by Olly Betts, 16 years ago

Blocking: 200 added

Is this fixed in SVN HEAD?

comment:12 by Charlie Hull, 16 years ago

Resolution: fixed
Status: assignedclosed

Yes, all fixed.

comment:13 by Olly Betts, 16 years ago

Resolution: fixedreleased

comment:14 by Olly Betts, 16 years ago

Blocking: 200 removed
Operating System: Microsoft Windows
Note: See TracTickets for help on using tickets.