Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package mpv-mpris for openSUSE:Factory 
checked in at 2022-06-18 22:06:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mpv-mpris (Old)
 and      /work/SRC/openSUSE:Factory/.mpv-mpris.new.1548 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mpv-mpris"

Sat Jun 18 22:06:05 2022 rev:3 rq:983511 version:0.8.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/mpv-mpris/mpv-mpris.changes      2021-11-24 
23:54:51.512401273 +0100
+++ /work/SRC/openSUSE:Factory/.mpv-mpris.new.1548/mpv-mpris.changes    
2022-06-18 22:06:09.923654024 +0200
@@ -1,0 +2,20 @@
+Fri Jun 17 23:04:06 UTC 2022 - Mia Herkt <m...@0x0.st>
+
+- Update to 0.8.1
+  * Fix Unknown Artist for YouTube videos
+    #gh/hoyon/mpv-mpris#76
+  * Emit signal for fullscreen event
+    #gh/hoyon/mpv-mpris#78
+
+-------------------------------------------------------------------
+Wed Jun 15 17:02:27 UTC 2022 - Mia Herkt <m...@0x0.st>
+
+- Update to 0.7.1
+  * Add test suite
+  * Emit Stopped Signal on exit.
+    #gh/hoyon/mpv-mpris#61
+    #gh/hoyon/mpv-mpris#22
+  * Set xesam:artist to channel name for YouTube videos.
+    #gh/hoyon/mpv-mpris#50
+
+-------------------------------------------------------------------

Old:
----
  mpv-mpris-0.6.tar.gz

New:
----
  mpv-mpris-0.8.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mpv-mpris.spec ++++++
--- /var/tmp/diff_new_pack.419xBY/_old  2022-06-18 22:06:10.407654711 +0200
+++ /var/tmp/diff_new_pack.419xBY/_new  2022-06-18 22:06:10.411654717 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package mpv-mpris
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,21 +17,24 @@
 
 
 Name:           mpv-mpris
-Version:        0.6
+Version:        0.8.1
 Release:        0
 Summary:        MPRIS plugin for mpv
 License:        MIT
 Group:          Productivity/Multimedia/Video/Players
 URL:            https://github.com/hoyon/mpv-mpris
 Source0:        
https://github.com/hoyon/mpv-mpris/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+BuildRequires:  dbus-1
 BuildRequires:  mpv
 BuildRequires:  pkgconfig
+# BuildRequires:  sound-theme-freedesktop
+# BuildRequires:  xvfb-run
 BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(gio-unix-2.0)
 BuildRequires:  pkgconfig(glib-2.0) >= 2.58
 BuildRequires:  pkgconfig(mpv)
 Supplements:    mpv
-Obsoletes:      mpv-plugin-mpris
+Conflicts:      mpv-plugin-mpris
 
 %description
 This package contains a plugin for mpv which allows control of the
@@ -41,6 +44,7 @@
 
 %prep
 %setup -q
+%autopatch -p1
 
 %build
 %make_build
@@ -50,6 +54,10 @@
 mkdir -p %{buildroot}%{_sysconfdir}/mpv/scripts
 ln -s %{_libdir}/mpv/mpris.so %{buildroot}%{_sysconfdir}/mpv/scripts/mpris.so
 
+# test suite does not work on OBS VM
+# %%check
+# %%make_build test
+
 %files
 %license LICENSE
 %{_libdir}/mpv

++++++ mpv-mpris-0.6.tar.gz -> mpv-mpris-0.8.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/.github/workflows/build.yml 
new/mpv-mpris-0.8.1/.github/workflows/build.yml
--- old/mpv-mpris-0.6/.github/workflows/build.yml       2021-10-19 
22:59:59.000000000 +0200
+++ new/mpv-mpris-0.8.1/.github/workflows/build.yml     2022-06-18 
00:35:07.000000000 +0200
@@ -1,3 +1,4 @@
+---
 name: build
 
 on: [push, pull_request]
@@ -14,16 +15,39 @@
           sudo apt install libmpv-dev libglib2.0-dev
 
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
 
       - name: Build
         run: |
           make
 
       - name: Upload binary
-        uses: actions/upload-artifact@v2
+        uses: actions/upload-artifact@v3
         with:
           name: mpris.so
           path: mpris.so
           if-no-files-found: error
 
+      - name: Prepare for test
+        run: |
+          sudo apt install mpv playerctl sound-theme-freedesktop bash dbus 
xvfb xauth jq socat gawk
+
+      - name: Run tests
+        run: |
+          make test
+
+      - name: Check git files unmodified
+        run: |
+          git diff --exit-code HEAD
+
+      - name: Check .gitignore matches generated files
+        run: |
+          ! git ls-files --others --exclude-standard | grep .
+
+      - name: Cleanup generated files
+        run: |
+          make clean
+
+      - name: Check cleanup removed generated files
+        run: |
+          ! git ls-files --others | grep .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/.gitignore 
new/mpv-mpris-0.8.1/.gitignore
--- old/mpv-mpris-0.6/.gitignore        2021-10-19 22:59:59.000000000 +0200
+++ new/mpv-mpris-0.8.1/.gitignore      2022-06-18 00:35:07.000000000 +0200
@@ -1,2 +1,11 @@
 compile_commands.json
 mpris.so
+*.mpv.ipc.input.json
+*.mpv.ipc.output.json
+*.mpv.ipc
+*.mpv.log
+*.xvfb.log
+*.Xauthority
+*.socat.log
+*.exit-code.log
+*.stderr.log
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/Makefile new/mpv-mpris-0.8.1/Makefile
--- old/mpv-mpris-0.6/Makefile  2021-10-19 22:59:59.000000000 +0200
+++ new/mpv-mpris-0.8.1/Makefile        2022-06-18 00:35:07.000000000 +0200
@@ -1,17 +1,62 @@
 PKG_CONFIG = pkg-config
 
 INSTALL := install
+MKDIR := mkdir
+RMDIR := rmdir
+LN := ln
+RM := rm
 
-BASE_CFLAGS=-std=c99 -Wall -Wextra -O2 `$(PKG_CONFIG) --cflags gio-2.0 
gio-unix-2.0 glib-2.0 mpv`
-BASE_LDFLAGS=`$(PKG_CONFIG) --libs gio-2.0 gio-unix-2.0 glib-2.0`
+CFLAGS += -std=c99 -Wall -Wextra -O2 -pedantic $(shell $(PKG_CONFIG) --cflags 
gio-2.0 gio-unix-2.0 glib-2.0 mpv)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs gio-2.0 gio-unix-2.0 glib-2.0)
 
 SCRIPTS_DIR := $(HOME)/.config/mpv/scripts
 
+PREFIX := /usr/local
+PLUGINDIR := $(PREFIX)/lib/mpv-mpris
+SYS_SCRIPTS_DIR := /etc/mpv/scripts
+
+UID ?= $(shell id -u)
+
+.PHONY: \
+  install install-user install-system \
+  uninstall uninstall-user uninstall-system \
+  test \
+  clean
+
 mpris.so: mpris.c
-       $(CC) mpris.c -o mpris.so $(BASE_CFLAGS) $(CFLAGS) $(BASE_LDFLAGS) 
$(LDFLAGS) -shared -fPIC
+       $(CC) mpris.c -o mpris.so $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fPIC
+
+ifneq ($(UID),0)
+install: install-user
+uninstall: uninstall-user
+else
+install: install-system
+uninstall: uninstall-system
+endif
+
+install-user: mpris.so
+       $(MKDIR) -p $(SCRIPTS_DIR)
+       $(INSTALL) -t $(SCRIPTS_DIR) mpris.so
+
+uninstall-user:
+       $(RM) -f $(SCRIPTS_DIR)/mpris.so
+       $(RMDIR) -p $(SCRIPTS_DIR)
+
+install-system: mpris.so
+       $(MKDIR) -p $(DESTDIR)$(PLUGINDIR)
+       $(INSTALL) -t $(DESTDIR)$(PLUGINDIR) mpris.so
+       $(MKDIR) -p $(DESTDIR)$(SYS_SCRIPTS_DIR)
+       $(LN) -s $(PLUGINDIR)/mpris.so $(DESTDIR)$(SYS_SCRIPTS_DIR)
+
+uninstall-system:
+       $(RM) -f $(DESTDIR)$(SYS_SCRIPTS_DIR)/mpris.so
+       $(RMDIR) -p $(DESTDIR)$(SYS_SCRIPTS_DIR)
+       $(RM) -f $(DESTDIR)$(PLUGINDIR)/mpris.so
+       $(RMDIR) -p $(DESTDIR)$(PLUGINDIR)
 
