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

libfetchers: Add unit test #6

Closed
wants to merge 1 commit into from

Conversation

roberth
Copy link

@roberth roberth commented Feb 11, 2023

Findings:

  • The error for an empty work tree isn't great, and should perhaps
    not be an error at all.

  • It would be nice to use a C++ wrapper library. Writing this in C style
    is a little unpleasant. Would make sense to use that in the main code
    as well, unless we want to keep the untested build from source closure
    small and not vendor the wrapper.
    An example of such a wrapper is https://github.com/AndreyG/libgit2cpp
    Alternatively, we might do a lightweight wrapper of our own that only
    adds constructors and destructors.

  • Alternatively, we could use a store-only CLI command to test fetchers.
    This won't let us test the intricacies of laziness, but does simplify
    the setup of such things as git repositories by an order of magnitude.
    In this case, I'd keep the test suite around for tests that are specific
    to the input accessor methods, insofar as those aren't covered by the
    such CLI-based tests.

  • Nix couldn't find a suitable getCacheDir() when run in the sandbox.
    I think a fixed location in /tmp is a sensible behavior in this case.

Findings:

 - The error for an empty work tree isn't great, and should perhaps
   not be an error at all.

 - It would be nice to use a C++ wrapper library. Writing this in C style
   is a little unpleasant. Would make sense to use that in the main code
   as well, unless we want to keep the untested build from source closure
   small and not vendor the wrapper.
   An example of such a wrapper is https://github.com/AndreyG/libgit2cpp/tree/master/src
   Alternatively, we might do a lightweight wrapper of our own that only
   adds constructors and destructors.

 - Alternatively, we could use a store-only CLI command to test fetchers.
   This won't let us test the intricacies of laziness, but does simplify
   the setup of such things as git repositories by an order of magnitude.
   In this case, I'd keep the test suite around for tests that are specific
   to the input accessor methods, insofar as those aren't covered by the
   such CLI-based tests.
@roberth roberth requested a review from edolstra as a code owner February 11, 2023 15:22
@roberth
Copy link
Author

roberth commented Feb 11, 2023

Cost breakdown of last unit test, repo with 1 file in HEAD.

TmpRepo init: 1ms
TmpStore init: 36ms
Adding 1 file to HEAD: 1.2ms
Acquire an InputAccessor: instant
readDirectory: 7ms
fetchToSTore (after readDirectory): 4ms

Total including cleanup: 68ms

Tests could be sped up 2× by using a global store.

Sometimes the test takes twice as long. Maybe libgit2 tries to auto gc or something.

@roberth roberth mentioned this pull request Feb 11, 2023
9 tasks
@Ericson2314
Copy link

Oh did this work ever end up anywhere?

@roberth
Copy link
Author

roberth commented Jan 3, 2024

It did not. I've added it to the board just now: https://github.com/orgs/NixOS/projects/19/views/9

EDIT: was wrong board

@edolstra edolstra closed this Jan 5, 2024
@edolstra
Copy link
Owner

edolstra commented Jan 5, 2024

Will move this to the NixOS/nix repo.

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.

3 participants