-
Notifications
You must be signed in to change notification settings - Fork 31
Fix Archive::describe to include sub-archives (#188) #189
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
Conversation
6a7f4ba to
f3c3392
Compare
Signed-off-by: Aseem Dua <[email protected]>
f3c3392 to
c700fd1
Compare
Signed-off-by: Aseem Dua <[email protected]>
c700fd1 to
a4346ab
Compare
Signed-off-by: Aseem Dua <[email protected]>
|
Can you add some unit tests as well (GeneratedArchiveTests)?:
|
Test that if sub-archive is unintialized, it's in the describe. Test if schema mismatches in optional sub-archive, you get a fatal error and it is in the describe. The mandatory sub-archive case is present in an existing test. Signed-off-by: Aseem Dua <[email protected]>
dbc939f to
4a6369c
Compare
| } | ||
|
|
||
| TEMPLATE_TEST_CASE_METHOD( Fixture, | ||
| "Uninitialized sub-archive is descried", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desried -> described
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sure, will fix.
| std::string description; | ||
| if ( initialized ) | ||
| { | ||
| description = std::is_base_of< Archive, ResourceType >::value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
- describing resourcing is sub-archives that failed to initialize? How does that look like now?
- describing resources in sub-archives that successfully loaded, how does that look like now?
I guess it might need to look like a tree-structure, e.g.:
resource1 : ...
archive_resource1: ...
sub_resource1: ...
sub_resource2: ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Uninitialized is reported as an error only in mandatory case. But then it doesn't stop us from describing the
Archivechild resources instead of keeping it "N/A". Will adapt it. -
If everything is initialized, then then describe works but there is no indentation and everything is flattened out (it's flatdata after all). But I'll try to see if there's a nice way to get indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a bit hacky... how about having a single combined list, but full resource names:
outermost
outer
outer.outer1
outer.outer2
outer.inner
outer.inner.inner
That could require passing down the path-prefix, and being able to disable headers/footers during recursive calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Signed-off-by: Aseem Dua <[email protected]>
Whether a resource is initialized or not, it will always display some details. For optional entities, a dummy is created to extract the name of the type to give maximum information to the user. Nested levels do not print headers. Signed-off-by: Aseem Dua <[email protected]>
|
I seem to often run into this issue of tests failing on CI. This time it happened because I just had forgotten where to run the tests from. Should we have a separate task to put into a README how to run tests locally? |
Signed-off-by: Aseem Dua <[email protected]>
That makes sense: Some
Do you want to create a new issue for that? And would you like to fill that yourself, or have it filled by regular contributors? |
Signed-off-by: Aseem Dua <[email protected]>
I can create an issue as a starting point, definitely. But I guess I don't have enough insight as to what all it could include. Like I literally had no idea about half the things you mentioned. |
| } | ||
| else | ||
| { | ||
| auto dummy = new ResourceType( ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are leaking memory here, just create the object on the stack?
| const bool is_archive = std::is_base_of< Archive, ResourceType >::value; | ||
|
|
||
| const ResourceType ref = initialized ? *resource // valid ref | ||
| : *( new ResourceType( ) ); // ref to dummy, not used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are leaking memory here, just create the object on the stack?
| size_t size_in_bytes( ) const; | ||
| size_t size( ) const; | ||
| std::string describe( ) const; | ||
| std::string describe( size_t unused = 0u ) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
give unused arguments their normal name, so users know what they are
|
|
||
| std::string | ||
| describe( ) const | ||
| describe( size_t unused = 0 ) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t /name_of_variable/ ?
| Resource Optional Too Large Loaded Details | ||
| ================================================================================ | ||
| outer NO NO YES Structure of size 1 | ||
| archive_resource YES NO NO FATAL: Resource storage not initialized. Please check archive path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the FATAL should be removed, since it is not fatal for optional subarchives
Same if true for check archive path.
Can you rephrase it into a neutral message? Or have a different message for root and nested?
Signed-off-by: Aseem Dua <[email protected]>
50a8f62 to
6ea5e28
Compare


Added to template adding describe to optional resources.
Prepended a newline for readability.