Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sIUej-00FzdK-Aj for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2024 14:45:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sIUeg-00EF8I-T4 for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2024 14:45:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sIUeg-00EF89-Do for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2024 14:45:23 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sIUed-001oLy-VE for pgsql-hackers@postgresql.org; Sat, 15 Jun 2024 14:45:22 +0000 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-440581d6a50so17171031cf.0 for ; Sat, 15 Jun 2024 07:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1718462718; x=1719067518; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:subject:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=xQYCEaD5EpsD6sDvMHGTlGIw6JA1h98Nj5zQA61zveY=; b=nrGb4TtMwvLg/n6vpYbf94biheaFEglqVhyAyuPORLlzLB8axM9I8SCoeQbWW8Srx/ 1pWvGpEHcOZ1ulf4CxacjXtRSL6OFwLhoaH6igQxQNTWI2ciPYxvnF+UN+J54EFwsX48 KdABxA7jqPXXgtcQddosP+yQW60cc8x/WoKtEALy6fi1neCu6rX3XRGbAHdCOi3bA+0n 2J6oSZKzdqE47gGpztF3BOr4jeQIik73dt0bTSbVugqGqnpJiDvRSaAhKzMPUoNiedRW waHqpAjKt1GjOjGUc8x5K3sMZTSmVNBoPfrCBkQS7k9A5SIvX2a2dI8/cQ8kGX7FY3et hiYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718462718; x=1719067518; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:subject:from:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xQYCEaD5EpsD6sDvMHGTlGIw6JA1h98Nj5zQA61zveY=; b=tnbEayHIRmmIxniHwzM2uVZcAQQbWIT5c9qSvw4vInFtDJy9j+4h/hrPBG7QFMtWyK rOrGfPEM+8Ri5gUJlzgVxcTCiushGwcIudl+3rGzPl9mlCPGn/CuhJZbXZQD0xWgmMWn JA2h3r0KcO9q+rvzDgU0Lk1P6qD/TmNc50pGTLgdJ8NE7lqcKobIzQ7CRi1xOsIRRaeW yHNWo2QCdZ08jkIThGLYSq/EgP82x25QRvAntfS8xeVnGX388vmIUjwutbIACfWCi03j 4ljkZ2JZH1Cq/eBeSQlwFi6TDSd0fBjgr9jrBgiDnWUbUtZfolcvEmwHp3TE8armH5nx li/A== X-Forwarded-Encrypted: i=1; AJvYcCVhseG71C53bqeQ0prd05aDnkHMV2uNE56lEc2VND8tOlFrmCyBwVIH0fY00fE/dIo4M8FZszUTKipVuuHHG4zea5JQsU+JNYX6IfgS X-Gm-Message-State: AOJu0Yz4yNjBpblFzGLqiBM5uJipJQ2AAME0MwcUayUV/oMk4TEzrBHH QAyO4stgyn+qgpyaMpcybEEUj60rRCDLSJly9DbB1E+KJtqUF6how7O5TdPGIL4= X-Google-Smtp-Source: AGHT+IFUMUTTfsNbu0xhql2lGLv5zI1YLen/HHBgusEGWvTizKmao6M6U8JRWbvWO7GPll3FMRUZtg== X-Received: by 2002:a05:622a:12:b0:441:5642:aaec with SMTP id d75a77b69052e-4421687be96mr61041471cf.26.1718462717982; Sat, 15 Jun 2024 07:45:17 -0700 (PDT) Received: from ?IPV6:2605:a601:9180:9800::2bb? ([2605:a601:9180:9800::2bb]) by smtp.googlemail.com with ESMTPSA id d75a77b69052e-4420c5e8e4bsm27111831cf.39.2024.06.15.07.45.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 Jun 2024 07:45:17 -0700 (PDT) Message-ID: Date: Sat, 15 Jun 2024 10:45:16 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Andrew Dunstan Subject: Re: RFC: adding pytest as a supported test framework To: Jelte Fennema-Nio , Tom Lane Cc: Robert Haas , Jacob Champion , Daniel Gustafsson , Andres Freund , PostgreSQL Hackers References: <20240612155040.u6cvatdb5tiwcxci@awork3.anarazel.de> <2302192.1718380169@sss.pgh.pa.us> Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNJEFuZHJldyBEdW5zdGFuIDxhbmRyZXdAZHVuc2xhbmUubmV0PsLAmwQTAQgARQIbAwIX gAIZAQULCQgHAgMiAgEGFQoJCAsCBBYCAwECHgcW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HRzC1jgQNidyd6tKqcsVJs0dzF0oKTmFFmUAqTdJO12LBuNA1rlqrR3EtpYk8B/wtS 5dIMD7Q8hwQpL+4C6GNpb6ZKnPkLi47pDOLhz2qBrqN+rqUEsT3YnExYpzj5yOBi+FlmV1Hw 49QYe1sn2ZPs In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-06-14 Fr 18:11, Jelte Fennema-Nio wrote: > On Fri, 14 Jun 2024 at 17:49, Tom Lane wrote: >> But what I'd really like to see is some comparison of the >> language-provided testing facilities that we're proposing >> to depend on. Why is pytest (or whatever) better than Test::More? > Some advantages of pytest over Test::More: > > 1. It's much easier to debug failing tests using the output that > pytest gives. A good example of this is on pytest its homepage[1] > (i.e. it shows the value given to the call to inc in the error) > 2. No need to remember a specific comparison DSL > (is/isnt/is_deeply/like/ok/cmp_ok/isa_ok), just put assert in front of > a boolean expression and your output is great (if you want to add a > message too for clarity you can use: assert a == b, "the world is > ending") > 3. Very easy to postgres log files on stderr/stdout when a test fails. > This might be possible/easy with Perl too, but we currently don't do > that. So right now for many failures you're forced to traverse the > build/testrun/... directory tree to find the logs. I see the fact that we stash the output in a file as a feature. Without it, capturing failure information in the buildfarm client would be more difficult, especially if there are multiple failures. So this is actually something I think we would need for any alternative framework. Maybe we need an environment setting that would output the regress_log_00whatever file to stderr on failure.  That should be pretty easy to arrange in the END handler for PostgreSQL::Test::Utils. > 4. Pytest has autodiscovery of test files and functions, so we > probably wouldn't have to specify all of the exact test files anymore > in the meson.build files. I find this comment a bit ironic. We don't need to do that with the Makefiles, and the requirement to do so was promoted as a meson feature rather than a limitation, ISTR. > Regarding 2, there are ~150 checks that are using a suboptimal way of > testing for a comparison. Mostly a lot that could use "like(..., ...)" > instead of "ok(... ~= ...)" > ❯ grep '\bok(.*=' **.pl | wc -l > 151 Well, let's fix those. I would be tempted to use cmp_ok() for just about all of them. But the fact that Test::More has a handful of test primitives rather than just one strikes me as a relatively minor complaint. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com