File: smoke_test_common.py

package info (click to toggle)
gtk4-layer-shell 1.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 616 kB
  • sloc: ansic: 3,537; xml: 417; python: 333; makefile: 9
file content (25 lines) | stat: -rw-r--r-- 859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
import os
import sys
from typing import List, Dict

timeout = 3

def build_dir() -> str:
    p = os.environ.get('GTK4_LAYER_SHELL_BUILD')
    assert p, 'GTK4_LAYER_SHELL_BUILD environment variable not set'
    assert os.path.isdir(p), p + ' (from GTK4_LAYER_SHELL_BUILD) does not exist'
    return p

def expect(*args) -> None:
    print('EXPECT: ' + ' '.join(args), file=sys.stderr)

def run(cmd: List[str], env: Dict[str, str]) -> None:
    expect('zwlr_layer_shell_v1', '.get_layer_surface')
    expect('wl_surface', '.commit')
    try:
        result = subprocess.run(cmd, env={**os.environ, **env}, timeout=timeout)
        assert False, 'subprocess completed without timeout expiring, return code: ' + str(result.returncode)
    except subprocess.TimeoutExpired:
        pass
    print('CHECK EXPECTATIONS COMPLETED', file=sys.stderr)