Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B84E0C433F5 for ; Sat, 2 Apr 2022 17:07:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4CB808396C; Sat, 2 Apr 2022 19:06:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kt0l1qEJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FA3183994; Sat, 2 Apr 2022 19:06:36 +0200 (CEST) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F38AF83968 for ; Sat, 2 Apr 2022 19:06:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ed1-x536.google.com with SMTP id b15so6372036edn.4 for ; Sat, 02 Apr 2022 10:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gpSFDPaVgESieBR2/n7KepG2Fd8IEcvymXkRwpLg/ag=; b=kt0l1qEJlw8B9SaGwg+vdDkP1qXygy7DJTERthmvZ/1MgIqiKEt7rYivfGjom48c4d 1+36/xE+tcA0v9MAN6trhentVWbV74ntqFepf8mp65DgumLqUy9qs4xN+lwlrIYkfYfX 48p3hN96gA3PpOtL1swWX2AXxMYO/yvI1kSurdpVF9qpj/MZT72GK9hak4KHZlcAEmtF w0vmOl0ZhYmB3bdjoe6alCewo5gvDGkTmVti80KpYKC5NkDjz/vtbMLJLai+XUgiy+UG o72s5pRiIQI2KwuGjnpvjw1GlcNItiZXySvVsPga785H+dCZ5HrcHL90USNv6yOpP6vu ZGoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gpSFDPaVgESieBR2/n7KepG2Fd8IEcvymXkRwpLg/ag=; b=V2uiqzZPeOTtpzQbvF2uaf0WgKKxXNHEBA1mS4JiUStmo57EhcK+yxvRhT6u3o0y89 8E0617dunAtiR9ub2DxU8u23gJPwDqag1mCdu6yp5lVaDZP52okrnabj6LemmFU7YFKN jwtqtOYSom3j2o9/e3FMRY6h34YwcbYu59Qlun0IWgjtARVPEHOUaHdJPckoOlNITIuA +4AkRLpvBVE4BZh+eJ7GiVSaJy/JU9iztLHdIdD7HA+ed/PAWy3oEg3RKTDKwxNYqbBn kSS8gaHqNjDt9/j/o2JqaljyeDeoKuis+vhNF0k+k9CQ8NUkPWM/TFv4qkaOAWrDUv6P pUgw== X-Gm-Message-State: AOAM532t3aR9corTq47E3kBYNfEDa5IJMEjgVzp5IbJNN3oWO2llSNrG HJOKBGXjyHBDbbv27+2jW6lwHcbBzqE= X-Google-Smtp-Source: ABdhPJyLPdEB+EvezHu8iu1qrvhHNNBelq/7efe7hMkqeN/RY7bxuvkYqMklpCBzppSt1qJmdGUQKw== X-Received: by 2002:aa7:da99:0:b0:419:17be:ceb4 with SMTP id q25-20020aa7da99000000b0041917beceb4mr26273380eds.303.1648919187598; Sat, 02 Apr 2022 10:06:27 -0700 (PDT) Received: from localhost.localdomain ([178.233.178.185]) by smtp.gmail.com with ESMTPSA id qb24-20020a1709077e9800b006e029bd4c24sm2268198ejc.193.2022.04.02.10.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 10:06:27 -0700 (PDT) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Walter Lozano , Simon Glass , Alper Nebi Yasak Subject: [PATCH 2/5] patman: test_util: Handle nonexistent tests while loading tests Date: Sat, 2 Apr 2022 20:06:05 +0300 Message-Id: <20220402170609.17790-3-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220402170609.17790-1-alpernebiyasak@gmail.com> References: <20220402170609.17790-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean It's possible to request a specific test to run when trying to run a python tool's tests. If we request a nonexistent test, the unittest loaders generate a fake test that reports this as an error. However, we get these fake tests even when the test exists, because test_util can load tests from multiple places one by one and the test we want only exists in one. The test_util helpers currently remove these fake tests when printing test results, but that's more of a workaround than a proper solution. Instead, don't even try to load the missing tests. Signed-off-by: Alper Nebi Yasak --- tools/patman/test_util.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 8b2220dbbafc..a4c2a2c3c0b2 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -110,19 +110,6 @@ def report_result(toolname:str, test_name: str, result: unittest.TestResult): test_name: Name of test that was run, or None for all result: A unittest.TestResult object containing the results """ - # Remove errors which just indicate a missing test. Since Python v3.5 If an - # ImportError or AttributeError occurs while traversing name then a - # synthetic test that raises that error when run will be returned. These - # errors are included in the errors accumulated by result.errors. - if test_name: - errors = [] - - for test, err in result.errors: - if ("has no attribute '%s'" % test_name) not in err: - errors.append((test, err)) - result.testsRun -= 1 - result.errors = errors - print(result) for test, err in result.errors: print(test.id(), err) @@ -184,10 +171,12 @@ def run_test_suites(result, debug, verbosity, test_preserve_dirs, processes, preserve_outdirs=test_preserve_dirs and test_name is not None, toolpath=toolpath, verbosity=verbosity) if test_name: - try: + # Since Python v3.5 If an ImportError or AttributeError occurs + # while traversing a name then a synthetic test that raises that + # error when run will be returned. Check that the requested test + # exists, otherwise these errors are included in the results. + if test_name in loader.getTestCaseNames(module): suite.addTests(loader.loadTestsFromName(test_name, module)) - except AttributeError: - continue else: suite.addTests(loader.loadTestsFromTestCase(module)) if use_concurrent and processes != 1: -- 2.35.1