Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext-utils - integration test failing, whitespace mismatch?
xtext-utils - integration test failing, whitespace mismatch? [message #754604] Thu, 03 November 2011 13:25 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 83
Registered: October 2011
Member
Integration test failing and I'm not sure why. Error is:

org.junit.ComparisonFailure: expected:<Domain "Banking" {[]}> but was:<Domain "Banking" {[ ]}>

So only difference appears to be whitespace?

The source file was created using the generated xtext editor and shows no validation errors in the IDE. Here's the file:

Domain "Banking" {}


And the relevant grammar rule:

Domain:
	'Domain' name=String '{'
	(elements+=ModelElement)*
	'}';


The test passes if I change the input to:

Domain "Banking" { }


i.e. add space between braces...?

thx.


[Updated on: Thu, 03 November 2011 13:31]

Report message to a moderator

Re: xtext-utils - integration test failing, whitespace mismatch? [message #754608 is a reply to message #754604] Thu, 03 November 2011 13:56 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1159
Registered: July 2009
Senior Member
Hi,

if you want two things to be identical, they have to be. The test does not check semantic equivalence.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754627 is a reply to message #754608] Thu, 03 November 2011 16:13 Go to previous messageGo to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 83
Registered: October 2011
Member
@Alexander: point is that you don't specify in the test what to compare against.

Xtest-utils must generate the comparison string in the background. Net result is that a valid input file fails - because the auto-generated file includes different whitespace. So the test fails even though the input file is valid.

Easy enough to fix for the simple example above, but not practical for real examples.

Unless i'm missing something...?

Re: xtext-utils - integration test failing, whitespace mismatch? [message #754635 is a reply to message #754627] Thu, 03 November 2011 16:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6492
Registered: July 2009
Senior Member
Did you use the formatter on your file in the editor?

~Christian
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754640 is a reply to message #754635] Thu, 03 November 2011 17:42 Go to previous messageGo to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 83
Registered: October 2011
Member
@Christian - thanks, that works. Although the 'formatter' seems to remove all formatting, resulting in a single string with no cr/lf etc. So OK for creating test input that works but not for readable test data... Sad

However I can work around that, just means keeping a 'formatted' and readable version of the file. Thanks for the suggestion.

- S.
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754642 is a reply to message #754640] Thu, 03 November 2011 17:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6492
Registered: July 2009
Senior Member
Hi,

you can "adjust" formatting Wink
see the generated yourdslFormatter class.

~Christian
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754654 is a reply to message #754642] Thu, 03 November 2011 18:57 Go to previous messageGo to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 83
Registered: October 2011
Member
Thanks Christian Smile
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754671 is a reply to message #754604] Thu, 03 November 2011 19:54 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 359
Registered: July 2009
Location: Dortmund
Senior Member

And you can disable formatting comparison by calling
ignoreFormattingDifferences();

in a @Before method.

The integration test *does* test that everything is as expected, including every whitespace. Since this is the only way to test the formatter.

~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754672 is a reply to message #754671] Thu, 03 November 2011 20:02 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 359
Registered: July 2009
Location: Dortmund
Senior Member

I have extended the documentation a bit.

http://code.google.com/a/eclipselabs.org/p/xtext-utils/wiki/Unit_Testing


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: xtext-utils - integration test failing, whitespace mismatch? [message #1003230 is a reply to message #754672] Sun, 20 January 2013 17:50 Go to previous message
Nathan M is currently offline Nathan MFriend
Messages: 5
Registered: January 2013
Junior Member
The problem I am having is the when running the test, the formatter is using the default one (IIndentationInformation.Default) which always uses a literal tab character. But the actual default xtext implementation is PreferenceStoreIndentationInformation.java, which uses the eclipse preference. So the eclipse preference can be set to use spaces, and so the test file gets formatted as such, but then the serialization comparison fails because it's expecting a tab instead of spaces.
So is there a way to make the formatter used in the test use the PreferenceStoreIndentationInformation class instead?
Previous Topic:Limiting scoped elements, but allowing simple names to be used
Next Topic:problem running a xtext file
Goto Forum:
  


Current Time: Mon Nov 24 22:50:39 GMT 2014

Powered by FUDForum. Page generated in 0.01799 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software