Skip to content
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

Fix output format detection #1079

Merged
merged 7 commits into from
Nov 5, 2021
Merged

Fix output format detection #1079

merged 7 commits into from
Nov 5, 2021

Conversation

shonfeder
Copy link
Contributor

@shonfeder shonfeder commented Nov 5, 2021

Followup to #1073

That fix introduced another regression test, which caused the of the
parser to always go to TLA. :(


  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)
  • Documentation added for any new functionality
  • Entry added to UNRELEASED.md for any new functionality

Shon Feder added 4 commits November 5, 2021 12:15
Followup to #1073

That fix introduced *another* regression test, which caused the of the
parser to always go to TLA. :(
This way if I break the output detection again, I'll know it before
merging :)
Comment on lines +86 to -88
val outfile = new File(output)
val outfileName = outfile.toString()

if (filename.toLowerCase.endsWith(".tla")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This had been picking up the filename instead of the outfile, and the filename was the input file (artifact of shadowing and not having sufficiently careful test coverage.

@shonfeder shonfeder requested a review from danwt November 5, 2021 16:33
Comment on lines -89 to 95
val moduleName = filename.substring(0, filename.length - ".tla".length)
if (outfileName.toLowerCase.endsWith(".tla")) {
val moduleName = outfileName.substring(0, outfileName.length - ".tla".length)
writerFactory.writeModuleToTla(rootModule.get.copy(name = moduleName), TlaWriter.STANDARD_MODULES,
Some(file))
} else if (filename.toLowerCase.endsWith(".json")) {
val moduleName = filename.substring(0, filename.length - ".json".length)
Some(outfile))
} else if (outfileName.toLowerCase.endsWith(".json")) {
val moduleName = outfileName.substring(0, outfileName.length - ".json".length)
writerFactory.writeModuleToJson(rootModule.get.copy(name = moduleName), TlaWriter.STANDARD_MODULES,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The duplicate logic in these bits makes this kind of problem a bit more likely, but I'll be refactoring this as part of #1077

@shonfeder
Copy link
Contributor Author

Dan gave a LGTM on this in slack.

@shonfeder shonfeder requested a review from Kukovec November 5, 2021 17:24
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

Looks good!

@shonfeder shonfeder enabled auto-merge (squash) November 5, 2021 17:28
@shonfeder shonfeder removed the request for review from Kukovec November 5, 2021 17:28
@shonfeder shonfeder merged commit eff6603 into unstable Nov 5, 2021
@apalache-bot apalache-bot mentioned this pull request Nov 8, 2021
@shonfeder shonfeder deleted the shon/fix-output-formattin branch February 4, 2022 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants