Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117013 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91926 invoked from network); 11 Feb 2022 14:10:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2022 14:10:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 64685180382 for ; Fri, 11 Feb 2022 07:26:45 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 11 Feb 2022 07:26:41 -0800 (PST) Received: by mail-il1-f176.google.com with SMTP id d7so1329871ilf.8 for ; Fri, 11 Feb 2022 07:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Y1/C3yFYCns9HBzBV2zMvPU6iDeeyrXnPSgXyfF9kjo=; b=dfXzVg55pS8vGv+/hkxtQFQy6WIbLn1MvZ82X6PD0l3wcYqt+Bast92jymUYwURjLf 7v7AtBXutJcJIOyW2EEAv4g2Tn6NV6BaJ5RdtpE1/bDfLjpvGy+dHtvpvwy7L9oB1qOS yH44lsydKbZZgqMkO9yHWWp5ZSO9mb4XLqsHx45/mQEXma7SElPCM0VTZTag7j873PuV 21dJUefSsgR4G5C9kx2MJwuOczxe7lfm+QQeM7bTypjG3lXxfzEidnft2skEsPrhJKNx FmNrQdicbhzoN8YwRFJ5hEUYgxBYLS8JAqIHBB3VhlmTsb2Uz1XIHgb82eyLpGeDnFSy FbMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Y1/C3yFYCns9HBzBV2zMvPU6iDeeyrXnPSgXyfF9kjo=; b=OObrr99Aimrgi4LhL0VlvMFIifm0cPyEy50eJRfKOGwBYeRmPbo4fEmTkt1Ds3JQc/ cewX3U7pl7CLSUGaoX5CwMmw9kBwDLRad1hiKlvh1jt37YHewQ3mabp+JKk2NJmVKG6i iyO3o5myVHk6vFvTI/zBdhlJbTfF+6tPmDHBJ64mTn6sox0zJDIJ7Ojn13fsC3QhVpk/ vf8sIEjWUGu+qi9CcfYVWKdY7BPxAH2I/KUnuIAObQIiLXaxrXcX3lGFfTHYjVyAtsHw mTJueSH2LNgbRtIchWczUXo+nPXA9b8M1c59CAZgEtdcNGTPL9yY9IdbJWWsPfRL5hPa ZYVw== X-Gm-Message-State: AOAM531QKcnw5b5JlhQlwoddDChhCjZ2OcB9gaOF/9kZUXqTjYpBjIxs 0WURRr0JJBdLRXFKggek/rAjdYCMwGnKOKJzCfcy3r2MIps= X-Google-Smtp-Source: ABdhPJwvGHrP5qm92t9xpjlkSWHAzc40HRTqV+ki8S2c+BKLy35IN/HDX8ivy3TaGV4sFBti8bHr3koHtVlJc25p2vU= X-Received: by 2002:a92:904:: with SMTP id y4mr1166219ilg.83.1644593200698; Fri, 11 Feb 2022 07:26:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 11 Feb 2022 10:26:29 -0500 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="000000000000871da305d7bfb143" Subject: Re: [PHP-DEV] run-tests SKIPIF caching can be problematic for third-party extensions From: jmikola@gmail.com (Jeremy Mikola) --000000000000871da305d7bfb143 Content-Type: text/plain; charset="UTF-8" The reply below is from Sept 24, 2021. I just realized that I inadvertently responded to Nikita dierctly and never shared to the mailing list. Doing so now to close the loop on some open questions and provide more context for a PR I recently opened (https://github.com/php/php-src/pull/8076). Since this last message, I'll note that a mechanism to disable SKIPIF caching entirely was ultimately merged in https://github.com/php/php-src/commit/9fc6be297fc775c659d5e04b7a4a591bc8577f8a . ---- I'm not sure I understand the setup you're using. The "nocache" tag that > mysqli uses covers the situation where part of the test setup is done in > the SKIPIF section -- because checking whether the test should be skipped > requires doing the same setup as the actual test. If the test does get > skipped, it's still fine to cache that. > > Now, it sounds like your situation is different from that, and you > actually have SKIPIF sections where first one test should be skipped, but > then a later test with identical SKIPIF shouldn't be skipped. Is that > correct? What changes between the time these two tests run? > To avoid code duplication across SKIPIF blocks, we have several helper functions ( https://github.com/mongodb/mongo-php-driver/blob/master/tests/utils/skipif.php). In addition to environmental checks (e.g. server, PHP version), we have one function that ensures the collection (table equivalent) under test is empty. Based on the mysqli tests I saw, those SKIPIF blocks are quite large and contain literal references to the schema, which leads to them being cached independently. In our case, the functions called from our SKIPIF blocks often rely on default values for arguments (e.g. COLLECTION_NAME). The definitions for these constants are derived from a filename ( https://github.com/mongodb/mongo-php-driver/blob/master/tests/utils/basic.inc), which ensures each test uses a different collection. Unfortunately, this also means many of our SKIPIF blocks end up having identical code and thus share the same cache entry. https://github.com/mongodb/mongo-php-driver/blob/master/tests/cursor/bug0671-001.phpt is an example of a common SKIPIF block, which ensures that the server is accessible and that the collection under test is empty (i.e. that we can successfully drop it). I think I was able to work around our issue with https://github.com/mongodb/mongo-php-driver/commit/ce6b11d475fb1ff19afed29bcf5b89c200f82440, but echoing "nocache\n" after a successful drop -- and only for PHP 8.1+ to avoid borks on earlier versions); however, this approach only allows us to opt out of caching for non-skips. Hypothetically, if we encounter an error dropping the collection for tests/cursor/bug0671-001.phpt and that test is skipped, it's not desirable for run-tests.php to immediately skip the subsequent bug0732-001.phpt test simply because the code in its SKIPIF block is identical. The risk here is that our test suite skips more tests than expected or are necessary. > Independently of that question (which is about whether "nocache" is > sufficient if we ignore cross-version compatibility issue) I do agree that > an option to disable the skip cache entirely would make sense. Would > https://github.com/php/php-src/pull/7510 work for you? > Being able to completely opt-out of SKIPIF caching seems generally useful. I'll take a look later today and provide some feedback on the PR. Thanks! -- jeremy mikola > On Thu, Sep 23, 2021 at 10:23 AM Nikita Popov wrote: > On Thu, Sep 23, 2021 at 4:10 PM Nikita Popov wrote: > >> On Wed, Sep 15, 2021 at 7:23 PM Jeremy Mikola wrote: >> >>> I just discovered that run-tests.php was changed to cache SKIPIF >>> evaluation >>> since 8.1.0beta3[1]. I believe ext-mongodb ran into the same issue as >>> mysqli[2], as we use SKIPIF to check that database contents are clean >>> going >>> into a test. The present solution in core is to check SKIPIF output for >>> "nocache" [3,4] and allow individual tests to opt out of caching; >>> however, >>> I'm worried that won't be portable for third-party extensions, where we >>> test with run-tests.php for each version of PHP that we support. >>> >>> Is there still time to consider an alternative solution? If "nocache" >>> needs >>> to remain in place for mysqli, perhaps 8.1.0's run-tests.php can be >>> enhanced to consult an environment variable (for maximum BC and playing >>> nice with `make test`) that disables caching entirely. >>> >> >> I'm not sure I understand the setup you're using. The "nocache" tag that >> mysqli uses covers the situation where part of the test setup is done in >> the SKIPIF section -- because checking whether the test should be skipped >> requires doing the same setup as the actual test. If the test does get >> skipped, it's still fine to cache that. >> >> Now, it sounds like your situation is different from that, and you >> actually have SKIPIF sections where first one test should be skipped, but >> then a later test with identical SKIPIF shouldn't be skipped. Is that >> correct? What changes between the time these two tests run? >> > > Independently of that question (which is about whether "nocache" is > sufficient if we ignore cross-version compatibility issue) I do agree that > an option to disable the skip cache entirely would make sense. Would > https://github.com/php/php-src/pull/7510 work for you? > > Regards, > Nikita > -- jeremy mikola --000000000000871da305d7bfb143--