-
Notifications
You must be signed in to change notification settings - Fork 250
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
VUnit python interface: adding files to a Library #274
Comments
Looks like the file gets added to the underlying source files again, even if it does not get added to the library again. Is this desired behavior? Line 142 in b5b9b24
If not, I would propose a check similar to that in |
Sure it results in a invalid state. At least a warning is emitted. Maybe the warning should be raising an exception instead. |
Now an exception is raised instead when adding a duplicate file. |
@kraigher Looking at it from the user's perspective, I would rather log that VUnit saw a duplicate file attempted to be added and then not add it rather than raise an exception. If an exception is raised, then the user still has to handle the exception anyway (which was my workaround to this issue in the first place). I discovered the invalid state because I was dynamically added libraries (and files to those libraries) to test suites without knowing what was added previously. To me, one of the advantages of VUnit was that it handled the case of me trying to add files that already existed in a library elegantly (log a warning, ignore file). |
I prefer the exception for two reasons:
|
Problem
The vunit.ui.VUnit.library method returns new instances of a library. I understand that this is just an interface into the underlying
vunit.project.Library
class, but this becomes an issue when trying to access previously added libraries on an instance of VUnit programatically. For a bit more context, I am setting up a larger test suite using the pattern @LarsAsplund lays out on SO. When doing this I need to "get" Libraries I may have previously created and added files to so I can add additional files. The problem seems to be with howvunit.ui.Library.add_source_file
interfaces with the underlying project.Reproduction
The text was updated successfully, but these errors were encountered: