views:

265

answers:

1

This is an output of Boost.Test when test case failes:

bjam toolset=msvc
...patience...
...found 1287 targets...
...updating 4 targets...
compile-c-c++ ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.obj
Function.cpp
msvc.link ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.exe
msvc.manifest ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.exe
testing.capture-output ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.run
====== BEGIN OUTPUT ======
Running 1 test case...
Function.cpp(26): fatal error in "FunctionConstruction": critical check pf->Name() == "F13" failed [F1 != F13]

*** 1 failure detected in test suite "foo_test"
Detected memory leaks!
Dumping objects ->
{235} normal block at 0x003A7C88, 32 bytes long.
 Data:  00 00 00 00 CD CD CD CD 54 31 00 CD CD CD CD CD 
{234} normal block at 0x003A7E00, 96 bytes long.
 Data:  00 00 00 00 CD CD CD CD 54 31 00 CD CD CD CD CD 
{233} normal block at 0x003A7D88, 76 bytes long.
 Data:  F4 D9 45 00 00 00 00 00 CD CD CD CD 00 7E 3A 00 
Object dump complete.

EXIT STATUS: 201 
====== END OUTPUT ======

MSVC parses this errors correctly so i can double click and jump to place in code. But emacs can't parse this output. How to teach it?

+3  A: 

The solution will involve customizing the variables: 'compilation-error-regexp-alist, 'compilation-error-regexp-alist-alist, 'compilation-directory-matcher.

The first, 'compilation-error-regexp-alist is just a list of symbols telling the compilation mode what to look up in the second variable `'compilation-error-regexp-alist-alist', so you'll probably just add something for boost:

(add-to-list 'compilation-error-regexp-alist 'boost)

Then, to make that work, you need to add a list to the second variable, 'compilation-error-regexp-alist-alist. This is where it starts to get tricky. You'll need to read the documentation for the first variable to get the regexp right, but it'll be something like:

(add-to-list 'compilation-error-regexp-alist-alist
         '(boost
           "^\\(.*\\)(\\([0-9]+\\)): fatal error in" 1 2))

The regexp matches the error line, and the 1 and 2 specify the sub expression specifying the filename and line number respectively. There are other things you can specify (see the documentation).

Though, to be honest, the above two settings are probably unnecessary as I'm pretty sure one of the existing regexps will match the format. The problem really exists with the directory tracking.

The last variable, `'compilation-directory-matcher' is the one that lets the next-error track where to find the files. So it needs to be updated appropriately. It doesn't look like the boost test spits out the somewhat standard "Entering directory ..." that Emacs looks for, but the information seems to be there in the compile line...

You might also try asking on the boost user mailing list to see if someone there has solved this problem. The mailing list can be found here.

Trey Jackson