[vlc-commits] [Git][videolan/vlc][master] 4 commits: src: Cargo.toml: fix warnings on workspace
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Jun 22 08:13:20 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
7e6f5783 by Alexandre Janniaux at 2024-06-22T07:48:04+00:00
src: Cargo.toml: fix warnings on workspace
Since we'll be using edition = "2021", and we have a virtual
workspace[^1], we need to specify the manifest resolver[^2].
Otherwise, cargo emits the following warning:
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
See release note[^3] for details on how this resolver changes the way
features are selected for packages inside the workspace.
[^1]: https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace
[^2]: https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html
[^3]: https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver
- - - - -
7afc811f by Alexandre Janniaux at 2024-06-22T07:48:04+00:00
buildsystem: cargo-test: add cargo test driver
Cargo can output the test results as JSON when running with unstable
options. This script provides an automake test driver[^1] to run the
tests and gather the results in the automake test suite.
[^1]: https://www.gnu.org/software/automake/manual/html_node/Overview-of-Custom-Test-Drivers-Support.html
- - - - -
a29952aa by Alexandre Janniaux at 2024-06-22T07:48:04+00:00
src: Makefile.am: initialize TEST_EXTENSIONS
TEST_EXTENSIONS might be setup from different makefiles included, so it
must be defined first.
- - - - -
97e8fd1e by Alexandre Janniaux at 2024-06-22T07:48:04+00:00
src: rust: add Makefile.am for tests
Tests are sufficiently integrated into the automake test suite, and only
a few features are missing:
- Handling skipping and xfailing for rust tests.
- Reporting tests by category (lib, doctest, etc) and being able to
disable a category, there's currently not enough test to justify
this right now.
- Handling the incremental building of tests, which currently seems to
be triggered everytime.
- - - - -
5 changed files:
- Makefile.am
- + buildsystem/cargo-test.py
- src/Makefile.am
- src/rust/Cargo.toml
- + src/rust/Makefile.am
Changes:
=====================================
Makefile.am
=====================================
@@ -10,6 +10,7 @@ SUBDIRS = compat po share src modules lib doc bin test
DIST_SUBDIRS = m4 $(SUBDIRS)
EXTRA_DIST = \
+ buildsystem/cargo-test.py \
buildsystem/check_qml_module.py \
extras/include/x86/x86inc.asm \
extras/include/x86/x86util.asm \
=====================================
buildsystem/cargo-test.py
=====================================
@@ -0,0 +1,93 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright (C) 2024 Alexandre Janniaux <ajanni at 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('--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
+cmd = ['cargo', 'test',
+ '--offline', '--locked',
+ '--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': os.environ['top_builddir'] + '/src/.libs',
+ 'LD_LIBRARY_PATH': os.environ['top_builddir'] + '/src/.libs',
+ }
+ )
+
+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()
=====================================
src/Makefile.am
=====================================
@@ -13,6 +13,7 @@ BUILT_SOURCES = $(nodist_pluginsinclude_HEADERS)
CLEANFILES = $(BUILT_SOURCES)
SUFFIXES = .pc.in .pc .rc.in .rc
+TEST_EXTENSIONS =
###############################################################################
# Headers
@@ -789,6 +790,8 @@ check-local:
done
$(SHELL) $(srcdir)/check_headers $(pluginsinclude_HEADERS)
+include rust/Makefile.am
+
FORCE:
@echo "Generated source cannot be phony. Go away." >&2
@exit 1
=====================================
src/rust/Cargo.toml
=====================================
@@ -3,3 +3,4 @@ members = [
"vlcrs-messages",
"vlcrs-sys-generator"
]
+resolver = "2"
=====================================
src/rust/Makefile.am
=====================================
@@ -0,0 +1,15 @@
+TEST_EXTENSIONS += .cargo
+CARGO_LOG_DRIVER = env top_builddir="${abs_top_builddir}" \
+ $(abs_top_srcdir)/buildsystem/cargo-test.py \
+ --working-directory="${abs_top_srcdir}/src/rust/"
+
+vlcrs-messages.cargo:
+vlcrs-utils.cargo:
+ cd $(top_srcdir)/src/rust/$(@:.cargo=) && env \
+ top_builddir="${abs_top_builddir}" \
+ cargo build
+if HAVE_RUST
+TESTS += \
+ vlcrs-messages.cargo \
+ vlcrs-utils.cargo
+endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7507ac72f4d0740bead5d23735cf682d2f50567f...97e8fd1edb947d1de748547667627b1cce112771
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7507ac72f4d0740bead5d23735cf682d2f50567f...97e8fd1edb947d1de748547667627b1cce112771
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list