test: attempt flake fix

This commit is contained in:
Tony Crisci
2020-11-30 13:10:56 -05:00
parent d8c02860f1
commit 8b6574bf81
3 changed files with 19 additions and 13 deletions

View File

@@ -351,7 +351,7 @@ static void context_remove_player(struct PlayerctldContext *ctx, struct Player *
static void context_rotate_queue(struct PlayerctldContext *ctx) {
struct Player *player;
if ((player = g_queue_peek_head(ctx->players))) {
if ((player = g_queue_peek_head(ctx->players))) {
context_remove_player(ctx, player);
g_queue_push_tail(ctx->players, player);
}
@@ -359,13 +359,12 @@ static void context_rotate_queue(struct PlayerctldContext *ctx) {
static void context_unrotate_queue(struct PlayerctldContext *ctx) {
struct Player *player;
if ((player = g_queue_peek_tail(ctx->players))) {
if ((player = g_queue_peek_tail(ctx->players))) {
context_remove_player(ctx, player);
g_queue_push_head(ctx->players, player);
}
}
/**
* Returns the newly activated player
*/
@@ -599,7 +598,7 @@ static void playerctld_method_call_func(GDBusConnection *connection, const char
} else if (strcmp(method_name, "Unshift") == 0) {
if ((active_player = context_unshift_active_player(ctx))) {
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(s)", active_player->well_known));
g_variant_new("(s)", active_player->well_known));
} else {
g_debug("no active player, returning error");
g_dbus_method_invocation_return_dbus_error(
@@ -916,8 +915,8 @@ static gboolean parse_setup_options(int argc, char **argv, GError **error) {
success = g_option_context_parse(context, &argc, &argv, error);
if (success && command_arg &&
(g_strcmp0(command_arg[0], "shift") != 0 && g_strcmp0(command_arg[0], "unshift") != 0 &&
g_strcmp0(command_arg[0], "daemon") != 0)) {
(g_strcmp0(command_arg[0], "shift") != 0 && g_strcmp0(command_arg[0], "unshift") != 0 &&
g_strcmp0(command_arg[0], "daemon") != 0)) {
gchar *help = g_option_context_get_help(context, TRUE, NULL);
printf("%s\n", help);
g_option_context_free(context);

View File

@@ -21,7 +21,9 @@ async def setup_mpris(*names, bus_address=None, system=False):
assert reply == RequestNameReply.PRIMARY_OWNER
return player
return await asyncio.gather(*(setup(name) for name in names))
players = await asyncio.gather(*(setup(name) for name in names))
await asyncio.gather(*(p.ping() for p in players))
return players
async def setup_playerctld(bus_address=None):
@@ -111,9 +113,9 @@ class MprisPlayer(ServiceInterface):
async def set_artist_title(self, artist, title, track_id=None):
if track_id is None:
self.counter += 1
track_id = '/' + str(self.counter)
self.counter += 1
self.metadata = {
'xesam:title': Variant('s', title),
'xesam:artist': Variant('as', [artist]),

View File

@@ -125,9 +125,11 @@ async def test_daemon_follow(bus_address):
[mpris3] = await setup_mpris('player3', bus_address=bus_address)
await mpris3.set_artist_title('artist3', 'title3')
line = await proc.queue.get()
# I don't really care if this is blank, but happens by test setup
assert line == ''
line = await proc.queue.get()
if line == '':
# the line might be blank here because of the test setup
line = await proc.queue.get()
assert line == 'playerctld: artist3 - title3', proc.queue
await mpris1.set_artist_title('artist4', 'title4')
@@ -150,7 +152,7 @@ async def test_daemon_follow(bus_address):
await playerctld_proc.wait()
async def playerctld_shift(bus_address, reverse = False):
async def playerctld_shift(bus_address, reverse=False):
env = os.environ.copy()
env['DBUS_SESSION_BUS_ADDRESS'] = bus_address
env['G_MESSAGES_DEBUG'] = 'playerctl'
@@ -167,7 +169,10 @@ async def playerctld_shift(bus_address, reverse = False):
async def test_daemon_shift_simple(bus_address):
playerctld_proc = await start_playerctld(bus_address)
mprises = await setup_mpris('player1', 'player2', 'player3', bus_address=bus_address)
mprises = await setup_mpris('player1',
'player2',
'player3',
bus_address=bus_address)
[mpris1, mpris2, mpris3] = mprises
playerctl = PlayerctlCli(bus_address)