-
Notifications
You must be signed in to change notification settings - Fork 3
Added test dependency for official parser (issue 119) #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9b10a5d
da24d9b
c16c775
c467099
f0122a2
4d30fde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,9 @@ dependencies { | |
|
|
||
| implementation "org.apache.commons:commons-lang3:$commons_lang_version" | ||
| implementation "commons-cli:commons-cli:$commons_cli_version" | ||
|
|
||
| def omg_version = "0.18.0" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| testImplementation(group: "org.omg.sysml", name: "org.omg.sysml.interactive", version: omg_version, classifier: "all") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a little problematic. In the pipeline we have a flag "isPipelineFullBuild" that only loads the visualization subproject only if the flag is set. This way the user can check out the projects without having a github login. This breaks that principle. This needs to be a conditional dependency and the test itself needs to be excluded from the test source sets both depending on the flag. |
||
| } | ||
|
|
||
| /* ============================================================ */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package parser; | ||
|
|
||
| import de.monticore.lang.sysmlv2.SysMLv2Mill; | ||
| import de.monticore.lang.sysmlv2._ast.ASTSysMLModel; | ||
| import de.monticore.lang.sysmlv2._parser.SysMLv2Parser; | ||
| import de.se_rwth.commons.logging.Log; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.ValueSource; | ||
| import org.omg.sysml.interactive.SysMLInteractive; | ||
| import org.omg.sysml.interactive.SysMLInteractiveResult; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.Optional; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| public class ParsersComparisonTest { | ||
| private static final String MODEL_PATH = "src/test/resources/parser"; | ||
|
|
||
| private SysMLv2Parser parser = SysMLv2Mill.parser(); | ||
|
|
||
| // SysMLInteractive is a singleton; keep one reference | ||
| private static SysMLInteractive official; | ||
|
|
||
| @BeforeAll | ||
| public static void init() { | ||
| Log.init(); | ||
| SysMLv2Mill.init(); | ||
|
|
||
| official = SysMLInteractive.getInstance(); | ||
| official.setVerbose(false); | ||
| } | ||
|
|
||
| @BeforeEach | ||
| public void reset() { | ||
| parser.setError(false); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "{index} - {0} does parse w/o errors (MontiCore + official)") | ||
| @ValueSource(strings = { | ||
| "packages.sysml", | ||
| "imports.sysml", | ||
| "ports.sysml", | ||
| "parts.sysml", | ||
| "states.sysml", | ||
| "parallel_states.sysml", | ||
| "actions.sysml", | ||
| "items.sysml", | ||
| "assert.sysml", | ||
| "constraints.sysml", | ||
| "requirements.sysml", | ||
| "streams.sysml", | ||
| "streamsFilter.sysml", | ||
| "refinement.sysml", | ||
| "cardinalities.sysml", | ||
| "connections.sysml", | ||
| "collections.sysml", | ||
| "StateDecomposition1.sysml", | ||
| "FlowConectionInterfaceExample.sysml", | ||
| "StateActions.sysml", | ||
| "ConditionalSuccessionExample-1.sysml" | ||
| }) | ||
| public void testParsingModels(String modelName) throws IOException { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also temporarely add @disabled to the test to fix the pipeline until we decide how to fix the negative parsing errors. |
||
| Path modelPath = Path.of(MODEL_PATH, modelName); | ||
|
|
||
| // 1) MontiCore parser (existing behavior) | ||
| Optional<ASTSysMLModel> ast = SysMLv2Mill.parser().parse(modelPath.toString()); | ||
| assertFalse(parser.hasErrors(), "MontiCore parsing should not have failed"); | ||
| assertTrue(ast.isPresent(), "MontiCore AST should have been created"); | ||
|
|
||
| // 2) Official OMG parser | ||
| String input = Files.readString(modelPath); | ||
| SysMLInteractiveResult result = official.eval(input); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not completely sure but this method probably also checks the official context conditions. So if line 70 only tests parsing then this should also only test parsing. Otherwise you are testing two different functionalities. Extract the method that is relevant and use it there. But first look at the other comment. |
||
|
|
||
| assertFalse( | ||
| result.hasErrors(), | ||
| () -> "Official OMG parser errors for " + modelName + ":\n" + result.formatIssues() | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.