From patchwork Sat Jul 29 05:09:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 28087 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE81DC0015E for ; Sat, 29 Jul 2023 05:09:41 +0000 (UTC) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web11.49364.1690607375634884676 for ; Fri, 28 Jul 2023 22:09:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XAuRkJ8G; spf=pass (domain: gmail.com, ip: 209.85.221.44, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-31763b2c5a4so2868819f8f.3 for ; Fri, 28 Jul 2023 22:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690607373; x=1691212173; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=v9g6073G52Nf+Ro5gKHW2nFK0TyfBimij3E/elO8E8o=; b=XAuRkJ8G6xs8gSgfhqatc8O1W7rkKkNll6XPN6TATmEllMoPXKAeBe7+xDEx2tmLcp NF+iC8dawjHkJTTbS98qDRP8O3oqAi9QPJQfrzCaWVt1/tZl6kkc/iwSYeMVniI76Xos Aik7FnAP4EnSiWOkFvhr111i6npYlVC4HKmEa4VzAQ6kiec9hoFyMiC2K/8LyE3dncYF V+F+BEccqPn7p3z5iilSvMmUe2PY8E2qL07DyO6OXvmEGq0YfjTlJp8XhLidUTmx6VP3 5ip20ChGCYwEUwe1aD9iGmC9tQcvYbhfA3ucQDvJ5P/6IVOTyjcqg+I0iO3c5XpnFYu3 Hzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690607373; x=1691212173; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=v9g6073G52Nf+Ro5gKHW2nFK0TyfBimij3E/elO8E8o=; b=ebg/MH2/zMlv+EKmPx7sprnK7ak/bfjE43cwFDoaa6ZcJsF1Uzo2RiZWqB7U3KEEjr Qi3njdLyCQiW9huN7Hy+NHuv2w5ueym0Fy+sq73gfku0OSfxotqzwssOY723UjIm3MLT empbJvsYdpI3xb/uH2giCP6gLJ8pwdsWNcvt4hdKjLkpBq8Bzqc0KRq4ikhWudeE2EmL Jn184vm8uXe9LoU4OYaefaWokeyjRK5MkNKiRVbMMA0OAxUbx7NYFMErgT7MxWexxTe1 JgmBLIDLT2WLws2SW1mTocJLnyuQn11xxjGKL4s7AbKRTl3ySo1RjmY8qfOUz3rDnQXq /L+Q== X-Gm-Message-State: ABy/qLYgsHSZwUu8doX77owXNxHGiWr1V2iiSbM2qsE0gWfGTCd8bDgp 1a/HbjBqE0UOLWVGwzhlnN4nlDNZLE0= X-Google-Smtp-Source: APBJJlGyxlLkhZ9pkYCA3pUIH6JnMhm209+FdCwqYcPfoNapWZUjeQTrWY+kEP/i2K5wjzy6P9og0A== X-Received: by 2002:a5d:4b03:0:b0:314:50d:4540 with SMTP id v3-20020a5d4b03000000b00314050d4540mr3890258wrq.18.1690607373411; Fri, 28 Jul 2023 22:09:33 -0700 (PDT) Received: from work-pc.sigfox.io ([2a01:e0a:8d5:c6c0:6c97:10b2:99c8:d41]) by smtp.gmail.com with ESMTPSA id f17-20020adffcd1000000b00313f61889ecsm6482356wrs.66.2023.07.28.22.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 22:09:32 -0700 (PDT) From: frederic.martinsons@gmail.com To: openembedded-core@lists.openembedded.org Cc: Frederic Martinsons Subject: [PATCH] ptest-cargo.bbclass: Support of cargo workspaces Date: Sat, 29 Jul 2023 07:09:21 +0200 Message-Id: <20230729050921.139912-1-frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 29 Jul 2023 05:09:41 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/185045 From: Frederic Martinsons For complex project, it is very common to have multiple sub artifacts and so use workspaces, sometimes it has even no root artifacts (but several bin or lib) and virtual manifest is used for that. Long story short, support this case in ptest-cargo class to look for all test binaries in the current project and no more those generated by the root Cargo.toml Signed-off-by: Frederic Martinsons --- meta/classes-recipe/ptest-cargo.bbclass | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index 5d53abe969..ff57be8525 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass @@ -16,6 +16,8 @@ python do_compile_ptest_cargo() { cargo_build_flags = d.getVar("CARGO_BUILD_FLAGS", True) rust_flags = d.getVar("RUSTFLAGS", True) manifest_path = d.getVar("MANIFEST_PATH", True) + project_manifest_path = os.path.normpath(manifest_path) + manifest_dir = os.path.dirname(manifest_path) env = os.environ.copy() env['RUSTFLAGS'] = rust_flags @@ -46,13 +48,15 @@ python do_compile_ptest_cargo() { pass else: try: - # Filter the test packages coming from the current manifest + # Filter the test packages coming from the current project: + # - test binaries from the root manifest + # - test binaries from sub manifest of the current project if any current_manifest_path = os.path.normpath(data['manifest_path']) - project_manifest_path = os.path.normpath(manifest_path) - if current_manifest_path == project_manifest_path: + common_path = os.path.commonpath([current_manifest_path, project_manifest_path]) + if common_path in [manifest_dir, current_manifest_path]: if (data['target']['test'] or data['target']['doctest']) and data['executable']: test_bins.append(data['executable']) - except KeyError as e: + except (KeyError, ValueError) as e: # skip lines that do not meet the requirements pass