-
Notifications
You must be signed in to change notification settings - Fork 1
Add CLI Tool and updated README for Concerto Conformance Suite #19
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a7ba312
Updated readme and added the CLI for customising the import source pa…
Anshukumar123975 2f0aa72
Some minor bug fixes
Anshukumar123975 6a38acb
Update README.md
Anshukumar123975 3fed288
Update README.md
Anshukumar123975 c3f5884
Update README.md
Anshukumar123975 b59ef6f
Update README.md
Anshukumar123975 686e835
Updated readme.md
Anshukumar123975 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,31 @@ | ||
| # concerto-conformance | ||
| # Concerto Conformance Test Suite | ||
|
|
||
| ## Desription | ||
| The Concerto Conformance Test Suite provides a standardized, automated testing suite to validate models and semantic behavior across Accord Project's Concerto implementation. | ||
|
|
||
| ## Overview | ||
| This repository includes: | ||
| 1. A set of semantic validation rules | ||
| 2. Comprehensive valid and invalid model examples | ||
| 3. Tests written using Cucumber, offering behavior-driven, human-readable test definitions | ||
| 4. Support for both JavaScript and C# runtimes | ||
| The suite specifically tests core components of the Concerto ecosystem: the `ModelFile` and `ModelManager` classes from `@accordproject/concerto-core` | ||
|
|
||
| ## Getting started | ||
| 1. Install dependencies: | ||
| `npm install` | ||
| 2. Run the Javascript test suite: | ||
| `npm test` | ||
| 3. Run tests for C#: | ||
| `npm run test:csharp` | ||
|
|
||
| ## Interactive CLI: | ||
| You can also use the built-in CLI for a guided setup: | ||
| `npm start` | ||
| The CLI allows you to provide custom ModelManager, Parser, or ModelFile sources for testing. | ||
|
|
||
| ## Future Roadmap | ||
|
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 think you can add those to the project board. You don't need to add them here unless you don't have time to add these to the repository before GSoC finishes. But keeping them is fine as well. Just keep in mind to have them up to date. |
||
| Enabling straightforward integration with CI/CD pipelines, so projects like Concerto itself can: | ||
| 1. Automatically run conformance tests on every push | ||
| 2. Detect semantic rule violations or model-breaking changes early | ||
| 3. Maintain consistent validation standards across development workflows | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import inquirer from 'inquirer'; | ||
| import fs from 'fs'; | ||
| import { execSync } from 'child_process'; | ||
|
|
||
| const defaults = { | ||
| ModelManager: '@accordproject/concerto-core', | ||
| Parser: '@accordproject/concerto-cto', | ||
| ModelFile: '@accordproject/concerto-core' | ||
| }; | ||
|
|
||
| async function run() { | ||
| const { language } = await inquirer.prompt({ | ||
| type: 'list', | ||
| name: 'language', | ||
| message: 'Choose language:', | ||
| choices: ['Javascript', 'C#'] | ||
| }); | ||
|
|
||
| const imports = {}; | ||
|
|
||
| for (const comp of Object.keys(defaults)) { | ||
| const { include } = await inquirer.prompt({ | ||
| type: 'confirm', | ||
| name: 'include', | ||
| message: `Do you want to test your own ${comp}?` | ||
| }); | ||
|
|
||
| if (include) { | ||
| const { path: userPath } = await inquirer.prompt({ | ||
| type: 'input', | ||
| name: 'path', | ||
| message: `Enter import path for ${comp} (default: ${defaults[comp]}):` | ||
| }); | ||
|
|
||
| const finalPath = userPath.trim() || defaults[comp]; | ||
| imports[comp] = `import { ${comp} } from '${finalPath}';`; | ||
|
|
||
| } else { | ||
| imports[comp] = `import { ${comp} } from '${defaults[comp]}';`; | ||
| } | ||
| } | ||
|
|
||
| const templatePath = `semantic/features/support/templates/${language}`; | ||
| const outputPath = `semantic/features/support/${language}`; | ||
|
|
||
| const worldTemplate = fs.readFileSync(`${templatePath}/world.template.ts`, 'utf-8'); | ||
| const worldOutput = worldTemplate.replace('{{MODELMANAGER_IMPORT}}', imports.ModelManager); | ||
| fs.writeFileSync(`${outputPath}/world.ts`, worldOutput); | ||
|
|
||
| const stepsTemplate = fs.readFileSync(`${templatePath}/steps.template.ts`, 'utf-8'); | ||
| const stepsOutput = stepsTemplate | ||
| .replace('{{PARSER_IMPORT}}', imports.Parser) | ||
| .replace('{{MODELFILE_IMPORT}}', imports.ModelFile); | ||
| fs.writeFileSync(`${outputPath}/steps.ts`, stepsOutput); | ||
|
|
||
| console.log("Setup ready. Running tests..."); | ||
|
|
||
| if (language === 'Javascript') { | ||
| execSync('npm test', { stdio: 'inherit' }); | ||
| } else { | ||
| execSync('npm run test:csharp', { stdio: 'inherit' }); | ||
| } | ||
| } | ||
|
|
||
| run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Semantic.Support.CSharp/obj/Debug/net6.0/Semantic.Support.CSharp.AssemblyInfoInputs.cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ac751e616cdb4178e8e1b0c3c1233dc4b2b6a691fe113800adc728d7d8146b29 | ||
| 728d0b1b0d333a3b88a57dc69ea86f43dc0b627052d6c700db51c82470e30ee7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
semantic/features/support/templates/Javascript/steps.template.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { Given, When, Then } from '@cucumber/cucumber'; | ||
| import { loadCTO } from './utils/loadCTO.ts'; | ||
| {{PARSER_IMPORT}} | ||
| {{MODELFILE_IMPORT}} | ||
| import assert from 'assert'; | ||
|
|
||
| Given('I load the following models:', function (dataTable) { | ||
| for (const row of dataTable.hashes()) { | ||
| const modelContent = loadCTO(row.model_file); | ||
| try { | ||
| const ast = Parser.parse(modelContent, row.model_file); | ||
| const modelFile = new ModelFile(this.modelManager, ast, modelContent, row.model_file); | ||
| this.modelManager.addModelFile(modelFile, null, modelFile.getName(), true); | ||
| } catch (err) { | ||
| this.error = err as Error; | ||
| break; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| When('I validate the models', function () { | ||
| try { | ||
| this.modelManager.validateModelFiles(); | ||
| this.error = null; | ||
| } catch (err) { | ||
| this.error = err as Error; | ||
| } | ||
| }); | ||
|
|
||
| Then('an error should be thrown with message {string}', function (expected: string) { | ||
| assert(this.error, 'Expected an error to be thrown, but none was'); | ||
|
|
||
| let isMatch: boolean; | ||
| const match = expected.match(/^\/(.+)\/([gimsuy]*)?$/); | ||
|
|
||
| if (match) { | ||
| const pattern = new RegExp(match[1], match[2]); | ||
| isMatch = pattern.test(this.error.message); | ||
| assert( | ||
| isMatch, | ||
| `Expected error to match regex ${pattern}, but got: "${this.error.message}"` | ||
| ); | ||
| } else { | ||
| isMatch = this.error.message.includes(expected); | ||
| assert( | ||
| isMatch, | ||
| `Expected error to include "${expected}", but got: "${this.error.message}"` | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| Then('no error should be thrown', function () { | ||
| assert.strictEqual(this.error, null, `Expected no error, but got: ${this.error?.message}`); | ||
| }); |
15 changes: 15 additions & 0 deletions
15
semantic/features/support/templates/Javascript/world.template.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| {{MODELMANAGER_IMPORT}} | ||
|
|
||
| import { setWorldConstructor, IWorldOptions } from '@cucumber/cucumber'; | ||
|
|
||
| export class CustomWorld { | ||
| public modelManager: ModelManager; | ||
| public error: Error | null; | ||
|
|
||
| constructor(options: IWorldOptions) { | ||
| this.modelManager = new ModelManager({ enableMapType: true }); | ||
| this.error = null; | ||
| } | ||
| } | ||
|
|
||
| setWorldConstructor(CustomWorld); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.