Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  cargo-test.py   Sprache: Python

 

#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1-or-later
# Copyright (C) 2024 Alexandre Janniaux <ajanni@videolabs.io>
#
# Helper script to implement a cargo-based automake test driver.
# See modules/Makefile.am and included Makefile for usage.

import os, sys
import argparse

parser = argparse.ArgumentParser(
    prog='cargo-test',
    description='Automake test driver for cargo-based tests')

parser.add_argument('--test-name')
parser.add_argument('--log-file')
parser.add_argument('--trs-file')
parser.add_argument('--color-tests')
parser.add_argument('--expect-failure')
parser.add_argument('--enable-hard-errors')
parser.add_argument('--host', required=True)
parser.add_argument('--working-directory', default=os.getcwd())

args = []
other_args = None
for arg in sys.argv[1:]:
    if other_args is not None:
        other_args.append(arg)
        continue
    if arg == "--":
        other_args = []
        continue
    args.append(arg)
args = parser.parse_args(args)

test_name = args.test_name
if test_name.endswith('.cargo'):
    test_name = test_name[:-len('.cargo')]

# TODO: handle also additional parameter to select sub-tests
# test_name = "::".join(args.test_name.split('.')[1:-1])

import subprocess, os

lib_dir = os.environ['top_builddir'] + '/src/.libs'

rust_triple = args.host

cmd = ['cargo', 'test',
       '--offline', '--locked',
       '--config', f'target.{rust_triple}.vlccore.rustc-link-lib=["vlccore"]',
       '--config', f'target.{rust_triple}.vlccore.rustc-link-search=["{lib_dir}"]',
       '--config', f'target.{rust_triple}.vlccore.rustc-link-arg=["-Wl,-rpath,{lib_dir}"]',
       '--color', 'always' if args.color_tests == 'yes' else 'never',
       '--package', test_name,
       '--',
       '-Z', 'unstable-options',
       '--format=json', '--show-output']

out = subprocess.run(
    cmd,
    cwd=args.working_directory,
    capture_output=True,
    text=True,
    close_fds=False, # Necessary for jobserver
    env=os.environ | {
        'DYLD_LIBRARY_PATH': lib_dir,
        'LD_LIBRARY_PATH': lib_dir,
        }
    )

sys.stderr.write(str(out.stderr))

import json
log_file = open(args.log_file, 'wt')
trs_file = open(args.trs_file, 'wt')
for line in out.stdout.splitlines():
    meta = json.loads(line)
    if meta['type'] == 'test' and \
       meta['event'] in ['ok', 'failed']:
        result = 'PASS' if meta['event'] == 'ok' else 'FAIL'

        PASS = '\033[92m'
        FAIL = '\033[91m'
        ENDC = '\033[0m'
        color = PASS if meta['event'] == 'ok' else FAIL
        if args.color_tests == 'yes':
            print('{}{}{}: {}'.format(color, result, ENDC, meta['name']))
        else:
            print('{}: {}'.format(result, meta['name']))
        trs_file.write(':test-result: {} {}\n'.format(result, meta['name']))
        log_file.write('test: {}\n{}\n\n'.format(meta['name'], meta.get('stdout', '')))
log_file.close()

# TODO: define :global-test-result: correctly
trs_file.write(':global-test-result: {}\n'.format('PASS'))

# TODO: define :recheck: correctly
trs_file.write(':recheck: no\n')

trs_file.write(':copy-in-global-log: no\n')
trs_file.close()

Messung
CHZG
839710093

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104848
#Domains=416967