From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3BF33D524 for ; Thu, 21 Sep 2023 10:17:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1D9B31D6EA for ; Thu, 21 Sep 2023 10:16:35 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 21 Sep 2023 10:16:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6B26D48526 for ; Thu, 21 Sep 2023 10:16:33 +0200 (CEST) Message-ID: <8813586d-bf7c-42b7-84ff-9f9eaa745b4d@proxmox.com> Date: Thu, 21 Sep 2023 10:16:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Hannes Laimer , Proxmox Backup Server development discussion References: <20230915065457.352953-1-h.laimer@proxmox.com> <20230915065457.352953-4-h.laimer@proxmox.com> <40808fbd-70c7-4c95-a335-67e079891345@proxmox.com> Content-Language: de-AT, en-US From: Lukas Wagner In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rust-lang.org] Subject: Re: [pbs-devel] [PATCH proxmox-backup 03/23] maintenance: add 'Unpplugged' maintenance type X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2023 08:17:05 -0000 On 9/21/23 09:41, Hannes Laimer wrote: >> >> It's always advisable to have tests in separate submodule: >> >> #[cfg(test)] >> mod tests { >>      use super::*; >> >>      #[test] >>      fn test_check() { >>         ... >>      } >> } >> >> This makes sure that the test(s) is/are not compiled during a normal >> build :) >> > Correct me if I'm wrong but, AFAIK `#[test]` does that, and since this > is the only and very simple test a whole mod thing seemed a bit > overkill, so I stuck with just `#[test]`. I stand corrected, you are indeed right. To quote [1]: The test attribute marks a function to be executed as a test. These functions are only compiled when in test mode. Maybe I misremember some edge case where this was not the case, or maybe it was the way I described some time ago and they changed it. TIL. Anyway, I still think it is good practice to put tests in a separate module, as it cleanly separates test code from production code. For a single function this does not make much difference, but maybe somebody else will add some more tests, extract common test setup code into helpers, etc. - then they would need to touch the existing code anyway and move it in a module. In other words, I think it's good to do it the 'clean' way right from the start. :) [1] https://doc.rust-lang.org/reference/attributes/testing.html -- - Lukas