Skip to main content



      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 09:25 Go to next message
Eclipse UserFriend
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 09:31] by Moderator

Re: xtext-utils - integration test failing, whitespace mismatch? [message #754608 is a reply to message #754604] Thu, 03 November 2011 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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

Alex
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754627 is a reply to message #754608] Thu, 03 November 2011 12:13 Go to previous messageGo to next message
Eclipse UserFriend
@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 12:58 Go to previous messageGo to next message
Eclipse UserFriend
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 13:42 Go to previous messageGo to next message
Eclipse UserFriend
@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 13:43 Go to previous messageGo to next message
Eclipse UserFriend
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 14:57 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Christian Smile
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754671 is a reply to message #754604] Thu, 03 November 2011 15:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: xtext-utils - integration test failing, whitespace mismatch? [message #754672 is a reply to message #754671] Thu, 03 November 2011 16:02 Go to previous messageGo to next message
Eclipse UserFriend
I have extended the documentation a bit.

http://code.google.com/a/eclipselabs.org/p/xtext-utils/wiki/Unit_Testing
Re: xtext-utils - integration test failing, whitespace mismatch? [message #1003230 is a reply to message #754672] Sun, 20 January 2013 12:50 Go to previous message
Eclipse UserFriend
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: Sat Jul 12 15:02:34 EDT 2025

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

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

Back to the top