GithubHelp home page GithubHelp logo

Redefining constants about clockwork-test HOT 13 CLOSED

ce07c3 avatar ce07c3 commented on July 20, 2024
Redefining constants

from clockwork-test.

Comments (13)

ce07c3 avatar ce07c3 commented on July 20, 2024 1

No, that's not related to the issue with the re-loading.

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

I'm not sure how this is an issue with the repo if the problem is in your clock file. Could you clarify how this is manifesting as a result of this test library?

from clockwork-test.

ce07c3 avatar ce07c3 commented on July 20, 2024

Hey @kevin-j-m! First of all, many thanks for the gem and for responding. :)

The gem does try to require the clock configuration file I assume, and for the five test cases we have, it does so five times. Everything after the first re-requires the module and its constants I believe?

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Are you running Clockwork::Test.clear! before/after every run? Every time run is invoked, it will load the clock file. I would guess if you have multiple runs without a clear, then this will load the file multiple times, which I'd guess would raise that warning.

from clockwork-test.

ce07c3 avatar ce07c3 commented on July 20, 2024

Yes, the load would be the problem here. Ruby's require requires only once. Maybe the result of the load ought to be memoized in some way?

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Are you clearing the manager between all of your 5 test runs? You're going to want to do that anyway to lose the job history between runs - but I believe will also resolve your issues of calling run multiple times with a given manager.

from clockwork-test.

ce07c3 avatar ce07c3 commented on July 20, 2024

How do I clear it? I can try it, but the load would still happen within the same Ruby runtime, right - not solving the multiple load?

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Clockwork::Test.clear! gives you a new instance of the manager to call run against.

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Did that help you out?

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Thanks for responding. I apologize for not fully understanding the issue until taking another look at it today. I have a branch with a reproduction, where the commit message explains what is happening.

Note that I believe this is another manifestation of the problems in #1. I believe that resolving that would handle this issue as well. I would like to close this in favor of tracking a single issue with the same symptoms (though I'll reference this in there). Sound good?

I welcome contributions to help resolve this.

from clockwork-test.

ce07c3 avatar ce07c3 commented on July 20, 2024

I looked into it and the way the test library monkey patches clockwork makes me wonder if it isn't wiser to build hooks into clockwork itself.

Another issue: I haven't looked into how the time gem is used, but it does interfere with e.g. the Google gems:

"Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems."

I'll try to look into it during the week or weekend.

from clockwork-test.

kevin-j-m avatar kevin-j-m commented on July 20, 2024

Clockwork::Test does use Timecop to change time if you specify what you want the time to be. However, it also returns it at the conclusion of a run.

Any issue with time traveling seems unrelated to this initial report. And I would use clockwork tests exclusively to validate the correctness/accuracy of your clock file. I wouldn't additionally perform any functionality testing in there.

I'm going to close this issue in favor of tracking with #1.

from clockwork-test.

ce07c3 avatar ce07c3 commented on July 20, 2024

It's related in the sense that Clockwork::Test alters core libraries such as Time leading to additional failures because there are side effects, e.g. clock skew. I am not testing additional functionality in our clock tests. It's hard to reproduce because it depends on the order of tests and what tests also depend on an accurate time measurement, but for now, I'd say that there probably need to be hooks in the original gem rather than monkeypatching it like this.

from clockwork-test.

Related Issues (15)

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.