Skip to content

Java: Test generator improvements #12195

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 3 commits into from
Feb 16, 2023

Conversation

joefarebrother
Copy link
Contributor

This PR allows the test generator to accept a yml file or a diretory of yml files containing MaD specifications as input.
Also, the generated "return type" of a constuctor is now considered to be the constructed type.

- Accept yml files as input
- Output the correct type for constructors
@joefarebrother joefarebrother requested a review from a team as a code owner February 15, 2023 16:23
@joefarebrother joefarebrother added the no-change-note-required This PR does not need a change note label Feb 15, 2023
@github-actions github-actions bot added the Java label Feb 15, 2023
Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! It'll be super useful for the rest of the modeling work we're doing.

I added some minor comments, but otherwise this LGTM.

Comment on lines +126 to +130
specs = []
for f in os.listdir(dirname):
if f.endswith('.yml'):
specs += readYml(f"{dirname}/{f}")
return specs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest an implementation a bit more pythonic?

Suggested change
specs = []
for f in os.listdir(dirname):
if f.endswith('.yml'):
specs += readYml(f"{dirname}/{f}")
return specs
return [readYml(f"{dirname}/{f}") for f in os.listdir(dirname) if f.endswith('.yml')]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That isn't equivalent is it? As that would result in a list of lists, rather than a single list of rows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, true, sorry. That would then probably need to be something like:

Suggested change
specs = []
for f in os.listdir(dirname):
if f.endswith('.yml'):
specs += readYml(f"{dirname}/{f}")
return specs
return [row for row in readYml(f"{dirname}/{f}") for f in os.listdir(dirname) if f.endswith('.yml')]

But the readability starts getting bad at that point, so feel free to leave it as it is.

@joefarebrother joefarebrother merged commit 430b432 into github:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants