]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
ptest-cargo.bbclass: fix condition to detect test executable
authorFrederic Martinsons <frederic.martinsons@gmail.com>
Thu, 6 Jul 2023 09:16:16 +0000 (11:16 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 14 Jul 2023 16:31:02 +0000 (17:31 +0100)
before that, a test executable at None was picked.
Moreover, use universal_newlines to subprocess call to avoid
being polluted by fancy carriage return characters.

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/ptest-cargo.bbclass

index 4ed528445a7cb743a6490eeebb8472f94bd195d4..5d53abe9691f076d672b9a2f3d8b76d7f7441d72 100644 (file)
@@ -23,13 +23,13 @@ python do_compile_ptest_cargo() {
     bb.note(f"Building tests with cargo ({cmd})")
 
     try:
-        proc = subprocess.Popen(cmd, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        proc = subprocess.Popen(cmd, shell=True, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
     except subprocess.CalledProcessError as e:
         bb.fatal(f"Cannot build test with cargo: {e}")
 
     lines = []
     for line in proc.stdout:
-        data = line.decode('utf-8').strip('\n')
+        data = line.strip('\n')
         lines.append(data)
         bb.note(data)
     proc.communicate()
@@ -50,7 +50,7 @@ python do_compile_ptest_cargo() {
                 current_manifest_path = os.path.normpath(data['manifest_path'])
                 project_manifest_path = os.path.normpath(manifest_path)
                 if current_manifest_path == project_manifest_path:
-                    if data['target']['test'] or data['target']['doctest'] and data['executable']:
+                    if (data['target']['test'] or data['target']['doctest']) and data['executable']:
                         test_bins.append(data['executable'])
             except KeyError as e:
                 # skip lines that do not meet the requirements