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

Print dependency cycles in error message #340

Merged

Conversation

martijnbastiaan
Copy link
Contributor

@martijnbastiaan martijnbastiaan commented Jun 20, 2022

While Tasty detects cycles and prints an error message, it does not print the cycles it found. This PR makes sure it does. I've tested it on another code base with cycles in it, the output looks like:

clash-testsuite: Test dependencies form a loop:

..tests.shouldwork.Issues.T2046.VHDL.Vivado => ..tests.shouldwork.Issues.T2046.VHDL.Vivado

..tests.shouldwork.Issues.T2046.SystemVerilog.Vivado => ..tests.shouldwork.Issues.T2046.SystemVerilog.Vivado

..tests.shouldwork.BlackBox.T2117.VHDL.Vivado => ..tests.shouldwork.BlackBox.T2117.VHDL.Vivado

..tests.shouldfail.Verification.NonTemporalPSL.VHDL.Vivado => ..tests.shouldfail.Verification.NonTemporalPSL.VHDL.Vivado

Note the double dot is an artifact of this particular test tree.

@martijnbastiaan
Copy link
Contributor Author

Sorry, goofed up. The PR should now pass CI as demonstrated here.

Copy link
Collaborator

@Bodigrim Bodigrim left a comment

Choose a reason for hiding this comment

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

LGTM. Indeed, debugging dependency cycles is quite tricky currently.

Since DependencyLoop has been exposed to users, this is a breaking change, but I doubt that there are many clients affected.

@martijnbastiaan
Copy link
Contributor Author

I've added a changelog entry. @Bodigrim Given that this PR has been open for two weeks and hasn't attracted any comments, I doubt it is controversial. Is there anything I can do to help this get merged?

@Bodigrim
Copy link
Collaborator

Bodigrim commented Jul 2, 2022

I think this is a valuable addition, which justifies a minor breakage. Indeed I needed such feature in the past. @andreasabel @ocharles @VictorCMiraldo @adamgundry opinions?

@VictorCMiraldo
Copy link
Collaborator

I never needed this and I didn't know that tasty does detect dependency cycles. Makes sense and I can see how this can useful. The only think I'd suggest is shortening the output, if we have a dependency loop [a,b,c,d], why not print names only once? For instance:

Cyclic test dependencies:
  - a
  - b
  - c
  - d

@martijnbastiaan
Copy link
Contributor Author

I did that to make self-loops non-ambiguous / more obvious to read. In my example I've got four separate dependency cycles, but they're all forming a self-loop. If we'd go with the list as you posted, I think we should do something like:

Cyclic test dependencies:

Cycle 1:
  - a
  - b
  - c

Cycle 2:
  - d

@martijnbastiaan
Copy link
Contributor Author

@VictorCMiraldo I've implemented your suggestion. Could you re-review and/or start CI?

@VictorCMiraldo
Copy link
Collaborator

Thank you @martijnbastiaan, I triggered CI.
@Bodigrim, as you mentioned, this is a breaking change. That being said, I agree that it is very unlikely to break for many users and @martijnbastiaan already prepped the changelog with a relevant entry for a future release of tasty. Do you think this still needs anything or should we merge once CI goes green?

Copy link
Collaborator

@VictorCMiraldo VictorCMiraldo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

deriving (Typeable)

instance Show DependencyException where
show DependencyLoop = "Test dependencies form a loop."
show (DependencyLoop css) = "Test dependencies have cycles:" ++ showCycles css
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. And showCycle should do the - stuff. Currently it looks like:

mod-bench: Test dependencies have cycles:All.Power.Data.Mod, All.Power.Data.Mod
- Foo, Bar, Foo

show DependencyLoop = "Test dependencies form a loop."
show (DependencyLoop css) = "Test dependencies have cycles:" ++ showCycles css
where
showCycles = intercalate "\n- " . map showCycle
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need "\n- " before the first line as well, otherwise the output looks like

mod-bench: Test dependencies have cycles:All.Power.Data.Mod, All.Power.Data.Mod

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch, thanks!

@martijnbastiaan
Copy link
Contributor Author

Thanks @Bodigrim, I've added a test for it too. Should be good now!

@Bodigrim
Copy link
Collaborator

Bodigrim commented Jul 3, 2022

@VictorCMiraldo feel free to merge.

@VictorCMiraldo
Copy link
Collaborator

Let's merge then! :)

@VictorCMiraldo VictorCMiraldo merged commit 7c8a1af into UnkindPartition:master Jul 4, 2022
@martijnbastiaan martijnbastiaan deleted the print-cycles branch July 4, 2022 07:32
@Bodigrim Bodigrim mentioned this pull request Dec 8, 2022
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.

None yet

3 participants