Remove calls to drupal_valid_test_ua() from production code

Created on 4 March 2025, 5 months ago

Problem/Motivation

There are a bunch of places in the production code where we call drupal_valid_test_ua() to facilitate test-only flags and behavior. Convenient at the time, but it makes maintainers pretty sad, so maybe we can try to remove these calls and find cleaner ways to accomplish the same things.

๐Ÿ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arunsahijpal

    Hi @phenaproxima,
    That makes senseโ€”mixing test-related logic into production code with drupal_valid_test_ua() can make the codebase harder to maintain.
    So I'm planning to Introduce a service to determine test mode (TestModeChecker), and will replace drupal_valid_test_ua() calls with service usage.

    Would it be a good solution?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    I don't think that would really solve the problem, to be honest; the idea is to remove any testing-related code from the production code. There are other approaches we can take, but they'll vary based on the specific use. In other words, we're going to need a few different approaches for this one.

    I'll take this on!

  • Assigned to phenaproxima
  • Pipeline finished with Failed
    21 days ago
    #554064
  • Pipeline finished with Failed
    21 days ago
    #554066
  • Pipeline finished with Failed
    21 days ago
    #554080
  • Pipeline finished with Failed
    21 days ago
    #554100
  • Pipeline finished with Failed
    21 days ago
    #554117
  • Pipeline finished with Failed
    21 days ago
    Total: 663s
    #554201
  • Pipeline finished with Failed
    21 days ago
    #554207
  • Pipeline finished with Failed
    18 days ago
    Total: 602s
    #556871
  • Pipeline finished with Failed
    18 days ago
    #557041
  • Pipeline finished with Canceled
    18 days ago
    #557051
  • Pipeline finished with Failed
    18 days ago
    #557054
  • Pipeline finished with Canceled
    18 days ago
    #557057
  • Pipeline finished with Canceled
    18 days ago
    #557064
  • Pipeline finished with Failed
    18 days ago
    #557066
  • Pipeline finished with Failed
    18 days ago
    #557074
  • Pipeline finished with Running
    18 days ago
    #557079
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    This doesn't go as far as I would like, but trying to completely remove switches that are only used for testing turned out to be a little bit dragon-shaped. I think we can have follow-ups to properly do the remainder of the cleanup (i.e., making certain things actual configuration options), but this at least gets rid of the ugly calls to drupal_valid_test_ua().

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Tagging for backport to 2.0.x.

  • Pipeline finished with Success
    15 days ago
    Total: 589s
    #558914
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tim.plunkett Philadelphia

    This looks good. I remember feeling a way about having `drupal_valid_test_ua()` in runtime code when we added it, glad to see it gone.

  • First commit to issue fork.
  • Pipeline finished with Success
    14 days ago
    Total: 428s
    #559723
  • Pipeline finished with Skipped
    14 days ago
    #559749
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States chrisfromredfin Portland, Maine

    rebased and merged onto 2.1.x, conflicts in backport

  • Merge request !837Backport โ†’ (Merged) created by phenaproxima
  • Pipeline finished with Failed
    14 days ago
    Total: 419s
    #559785
  • Pipeline finished with Failed
    14 days ago
    Total: 1198s
    #559806
  • Pipeline finished with Failed
    14 days ago
    Total: 267s
    #559831
  • Pipeline finished with Success
    14 days ago
    Total: 719s
    #559837
  • Pipeline finished with Skipped
    14 days ago
    #559851
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States chrisfromredfin Portland, Maine

    backported! thanks, @phenaproxima

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024