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

Testing for WP_DEBUG #2329

Open
jarednova opened this issue Oct 5, 2020 · 2 comments
Open

Testing for WP_DEBUG #2329

jarednova opened this issue Oct 5, 2020 · 2 comments

Comments

@jarednova
Copy link
Member

As noted in #2327, we should consider methods to test when WP_DEBUG is disabled in order to catch potential errors or issues involved in its setting

@acobster
Copy link
Collaborator

One way we could potentially do this is at the CI level, where WP_DEBUG is defined in a bootstrap file according to an environment variable. This would double the compute resources for every test run, though, so I'm not totally convinced it's worth it. The "blast radius" for WP_DEBUG being enabled vs. disabled is not even close to the size of the entire codebase, so a 2x increase in resources needed to test this indicates a design problem to me.

If we're really invested in testing these different code paths, we could abstract over WP_DEBUG with an internal filter, and hook into them from each test for the features we care about:

public function test_with_debug() {
  $stuff_is_normal = do_normal_stuff();
  $this->assertTrue( $stuff_is_normal );
}

public function test_with_debug_disabled() {
  $this->add_filter_temporarily( 'timber/internal/debug', '__return_false' );
  $stuff_is_normal = do_normal_stuff();
  $this->assertFalse( $stuff_is_normal );
}

@jarednova
Copy link
Member Author

@acobster I think for now your suggestion on using the bootstrap file is a good answer for "consider ...". We could perhaps run this once a week or some other regular interval so it doesn't slow down normal test execution. A good thing to consider, but not high priority versus other stuff right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants