Code Monkey home page Code Monkey logo

Comments (10)

LandonTClipp avatar LandonTClipp commented on May 24, 2024 1

FWIW, my latest patch (that closed this issue) fixes the behavior of showconfig so that we don't get into infinite recursion when using recursive: True

➜  mockery git:(master) ✗ ./mockery showconfig
05 Nov 23 22:23 CST INF Using config: /Users/landonclipp/git/vektra/mockery/.mockery.yaml version=v0.0.0-dev
disable-version-string: true
filename: '{{.MockName}}.go'
mockname: '{{.InterfaceName}}'
outpkg: mocks
packages:
  github.com/vektra/mockery/v2/pkg:
    config:
.....

from mockery.

kbolino avatar kbolino commented on May 24, 2024

This is not hardly the only issue on Windows, which certainly complicates fixing it.

from mockery.

LandonTClipp avatar LandonTClipp commented on May 24, 2024

So I'm not sure I understand. What exactly is the infinite recursion here? What do you notice when running that config? (does mockery spin infinitely and not give any output?)

from mockery.

LandonTClipp avatar LandonTClipp commented on May 24, 2024

I admit, I have spent 0 mental energy making mockery work for Windows. It hasn't been a huge priority because most people use unix-like systems. I'm honestly surprised mockery works at all on windows TBH because there are a lot of underlying things like in pathlib (which I wrote) that don't have any explicit support for Windows, although maybe that's not as much of an issue if you're using WSL.

from mockery.

kbolino avatar kbolino commented on May 24, 2024

So I'm not sure I understand. What exactly is the infinite recursion here? What do you notice when running that config? (does mockery spin infinitely and not give any output?)

It's a little difficult to get a good working output because the YAML encoder seems to run out of memory before it can print anything. Inferring from what I can see from spew.Dump, what seems to happen is that the configuration gets turned into something like the following (ignoring the parts that aren't broken):

packages:
  github.com/vektra/mockery/v2/pkg/fixtures/example_project/pkg_with_subpkgs/subpkg2/subpkg3:
    packages:
      github.com/vektra/mockery/v2/pkg/fixtures/example_project/pkg_with_subpkgs/subpkg2\subpkg3:
        packages:
          github.com/vektra/mockery/v2/pkg/fixtures/example_project/pkg_with_subpkgs/subpkg2/subpkg3:
            packages:
              github.com/vektra/mockery/v2/pkg/fixtures/example_project/pkg_with_subpkgs/subpkg2\subpkg3:
                ...

from mockery.

LandonTClipp avatar LandonTClipp commented on May 24, 2024

Oh, so you are saying that showconfig is getting into an infinite loop, not the actual mock generation?

from mockery.

kbolino avatar kbolino commented on May 24, 2024

I haven't tried generating mocks using the problematic configuration yet, so I don't know if mock generation is broken or not. I can test that later when I'm back on Windows. So far, this only arose for me in mockery's own tests.

from mockery.

kbolino avatar kbolino commented on May 24, 2024

I admit, I have spent 0 mental energy making mockery work for Windows. It hasn't been a huge priority because most people use unix-like systems. I'm honestly surprised mockery works at all on windows TBH because there are a lot of underlying things like in pathlib (which I wrote) that don't have any explicit support for Windows, although maybe that's not as much of an issue if you're using WSL.

That's fair, it may not be worth the time or effort if nobody really uses it on Windows. If the right answer is just to use Mac/WSL/Linux instead, maybe the right solution to this is just to add a note to the README that Windows isn't supported and move on.

from mockery.

LandonTClipp avatar LandonTClipp commented on May 24, 2024

Got it, so I think that this config would work fine for actual mock generation. showconfig has been broken since I implemented the recursive feature, I just never mentioned it and it seemed like no one actually ever used showconfig until now. I'm also not sure this has anything to do with Windows necessarily.

The problem lies with the fact that when using recursive: True, all discovered sub-packages will contain a copy of the parent package's config, including the package parameter itself. Because of this copying behavior, the package parameter gets into this infinite self-referential loop that is impossible to get out of. This isn't a problem for the mock generation because it doesn't recurse into the packages map, it only looks at the top-level packages map.

I did try fixing this like a year ago but obviously I gave up... I think the solution would be to nil out the packages map during the config inheritance step. It's not a great solution but I think it'd work.

from mockery.

kbolino avatar kbolino commented on May 24, 2024

There does seem to be something especially bad about it on Windows, where the path separator discrepancy (\ for the file system, / for Go packages) creates redundant entries in the packages map which I guess breaks the YAML encoder's cycle detection.

from mockery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.