-install: mpris.so
-       $(INSTALL) -Dt $(SCRIPTS_DIR) mpris.so
+test: mpris.so
+       $(MAKE) -C test
 
 clean:
-       rm mpris.so
+       rm -f mpris.so
+       $(MAKE) -C test clean
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/README.md new/mpv-mpris-0.8.1/README.md
--- old/mpv-mpris-0.6/README.md 2021-10-19 22:59:59.000000000 +0200
+++ new/mpv-mpris-0.8.1/README.md       2022-06-18 00:35:07.000000000 +0200
@@ -5,13 +5,38 @@
 
 This plugin implements the MPRIS D-Bus interface and can be controlled using
 tools such as [playerctl](https://github.com/acrisci/playerctl) or through many
-Linux DEs, such as Gnome and KDE.
+open source desktop environments, such as GNOME and KDE.
 
-## Build
+## Compatibility
+
+This plugin requires mpv to be built with `--enable-cplugins` (default as of 
mpv 0.26)
+and to be built with Lua support (to enable loading scripts).
+
+## Loading
+
+mpv will automatically load the plugin from the following directories:
+
+- `/etc/mpv/scripts`: for all users
+- `~/.config/mpv/scripts`: for current user
+
+mpv can also manually load the plugin from other directories:
+
+```
+mpv --script=/path/to/mpris.so video.mp4
+```
+
+## Install
 
-If you are using 64bit Linux a pre-built version is available
-[here](https://github.com/hoyon/mpv-mpris/releases) otherwise you will have to
-manually build.
+Packages are available for many 
[distributions](https://repology.org/project/mpv-mpris/versions).
+
+For 64-bit x86 Linux a pre-built version is [available 
here](https://github.com/hoyon/mpv-mpris/releases)
+and can be copied into one of the mpv scripts directories documented above.
+
+A self-built `mpris.so` file can be installed with `make install` and will
+be installed to the appropriate mpv scripts directory for your current user
+or to the mpv system wide scripts directory for all users when you install as 
root.
+
+## Build
 
 Build requirements:
  - C99 compiler (gcc or clang)
@@ -20,27 +45,47 @@
  - glib development files
  - gio development files
 
-Building should be as simple as running `make` in the cloned directory.
+Building should be as simple as running `make` in the source code directory.
 
-## Install
-
-To install either run `make install` or copy the compiled `mpris.so` file into
-one of the following directories:
-- `/etc/mpv/scripts`
-- `~/.config/mpv/scripts`
+## Test
 
-The plugin can be used without installing by running mpv with the `--script` 
flag:
+Test requirements:
+ - mpv (for loading the mpv mpris plugin)
+ - mpv-mpris plugin (installed or self-built)
+ - playerctl (for sending MPRIS commands via D-Bus)
+ - dbus-send (from dbus, for sending MPRIS commands via D-Bus)
+ - sound-theme-freedesktop (for a file to play in mpv)
+ - bash (for running the test scripts)
+ - dbus-run-session (from dbus, for simulating a D-Bus session)
+ - xvfb and xauth (for simulating an X11 session)
+ - jq (for mpv IPC JSON generation and parsing)
+ - socat (for passing JSON to/from mpv IPC sockets)
+ - awk (for redirecting parts of mpv stderr logs)
+
+Testing should be as simple as running `make test` in the source code 
directory.
+
+The stderr of the tests will be empty unless there are mpv/etc issues.
+
+The tests accept these environment variables as parameters:
+ - `MPV_MPRIS_TEST_PLUGIN`: the mpv mpris plugin file to test, must be
+   readable and executable, defaults to the self-built one. Set it to an
+   empty string to only load and test an already installed mpv mpris plugin.
+ - `MPV_MPRIS_TEST_PLAY`: the file to play during tests, defaults to
+   `/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga`.
+   Use a file at most 10 seconds long or the tests will take a long time.
+ - `MPV_MPRIS_TEST_MPV_IPC`: dir for mpv IPC, default is test dir.
+ - `MPV_MPRIS_TEST_DBUS`: dir for D-Bus sockets, default is test dir.
+   Sets the `XDG_RUNTIME_DIR` env var so D-Bus uses the dir.
+ - `MPV_MPRIS_TEST_XAUTH`: dir for Xauthority files, default is test dir.
+ - `MPV_MPRIS_TEST_LOG`: dir for mpv/socat logs, default is test dir.
+ - `MPV_MPRIS_TEST_TMP`: dir for temp files, default is test dir.
+   Sets the `TEMPDIR`, `TMPDIR`, `TEMP` and `TMP` env vars.
+ - `MPV_MPRIS_TEST_NO_STDERR`: disable extra printing of the errors printed
+   to stderr. This is for when the test scenario already does this.
 
-```
-mpv --script=/path/to/mpris.so video.mp4
-```
-
-## Notes
-
-This plugin requires mpv to be built with `--enable-cplugins` (default as of 
mpv 0.26)
-and to be built with Lua support (to enable loading scripts).
+These parameters are useful for running the tests in alternate test scenarios.
 
-### D-Bus interfaces
+## D-Bus interfaces
 
 Implemented:
 - `org.mpris.MediaPlayer2` 
@@ -48,4 +93,4 @@
 
 Not implemented:
 - `org.mpris.MediaPlayer2.TrackList`
- - `org.mpris.MediaPlayer2.Playlists`
+- `org.mpris.MediaPlayer2.Playlists`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/mpris.c new/mpv-mpris-0.8.1/mpris.c
--- old/mpv-mpris-0.6/mpris.c   2021-10-19 22:59:59.000000000 +0200
+++ new/mpv-mpris-0.8.1/mpris.c 2022-06-18 00:35:07.000000000 +0200
@@ -360,6 +360,7 @@
     add_metadata_item_string(ud->mpv, &dict, "metadata/by-key/Album", 
"xesam:album");
     add_metadata_item_string(ud->mpv, &dict, "metadata/by-key/Genre", 
"xesam:genre");
 
+    add_metadata_item_string_list(ud->mpv, &dict, "metadata/by-key/uploader", 
"xesam:artist");
     add_metadata_item_string_list(ud->mpv, &dict, "metadata/by-key/Artist", 
"xesam:artist");
     add_metadata_item_string_list(ud->mpv, &dict, 
"metadata/by-key/Album_Artist", "xesam:albumArtist");
     add_metadata_item_string_list(ud->mpv, &dict, "metadata/by-key/Composer", 
"xesam:composer");
@@ -497,7 +498,7 @@
 
 static void method_call_player(G_GNUC_UNUSED GDBusConnection *connection,
                                G_GNUC_UNUSED const char *sender,
-                               G_GNUC_UNUSED const char *object_path,
+                               G_GNUC_UNUSED const char *_object_path,
                                G_GNUC_UNUSED const char *interface_name,
                                const char *method_name,
                                G_GNUC_UNUSED GVariant *parameters,
@@ -720,15 +721,13 @@
 {
     UserData *ud = (UserData*)data;
     GError *error = NULL;
-    GVariant *params;
-    GVariantBuilder *properties;
-    GVariantBuilder *invalidated;
     gpointer prop_name, prop_value;
     GHashTableIter iter;
 
     if (g_hash_table_size(ud->changed_properties) > 0) {
-        properties = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-        invalidated = g_variant_builder_new(G_VARIANT_TYPE("as"));
+        GVariant *params;
+        GVariantBuilder *properties = 
g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+        GVariantBuilder *invalidated = 
g_variant_builder_new(G_VARIANT_TYPE("as"));
         g_hash_table_iter_init(&iter, ud->changed_properties);
         while (g_hash_table_iter_next(&iter, &prop_name, &prop_value)) {
             if (prop_value) {
@@ -777,7 +776,20 @@
     }
 }
 
-// Register dbus object and interfaces
+static void set_stopped_status(UserData *ud)
+{
+  const char *prop_name = "PlaybackStatus";
+  GVariant *prop_value = g_variant_new_string(STATUS_STOPPED);
+
+  ud->status = STATUS_STOPPED;
+
+  g_hash_table_insert(ud->changed_properties,
+                      (gpointer)prop_name, prop_value);
+
+  emit_property_changes(ud);
+}
+
+// Register D-Bus object and interfaces
 static void on_bus_acquired(GDBusConnection *connection,
                             G_GNUC_UNUSED const char *name,
                             gpointer user_data)
@@ -806,7 +818,7 @@
 }
 
 static void on_name_lost(GDBusConnection *connection,
-                         G_GNUC_UNUSED const char *name,
+                         G_GNUC_UNUSED const char *_name,
                          gpointer user_data)
 {
     if (connection) {
@@ -838,7 +850,7 @@
 
     } else if (g_strcmp0(name, "media-title") == 0 ||
                g_strcmp0(name, "duration") == 0) {
-        // Free exising metadata object
+        // Free existing metadata object
         if (ud->metadata) {
             g_variant_unref(ud->metadata);
         }
@@ -872,6 +884,7 @@
         }
         prop_name = "LoopStatus";
         prop_value = g_variant_new_string(ud->loop_status);
+
     } else if (g_strcmp0(name, "loop-playlist") == 0) {
         char *status = *(char **)data;
         if (g_strcmp0(status, "no") != 0) {
@@ -887,6 +900,11 @@
         }
         prop_name = "LoopStatus";
         prop_value = g_variant_new_string(ud->loop_status);
+
+    } else if (g_strcmp0(name, "fullscreen") == 0) {
+        gboolean *status = data;
+        prop_name = "Fullscreen";
+        prop_value = g_variant_new_boolean(*status);
     }
 
     if (prop_name) {
@@ -901,7 +919,6 @@
 static gboolean event_handler(int fd, G_GNUC_UNUSED GIOCondition condition, 
gpointer data)
 {
     UserData *ud = data;
-    mpv_event *event;
     gboolean has_event = TRUE;
 
     // Discard data in pipe
@@ -909,16 +926,17 @@
     while (read(fd, unused, sizeof(unused)) > 0);
 
     while (has_event) {
-        event = mpv_wait_event(ud->mpv, 0);
+        mpv_event *event = mpv_wait_event(ud->mpv, 0);
         switch (event->event_id) {
         case MPV_EVENT_NONE:
             has_event = FALSE;
             break;
         case MPV_EVENT_SHUTDOWN:
+            set_stopped_status(ud);
             g_main_loop_quit(ud->loop);
             break;
         case MPV_EVENT_IDLE:
-            ud->status = STATUS_STOPPED;
+            set_stopped_status(ud);
             break;
         case MPV_EVENT_PROPERTY_CHANGE: {
             mpv_event_property *prop_event = (mpv_event_property*)event->data;
@@ -950,7 +968,7 @@
 int mpv_open_cplugin(mpv_handle *mpv)
 {
     GMainLoop *loop;
-    UserData ud = {};
+    UserData ud = {0};
     GError *error = NULL;
     GDBusNodeInfo *introspection_data = NULL;
     int pipe[2];
@@ -992,6 +1010,7 @@
     mpv_observe_property(mpv, 0, "loop-file", MPV_FORMAT_STRING);
     mpv_observe_property(mpv, 0, "loop-playlist", MPV_FORMAT_STRING);
     mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_INT64);
+    mpv_observe_property(mpv, 0, "fullscreen", MPV_FORMAT_FLAG);
 
     // Run callback whenever there are events
     g_unix_open_pipe(pipe, 0, &error);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/Makefile 
new/mpv-mpris-0.8.1/test/Makefile
--- old/mpv-mpris-0.6/test/Makefile     1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/Makefile   2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,30 @@
+MAKEFLAGS += --output-sync=target
+
+tests = \
+       metadata \
+       pause \
+       play \
+       play-pause \
+       stop \
+       quit
+
+.PHONY: \
+       test \
+       $(tests) \
+       clean
+
+test: $(tests)
+
+$(tests):
+       ./wrapper "$@"
+
+clean:
+       rm -f \
+         *.mpv.ipc* \
+         *.mpv.log \
+         *.xvfb.log \
+         *.Xauthority \
+         *.socat.log \
+         *.exit-code.log \
+         *.stderr.log
+       rm -rf dbus
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/env new/mpv-mpris-0.8.1/test/env
--- old/mpv-mpris-0.6/test/env  1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/env        2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,112 @@
+#!/bin/bash
+
+set -e
+
+
+exec {BASH_XTRACEFD}>&1
+echo "$0" "$@"
+set -x
+
+
+test="$(basename "$1")"
+
+
+if [ -z "${MPV_MPRIS_TEST_PLUGIN+set}" ] ; then
+       export MPV_MPRIS_TEST_PLUGIN=../mpris.so
+fi
+
+if [ -z "$MPV_MPRIS_TEST_PLAY" ] ; then
+       export 
MPV_MPRIS_TEST_PLAY=/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga
+fi
+
+if [ -z "$MPV_MPRIS_TEST_MPV_IPC" ] ; then
+       export MPV_MPRIS_TEST_MPV_IPC=.
+fi
+
+if [ -z "$MPV_MPRIS_TEST_LOG" ] ; then
+       export MPV_MPRIS_TEST_LOG=.
+fi
+
+if [ -z "$MPV_MPRIS_TEST_DBUS" ] ; then
+       MPV_MPRIS_TEST_DBUS=.
+fi
+
+if [ -z "$MPV_MPRIS_TEST_XAUTH" ] ; then
+       MPV_MPRIS_TEST_XAUTH=.
+fi
+
+if [ -z "$MPV_MPRIS_TEST_TMP" ] ; then
+       MPV_MPRIS_TEST_TMP=.
+fi
+
+if [ -n "$MPV_MPRIS_TEST_PLUGIN" ] ; then
+       if [ ! -f "$MPV_MPRIS_TEST_PLUGIN" ] ||
+          [ ! -r "$MPV_MPRIS_TEST_PLUGIN" ] ||
+          [ ! -x "$MPV_MPRIS_TEST_PLUGIN" ] ; then
+               echo "$MPV_MPRIS_TEST_PLUGIN not an existing file with rx 
perms" >&2
+               exit 1
+       fi
+fi
+
+if [ ! -f "$MPV_MPRIS_TEST_PLAY" ] ||
+   [ ! -r "$MPV_MPRIS_TEST_PLAY" ] ; then
+       echo "$MPV_MPRIS_TEST_PLAY not an existing readable file" >&2
+       exit 1
+fi
+
+writable_dir () {
+       if [ ! -d "$1" ] ||
+          [ ! -r "$1" ] ||
+          [ ! -w "$1" ] ||
+          [ ! -x "$1" ] ; then
+               echo "$1 not an existing writable directory" >&2
+               exit 1
+       fi
+}
+
+writable_dir "$MPV_MPRIS_TEST_MPV_IPC"
+writable_dir "$MPV_MPRIS_TEST_DBUS"
+writable_dir "$MPV_MPRIS_TEST_XAUTH"
+writable_dir "$MPV_MPRIS_TEST_LOG"
+writable_dir "$MPV_MPRIS_TEST_TMP"
+
+
+MPV_MPRIS_TEST_DBUS="$MPV_MPRIS_TEST_DBUS/dbus"
+mkdir -p -m 0700 "$MPV_MPRIS_TEST_DBUS"
+
+
+# These are not used outside this script so unexport them
+export -n \
+       MPV_MPRIS_TEST_DBUS \
+       MPV_MPRIS_TEST_XAUTH \
+       MPV_MPRIS_TEST_TMP
+
+
+# On some distros --auto-servernum doesn't work in parallel scenarios,
+# but --auto-display is offered and does work in parallel scenarios.
+# On other distros --auto-servernum *does* work in parallel scenarios,
+# but --auto-display is not offered so cannot work at all.
+# Detect which xvfb-run we have and use the right option.
+if xvfb-run --help | grep -- --auto-display ; then
+       xvfb_auto=--auto-display
+else
+       xvfb_auto=--auto-servernum
+fi
+
+
+rm -f "$MPV_MPRIS_TEST_LOG/$test.xvfb.log" 
"$MPV_MPRIS_TEST_XAUTH/$test.Xauthority"
+
+
+# xvfb-run -f is --auth-file, but that does not work on some distros:
+# https://bugs.archlinux.org/task/73865
+exec \
+env \
+MPV_MPRIS_TEST_NAME="$test" \
+XDG_RUNTIME_DIR="$MPV_MPRIS_TEST_DBUS" \
+TEMPDIR="$MPV_MPRIS_TEST_TMP" \
+TMPDIR="$MPV_MPRIS_TEST_TMP" \
+TEMP="$MPV_MPRIS_TEST_TMP" \
+TMP="$MPV_MPRIS_TEST_TMP" \
+dbus-run-session -- \
+xvfb-run "$xvfb_auto" --error-file "$MPV_MPRIS_TEST_LOG/$test.xvfb.log" -f 
"$MPV_MPRIS_TEST_XAUTH/$test.Xauthority" \
+"$@"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/metadata 
new/mpv-mpris-0.8.1/test/metadata
--- old/mpv-mpris-0.6/test/metadata     1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/metadata   2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+. ./setup
+
+test "$(playerctl metadata xesam:url)" = "file://$file"
+
+# Wait for mpv to parse the title from the file
+sleep 2
+
+test "$(playerctl metadata xesam:title)" != ""
+
+wait %1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/pause 
new/mpv-mpris-0.8.1/test/pause
--- old/mpv-mpris-0.6/test/pause        1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/pause      2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. ./setup
+
+status Playing
+check pause false
+
+playerctl pause
+sleep 1
+
+status Paused
+check pause true
+
+playerctl play
+sleep 1
+
+wait %1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/play new/mpv-mpris-0.8.1/test/play
--- old/mpv-mpris-0.6/test/play 1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/play       2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+pause=1
+
+. ./setup
+
+status Paused
+check pause true
+
+playerctl play
+sleep 1
+
+status Playing
+check pause false
+
+wait %1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/play-pause 
new/mpv-mpris-0.8.1/test/play-pause
--- old/mpv-mpris-0.6/test/play-pause   1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/play-pause 2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+pause=1
+
+. ./setup
+
+status Paused
+check pause true
+
+playerctl play-pause
+sleep 1
+
+status Playing
+check pause false
+
+playerctl play-pause
+sleep 1
+
+status Paused
+check pause true
+
+playerctl play-pause
+sleep 1
+
+status Playing
+check pause false
+
+wait %1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/quit new/mpv-mpris-0.8.1/test/quit
--- old/mpv-mpris-0.6/test/quit 1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/quit       2022-06-18 22:06:10.471654803 +0200
@@ -0,0 +1 @@
+symbolic link to stop
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/setup 
new/mpv-mpris-0.8.1/test/setup
--- old/mpv-mpris-0.6/test/setup        1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/setup      2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,122 @@
+set -e
+
+
+exec {BASH_XTRACEFD}>&1
+echo "$0" "$@"
+set -x
+
+
+test -n "$MPV_MPRIS_TEST_NAME" ||
+exec "./env" "$0" "$@"
+
+
+test="$(basename "$0")"
+
+
+if [ "$test" = setup ] ; then
+       echo "This setup script should be sourced, not executed" >&2
+       exit 1
+fi
+
+
+input_json="$MPV_MPRIS_TEST_MPV_IPC/$test.mpv.ipc.input.json"
+output_json="$MPV_MPRIS_TEST_MPV_IPC/$test.mpv.ipc.output.json"
+ipc="$MPV_MPRIS_TEST_MPV_IPC/$test.mpv.ipc"
+log_prefix="$MPV_MPRIS_TEST_LOG/$test"
+mpv_log="$log_prefix.mpv.log"
+socat_log="$log_prefix.socat.log"
+file="$MPV_MPRIS_TEST_PLAY"
+
+
+prop () {
+       jq --null-input --compact-output --arg prop "$1" '{command: 
["get_property", $prop]}'
+}
+
+val () {
+       jq --exit-status --null-input "inputs // {} | try (.data == $1 and 
.error == \"success\") catch false"
+}
+
+check () {
+       prop "$1" > "$input_json"
+       cat "$input_json"
+       rm -f "$socat_log"
+       # Pass the input JSON to socat and save the output JSON, also redirect
+       # socat errors to a file so we can check afterward if there are errors.
+       < "$input_json" socat -lf"$socat_log" - "UNIX-CONNECT:$ipc" > 
"$output_json"
+       cat "$socat_log" >&2
+       test ! -s "$socat_log"
+       cat "$output_json"
+       test -s "$output_json"
+       < "$output_json" val "$2"
+}
+
+wait_for () {
+        timeout=0
+        until "$@" ; do
+                if [ "$timeout" -eq 60 ];then
+                        printf "timed out after ${timeout}s waiting for this 
command to succeed:\n%s" "$*" >&2
+                        exit 1
+                fi
+                sleep 1
+                timeout=$((timeout+1))
+        done
+}
+
+playerctl_list_all_is_mpv () {
+       player="$(playerctl --list-all 2>&1)"
+       test "$player" = mpv
+}
+
+status () {
+       playerctl status |
+       grep "^$1$"
+}
+
+mpris_quit () {
+       # playerctl does not yet support the MPRIS Quit API
+       # https://github.com/altdesktop/playerctl/issues/171
+       dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mpv 
/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Quit
+}
+
+
+params=()
+if [ -n "$pause" ] && [ "$pause" -ne 0 ] 2> /dev/null ; then
+       params+=("--pause")
+fi
+
+if [ -n "$MPV_MPRIS_TEST_PLUGIN" ] ; then
+       params+=("--load-scripts=no" "--script=$MPV_MPRIS_TEST_PLUGIN")
+fi
+
+
+unset \
+       MPV_MPRIS_TEST_PLUGIN \
+       MPV_MPRIS_TEST_PLAY \
+       MPV_MPRIS_TEST_MPV_IPC \
+       MPV_MPRIS_TEST_LOG
+
+
+echo "DISPLAY=$DISPLAY"
+echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
+
+
+rm -f "$ipc" "$mpv_log" "$socat_log"
+
+
+mpv \
+"${params[@]}" \
+--vo=null --ao=null \
+--msg-time \
+--msg-module \
+--msg-level=cplayer=trace,mpris=trace \
+--log-file="$mpv_log" \
+--input-ipc-server="$ipc" \
+"$file" \
+2> >(awk '/statusline.*Paused/{print>"/dev/stdout";next} 1')>&2 \
+&
+
+
+# Wait for mpv to start up and load the file
+wait_for test -S "$ipc"
+wait_for playerctl_list_all_is_mpv
+sleep 2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/stop new/mpv-mpris-0.8.1/test/stop
--- old/mpv-mpris-0.6/test/stop 1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/stop       2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+pause=1
+
+. ./setup
+
+status Paused
+check pause true
+
+if [ "$test" = stop ] ; then
+       playerctl stop
+elif [ "$test" = quit ] ; then
+       mpris_quit
+fi
+sleep 2
+
+ret_ipc=0
+prop pause > "$input_json"
+cat "$input_json"
+rm -f "$socat_log"
+# Since mpv should be stopped by now and the IPC socket closed by mpv,
+# an error from socat is expected, so redirect it to a log file so that
+# it doesn't hit stderr, as some test systems check that stderr is empty.
+< "$input_json" socat -lf"$socat_log" - "UNIX-CONNECT:$ipc" > "$output_json" ||
+ret_ipc=$?
+cat "$output_json"
+test ! -s "$output_json"
+
+if [ $ret_ipc -eq 0 ] ; then
+       echo 'socat succeeded but it should have failed!' >&2
+       echo 'probably mpv did not stop when asked to!' >&2
+fi
+
+if [ ! -s "$socat_log" ] ; then
+       echo 'socat log should contain an error!' >&2
+else
+       echo 'socat log contains these *expected* errors:'
+       cat "$socat_log"
+fi
+
+playerctl status 2>&1 > /dev/null |
+grep "^No players \(were \)\?found$"
+
+if [ $ret_ipc -eq 0 ] || [ ! -s "$socat_log" ] ; then
+       exit 1
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mpv-mpris-0.6/test/wrapper 
new/mpv-mpris-0.8.1/test/wrapper
--- old/mpv-mpris-0.6/test/wrapper      1970-01-01 01:00:00.000000000 +0100
+++ new/mpv-mpris-0.8.1/test/wrapper    2022-06-18 00:35:07.000000000 +0200
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+set -e
+
+
+if [ -z "$MPV_MPRIS_TEST_LOG" ] ; then
+        MPV_MPRIS_TEST_LOG=.
+fi
+
+
+test="$1"
+exit_code="$MPV_MPRIS_TEST_LOG/$test.exit-code.log"
+stderr="$MPV_MPRIS_TEST_LOG/$test.stderr.log"
+
+
+rm -f "$exit_code" "$stderr"
+
+
+# This construct directs stderr to what it currently is
+# but also sends it to a file for checking afterwards
+# and also saves the exit code to a file for checking.
+exec 3>&1
+{
+       ret=0
+       "./$test" 2>&1 >&3 ||
+       ret=$?
+       echo "$ret" > "$exit_code"
+} |
+tee "$stderr"
+
+
+< "$exit_code" read -r ret
+
+
+if [ -s "$stderr" ] ; then
+       if [ -z "$MPV_MPRIS_TEST_NO_STDERR" ] ; then
+               echo "test $test: stderr not empty!" >&2
+               echo "test $test: start of stderr ---------------------" >&2
+               cat "$stderr" >&2
+               echo "test $test: end of stderr -----------------------" >&2
+       fi
+       echo "test $test: stderr not empty!" >&2
+fi
+
+if [ "$ret" -ne 0 ] ; then
+       echo "test $test: failed with exit code $ret" >&2
+fi
+
+
+if [ "$ret" -ne 0 ] ; then
+        exit "$ret"
+fi
+
+if [ -s "$stderr" ] ; then
+        exit 1
+fi

Reply via email to