Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Why does the package manager download test folders/assemblies to the user machine?

Discussion in 'Package Manager' started by Xarbrough, Jun 27, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    518
    This is more a curious question than any sort of criticism, but I wanted to know why packages include their test code in a way that the package manager downloads this part of the package to the local machine.

    In Unity projects, users can't run tests for packages, right? It's only something the original developer or other contributors use when their package code is within their own development project environment.

    Would it actually make sense to provide means to let users run tests for packages? Maybe to validate that they run as expected within the actual project setup and find potential side-effects early.

    Or would it make sense to strip these files from the download to save time and disk space?
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    582
    Hi @Xarbrough,

    The intention behind providing tests inside a package is to let you make a change locally and test that it still works. So, if you embed a Unity package in your project, you can run the tests. You can try it if you want. Locate the package content on your machine. In recent Unity versions, look into the
    Library/Packages/PackageCache
    folder. Copy a package that you know have tests in
    Packages/
    (Make sure you copy the package root folder).

    The package test should now show up in the tests runner.

    Note: We are thinking of changing this approach. We want to fetch the tests from the package Git source repository if available on demand. The drawback of the current approach is that it requires all users to download the tests even though they don't need it.

    Regards,

    Pascal
     
    Xarbrough likes this.
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    518
    Good to know! I haven't tried the embed functionality yet, that makes more sense and is a nice way to handle things! I'll probably use it to make some temporary modifications or quick-bug fixes for packages.

    I agree, that the perfect solution would be to make the tests or additional content of the package repositories available on demand. :)
     
    okcompute_unity likes this.
  4. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    We have actually integrated the Unity tests as part of our general Continuous Integration. No particular reason - they don't take up extra time (unless milliseconds count) but its good for peace of mind.
     
  5. eelstork

    eelstork

    Joined:
    Jun 15, 2014
    Posts:
    195
    This has been raised in an older thread, but I really think it would be useful to do the following:
    1. Allow enabling or disabling package tests, independently from whether they are embedded, or linked via a file: ref. This is the more important one in my opinion.
    2. Allow downloading tests or not, depending on the user preference (less important imho but, as UPM matures, at some point people are going to ask for demo files to be optional. Tests are small, demos ~ depends; so there's going to be this push (or frustration) around not being able to select package components)
    The problem is that to package consumers there's no intuition that embedded == tests should be available. Package users may still want to tweak their local packages (so normally, expected via a file: ref); if they tweak them, surely they want to run the tests?

    But I'm preparing a package right now (so, producer perspective), and here's how I came here.
    • Wanted to add a demo to my package, but did not want the demo INSIDE the package. So I had an embedded package, with a project dedicated to it. The package is in git but the container project is not.
    • Now, as I see it my demo surely should be in vcs. So I switch to a file: configuration, which lets me put my project in git, without having to enlist git submodules (muddied waters; been there, rowed back)
    • BOOM. My package has no 'embedding container' and my tests disappeared.
    Meanwhile I would also use file: refs to consume packages (in user mode, as it is still more practical than URLs) so in this case I rarely would like to run the tests...

    Having to choose between submodules and using 2 container projects is having no best choice

    - v -

    On this note thanks for bringing UPM. Unity + UPM = FUN, so far.
     
    maximeb_unity likes this.
  6. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    143
    Hi @eelstork,

    Thanks for the feedback! We're aware of the limitations (well, I'd go as far as saying unwieldiness) of test support with packages. This is definitely one thing we want to improve and it's on our roadmap. The criticism you raised is all part of what we intend to improve.
     
    eelstork likes this.