Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Testing code generation (ComparisonFailure : expected : [ "char Sequence"] but was: <[NO FILE WAS GENERATED]>)
Testing code generation [message #1815818] Fri, 11 October 2019 06:35 Go to next message
Eclipse UserFriend
Hi there,

i try to test code generator, but i am getting following Failure.

org.junit.ComparisonFailure: expected:<[<Hello World ;-)>
]> but was:<[NO FILE WAS GENERATED]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at org.eclipse.xtext.xbase.testing.CompilationTestHelper$1.accept(CompilationTestHelper.java:178)
at org.eclipse.xtext.xbase.testing.CompilationTestHelper$1.accept(CompilationTestHelper.java:175)
at org.eclipse.xtext.xbase.testing.CompilationTestHelper.compile(CompilationTestHelper.java:247)
at org.eclipse.xtext.xbase.testing.CompilationTestHelper.compile(CompilationTestHelper.java:196)
at org.eclipse.xtext.xbase.testing.CompilationTestHelper.assertCompilesTo(CompilationTestHelper.java:175)

how can i fix it?

Any help is appreciated

Thanks
Re: Testing code generation [message #1815975 is a reply to message #1815818] Wed, 16 October 2019 08:44 Go to previous messageGo to next message
Eclipse UserFriend
hi,

can you give more information about what you are exactly doing?
Re: Testing code generation [message #1817021 is a reply to message #1815975] Thu, 14 November 2019 03:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

thanks for your reply,

i have moved the generator of my language in an own plugin.
After moving ,the generator works without any problem but during testing the generator can't find generated file and i become failure "NO FILE WAS GENERATED"

do you have any idea how to fix it?
Re: Testing code generation [message #1817031 is a reply to message #1817021] Thu, 14 November 2019 05:24 Go to previous messageGo to next message
Eclipse UserFriend
how does Xtext / the test know about your changes to the generator?
Re: Testing code generation [message #1817037 is a reply to message #1817031] Thu, 14 November 2019 08:01 Go to previous messageGo to next message
Eclipse UserFriend
here are the steps, how i did it
1. I have created three additional plugins: One for the runtime part of the generator, one for the UI contributions and one for Tests
2. Moved everything from the .generator subpackage of my DSL runtime project to the generator plugin (The dependencies are the same as in the DSL runtime project, but added the DSL runtime plugin as additional dependency)
3.Added an xtend-gen source folder to the project
4.Created a Module class extending AbstractGenericModule in the runtime plugin
5. bind UI part
created module class extending AbstractGenericModule and binded JavaProjectBasedBuilderParticipant:
6. created Activator class , which creates a Guice injector from the modules
DSL runtime module
org.eclipse.xtext.ui.shared.SharedStateModule
DSL UI module
Generator runtime module
Generator UI module
7. created ExecutableExtensionFactory
8. added plugin.xml
9. removed GeneratorFragment from .mwe2 workflow of my DSL project
but i don't know how to bind my Tests project with runtime project, i f i should bind it
Re: Testing code generation [message #1817041 is a reply to message #1817037] Thu, 14 November 2019 09:14 Go to previous messageGo to next message
Eclipse UserFriend
yes but this is for eclipse only. so for standalone you would need to customize the compilation test helper
to know your custom generator
or to have a different IGenerator that can load additional generators e.g. with service loaders
in standalone usecase
Re: Testing code generation [message #1817078 is a reply to message #1817041] Fri, 15 November 2019 02:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian ,
thanks for you feedback,

Now i have added TestStandaloneSetup.java to my tests project with following context

public class TestStandaloneSetup extends MyDslStandaloneSetupGenerated {
public static void doSetup() {
new TestStandaloneSetup().createInjectorAndDoEMFRegistration();
}

}
is that what you meant?

Re: Testing code generation [message #1817079 is a reply to message #1817078] Fri, 15 November 2019 03:13 Go to previous messageGo to next message
Eclipse UserFriend
no

your runtime module registers a generator that is empty now.
=> nothing is generated

=> either you need for standalone and test usecase a different module that has a generator that knows your external generators (explicitely or loading via service loader) and have a empty generator in ui module only.
=> or you teach your standalone usecase to call your external generators directly
Re: Testing code generation [message #1817081 is a reply to message #1817079] Fri, 15 November 2019 03:58 Go to previous messageGo to next message
Eclipse UserFriend
I'm new in Xtext world

can yo give me please some tips how to do it
Re: Testing code generation [message #1817084 is a reply to message #1817081] Fri, 15 November 2019 04:52 Go to previous messageGo to next message
Eclipse UserFriend
i dont know what you have done in the first place.

=> create a new MyDslRuntimeModule2
=> let it extend from MyDslRuntimeModule
=> override bindIGenerator2 and return your custom generator class
=> create a Custom MyDslStandalone setup and customize
public Injector createInjector() {
return Guice.createInjector(new MyDslRuntimeModule());
}
to use your new module
create a custom injector provider
with
org.xtext.example.mydsl1.tests.MyDslInjectorProvider.createRuntimeModule()
overriden to use your module.
and use the new injector provider in your test

(or simply undo the generator in separate module thing)
Re: Testing code generation [message #1817090 is a reply to message #1817084] Fri, 15 November 2019 05:57 Go to previous messageGo to next message
Eclipse UserFriend
Thanks a lot Christian,

I'll try it
Re: Testing code generation [message #1817102 is a reply to message #1817084] Fri, 15 November 2019 09:35 Go to previous messageGo to next message
Eclipse UserFriend
I tried it but it didn't work
maybe i did it wrong
please could you check my code out?
Re: Testing code generation [message #1817104 is a reply to message #1817084] Fri, 15 November 2019 09:39 Go to previous messageGo to next message
Eclipse UserFriend
Here is UI Part

Thank you very much in advance for your answer!
Re: Testing code generation [message #1817107 is a reply to message #1817104] Fri, 15 November 2019 09:52 Go to previous messageGo to next message
Eclipse UserFriend
please provide a sample github/lab repo

[Updated on: Fri, 15 November 2019 09:52] by Moderator

Re: Testing code generation [message #1817190 is a reply to message #1817107] Mon, 18 November 2019 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,
I have uploaded my Project to Github,

here is repository URL

https://github.com/nasri25/MyDsl.git

thank you very much in advance
Re: Testing code generation [message #1817202 is a reply to message #1817190] Mon, 18 November 2019 08:58 Go to previous messageGo to next message
Eclipse UserFriend
where is your subclass of MyDslRuntimeModule?

https://github.com/nasri25/MyDsl/pull/1
Re: Testing code generation [message #1817203 is a reply to message #1817202] Mon, 18 November 2019 09:03 Go to previous messageGo to next message
Eclipse UserFriend
Do you mean MyDslRuntimeModule2?
Re: Testing code generation [message #1817205 is a reply to message #1817203] Mon, 18 November 2019 09:18 Go to previous messageGo to next message
Eclipse UserFriend
I think you mean this

public Class<? extends org.eclipse.xtext.generator.IGenerator2> bindIGenerator() {
return MyDslGenerator.class;

do i need this part?
Re: Testing code generation [message #1817208 is a reply to message #1817205] Mon, 18 November 2019 09:50 Go to previous messageGo to next message
Eclipse UserFriend
i did a pr to your repo.
the injector and thus the module used by the injector provider needs to know your generator

(still the question: what is your deploymentconcept / reasoning behind moving to own generator)
looks like you dont address the standalone / test case there in general
Re: Testing code generation [message #1817212 is a reply to message #1817208] Mon, 18 November 2019 10:12 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much Christian,

it works, but why we need MyDslRuntimeModuleWithGen in tests? Usually, i can test my Generator within my DSL without adding any extra RuntimeModule to tests.

Answer your question: as I have already mentioned , I am very new in xtext world and i have read on internet , that is not good idea to have the generator bundled with your language

what do you think is it right?
Re: Testing code generation [message #1817213 is a reply to message #1817212] Mon, 18 November 2019 10:16 Go to previous messageGo to next message
Eclipse UserFriend
here is reasoning from the Artikel

One of the nice things that you get when starting an Xtext project is an Xtend based generator that is automatically invoked when you save an Xtext model file. The Xtend generator for your language resides in the .generator subpackage of your language. The problem with that is that it is usually no good idea to have the generator bundled with your language. It is a completely seperate feature which is reasonable to put it in an own plugin. Further, the DSL plugins must not depend on the generator plugin, the dependency must be vice versa. This article describes the steps that need to be done for this.
Re: Testing code generation [message #1817215 is a reply to message #1817213] Mon, 18 November 2019 10:50 Go to previous messageGo to next message
Eclipse UserFriend
yes. but it looks like the article addresses the eclipse aspect only and does not
the standalone and test.

do you plan to build your dsl projects outside eclipse (e.g. maven, gradle, own tool ...)
Re: Testing code generation [message #1817216 is a reply to message #1817215] Mon, 18 November 2019 10:51 Go to previous messageGo to next message
Eclipse UserFriend
the problem is:

nobody tells the test that you moved the geratator to somewhere
=> you have to call it explicitely

either the way i gave or build a custom solution
Re: Testing code generation [message #1817218 is a reply to message #1817215] Mon, 18 November 2019 11:10 Go to previous messageGo to next message
Eclipse UserFriend
yes, in the next step, i plan to build my projects with maven
Re: Testing code generation [message #1817219 is a reply to message #1817218] Mon, 18 November 2019 11:11 Go to previous messageGo to next message
Eclipse UserFriend
just to make sure: the project that contains the .yourdsl files?
Re: Testing code generation [message #1817220 is a reply to message #1817219] Mon, 18 November 2019 11:14 Go to previous messageGo to next message
Eclipse UserFriend
no, i have other project, mydsl was only example
Re: Testing code generation [message #1817221 is a reply to message #1817220] Mon, 18 November 2019 11:18 Go to previous messageGo to next message
Eclipse UserFriend
let me rephrase:
do you want to invoke your codegenerator from maven
Re: Testing code generation [message #1817224 is a reply to message #1817221] Mon, 18 November 2019 11:25 Go to previous messageGo to next message
Eclipse UserFriend
yes
Re: Testing code generation [message #1817225 is a reply to message #1817224] Mon, 18 November 2019 11:28 Go to previous messageGo to next message
Eclipse UserFriend
then you need to have a module like the one i have you too to tell the xtext-maven-plugin what the generator is.
Re: Testing code generation [message #1817257 is a reply to message #1817225] Tue, 19 November 2019 08:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian, how are you doing?
I've got one more question
Now i want to build my Generator project with maven
here are steps ,

1. created xtext project with maven and got following projects

org.eclipse.MyDsl.gen.parent
org.eclipse.MyDsl.gen
org.eclipse.MyDsl.gen.ide
org.eclipse.MyDsl.gen.ui
org.eclipse.MyDsl..genfeature
org.eclipse.MyDsl.gen.repository
org.eclipse.MyDsl.gen.target
org.eclipse.MyDsl.gen.ui.tests
org.eclipse.MyDsl.gen.tests

I have moved src folder of my generator(runtime) to org.eclipse.MyDsl.gen
and generator Tests to org.eclipse.MyDsl.gen.tests and generator UI to org.eclipse.MyDsl.gen.ui

evrything works but my question is , do I need all these .ide , . feature and . repository subpackages? or should i just delete it

another possibility would be, create a simple parent project and add my generator projects( runtime, ui and tests) as Module to the Parent
Re: Testing code generation [message #1817260 is a reply to message #1817257] Tue, 19 November 2019 08:28 Go to previous messageGo to next message
Eclipse UserFriend
ide is needed by ui
feature and repository is used to create an update site you can install your plugins to eclipse from
Re: Testing code generation [message #1817264 is a reply to message #1817260] Tue, 19 November 2019 09:33 Go to previous messageGo to next message
Eclipse UserFriend
thank you very much
Re: Testing code generation [message #1817303 is a reply to message #1817260] Wed, 20 November 2019 04:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian, one more question, do know about franca framework?
Re: Testing code generation [message #1817304 is a reply to message #1817303] Wed, 20 November 2019 04:42 Go to previous messageGo to next message
Eclipse UserFriend
in general yes.
i also know they do a lot in an unusual way
but i think for questions you should use their github issues
Re: Testing code generation [message #1817305 is a reply to message #1817304] Wed, 20 November 2019 04:47 Go to previous messageGo to next message
Eclipse UserFriend
thank you
Re: Testing code generation [message #1817452 is a reply to message #1817225] Fri, 22 November 2019 06:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Now, i have build my projects in maven

MyDsl.parent
MyDsl,gen.parent(Generator)
MySecondDsl.parent
MySecondDsl.gen.parent(Generator)

I know, that each project can have only one parent , but can be this parent part of a bigger parent hierarchy?

each of these projects hava a target definition ( e.g MyDsl.target), can i have only one target definiton for all these projects ( maybe under bigger parent)?
Re: Testing code generation [message #1817453 is a reply to message #1817452] Fri, 22 November 2019 06:35 Go to previous messageGo to next message
Eclipse UserFriend
could you please give me some tips
Re: Testing code generation [message #1817456 is a reply to message #1817453] Fri, 22 November 2019 07:19 Go to previous messageGo to next message
Eclipse UserFriend
You can simply add all of the second to the modules in the first parent
And change all poms of the second to use the parent of the first

Skip the second target
Re: Testing code generation [message #1817612 is a reply to message #1817456] Tue, 26 November 2019 11:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i found something interesting called Maven aggregate (master parent)

Master.parent


  • MyFirstDsl.parent
  • MySecondDsl.parent

and it works, every subparent has its own target definition but i want only one target for all projects and i defined new target under Master parent, after that i removed targets from MyFirstdsl.parent and MySecondDsl.parent and in Pom.xml of the subparents configured new target as a target platform,now it doesn't work

maybe yo have an idea , how to do it?
Re: Testing code generation [message #1817613 is a reply to message #1817612] Tue, 26 November 2019 11:13 Go to previous messageGo to next message
Eclipse UserFriend
simply have only one parent
they do a target-platform-configuration twice otherwise
Re: Testing code generation [message #1817748 is a reply to message #1817613] Thu, 28 November 2019 08:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
during installing my DSL, i am getting following failure:

Missing requirement: Equinox Provisioning UI Support 2.5.600.v20190814-1459 (org.eclipse.equinox.p2.ui 2.5.600.v20190814-1459) requires 'osgi.bundle; org.eclipse.e4.ui.dialogs 1.1.600' but it could not be found

i have created updatesite and added eclipse.e4.ui.dialogs as a included plugin but it doesn't help, could you give tips please?
Re: Testing code generation [message #1817749 is a reply to message #1817748] Thu, 28 November 2019 08:46 Go to previous messageGo to next message
Eclipse UserFriend
- how do you install
- into which version do you install
- what updates sites are configured
- you should not have anything besides the mydsl plugins in the update site
Re: Testing code generation [message #1817750 is a reply to message #1817749] Thu, 28 November 2019 08:55 Go to previous messageGo to next message
Eclipse UserFriend
update site :

file -> export -> deployable features selected MyDsl. feature (1.0.0 qualifier) selected destination in Options selected category.xml

installation:
after that i have installed other version of eclipse (eclipse for java version 2019-06) , install new software ( location of my updatesite)
Re: Testing code generation [message #1817751 is a reply to message #1817750] Thu, 28 November 2019 09:02 Go to previous messageGo to next message
Eclipse UserFriend
i cann install it in my working eclipse version ( 2019-09 dsl tools) without any problem
Re: Testing code generation [message #1817752 is a reply to message #1817751] Thu, 28 November 2019 09:03 Go to previous messageGo to next message
Eclipse UserFriend
but it doesn't work for other versions of eclipse,
Re: Testing code generation [message #1817753 is a reply to message #1817752] Thu, 28 November 2019 09:09 Go to previous messageGo to next message
Eclipse UserFriend
the question is: what do you package on the update site.
if you do a dependency to a specific version or package a thing that has a specific version it wont work
you might also have to add the xtext update site to that eclipse
Re: Testing code generation [message #1817754 is a reply to message #1817752] Thu, 28 November 2019 09:11 Go to previous messageGo to next message
Eclipse UserFriend
does target definition play any role in installing plugin (MyDsl)?
Re: Testing code generation [message #1817755 is a reply to message #1817754] Thu, 28 November 2019 09:15 Go to previous messageGo to next message
Eclipse UserFriend
yes and no. i dont have an idea what you put onto the update site
so i cannot answer.
i also dont know where you install to
and what update sites are configured there
and what options you tick in the install dialog

=> no information but 100000 options
Re: Testing code generation [message #1817759 is a reply to message #1817755] Thu, 28 November 2019 10:34 Go to previous messageGo to next message
Eclipse UserFriend
https://github.com/nasri25/MyDsl-updatesite.git
i added everything hier included updatesite , could you check out please
Re: Testing code generation [message #1817760 is a reply to message #1817759] Thu, 28 November 2019 11:19 Go to previous messageGo to next message
Eclipse UserFriend
Sorry I have no idea. The update site looks fine
What do you do to install it
Re: Testing code generation [message #1817786 is a reply to message #1817760] Fri, 29 November 2019 01:57 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much Christian, the problem is, MyDsl was created with eclipse version 2019-09( Dsl tools version) there are everything like xtext, emf and so on installed
but i want to install MyDsl plugin in eclipse version 2019-06 ( java version) , where i dont have any xtext, antlr ...
i can install my MyDsl plugin in eclipse version 2019-09(dsl tools) without any problem, but i can't install the same plugin in eclipse version 2019-06(java version)

to install this plugin ,
opened eclipse version 2019 -06 (java version)
choosed help-> install new software
in the "Work with" section clicked Add button , opened "Add repository" dialog and clicked Local
and selected directory of my updatesite, than appeared MyDsl
Re: Testing code generation [message #1817787 is a reply to message #1817786] Fri, 29 November 2019 02:01 Go to previous messageGo to next message
Eclipse UserFriend
No Message Body
Re: Testing code generation [message #1817792 is a reply to message #1817787] Fri, 29 November 2019 03:16 Go to previous messageGo to next message
Eclipse UserFriend
Still the questions
- what is the eclipse you install to.
- what is the update sites configured there
- did you add the Xtext update site there
- what changes did you do to what Xtext pregenerates
- what is the complete error message
Re: Testing code generation [message #1817799 is a reply to message #1817792] Fri, 29 November 2019 04:59 Go to previous messageGo to next message
Eclipse UserFriend
- what is the eclipse you install to ->
Eclipse IDE for Java Developers Version: 2019-06 (4.12.0)

- what is the update sites configured there ->
how can i configure update sites in eclipse?


( in org.xtext.example.mydsl.target) or should I define it elsewhere?

-did you add the Xtext update site there -> do you mean in Eclipse?
In the eclipse where I instal mydsl, there is no xtext installed

-what is the complete error message ->L_E768.tmp.PNG
Re: Testing code generation [message #1817801 is a reply to message #1817799] Fri, 29 November 2019 05:43 Go to previous messageGo to next message
Eclipse UserFriend
no idea sure you dont have a bad behaving proxy?
Re: Testing code generation [message #1817803 is a reply to message #1817801] Fri, 29 November 2019 06:12 Go to previous messageGo to next message
Eclipse UserFriend
thank you anyway
Re: Testing code generation [message #1817804 is a reply to message #1817803] Fri, 29 November 2019 06:14 Go to previous messageGo to next message
Eclipse UserFriend
I'll check my proxy
Re: Testing code generation [message #1817805 is a reply to message #1817801] Fri, 29 November 2019 06:40 Go to previous messageGo to next message
Eclipse UserFriend

can i configure updatesite of Mydsl so,
that all required plugins(dependencies) are installed,
for example xtext and so on ,
maybe in feature.xml of my MyDsl
Re: Testing code generation [message #1817806 is a reply to message #1817805] Fri, 29 November 2019 06:41 Go to previous messageGo to next message
Eclipse UserFriend
i mean during insatlling MyDsl
Re: Testing code generation [message #1817819 is a reply to message #1817806] Fri, 29 November 2019 10:28 Go to previous message
Eclipse UserFriend
you can add included features to your feature.xml
but i dont know a list.
i am not sure if
there is also an add required bundles/features button somewhere in the feature editor.
but that may no help in your case if you want to install new stuff into an old eclipse

[Updated on: Fri, 29 November 2019 10:29] by Moderator

Previous Topic:How to use multi line in XBlockExpression of a dsl
Next Topic:[Beginner] New line, tabs
Goto Forum:
  


Current Time: Wed Jul 23 12:53:06 EDT 2025

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

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

Back to the top