fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Noah Hellmantests: use command instead of absolute pathsa0d8d27f4

master
1.0 KiB32 linesraw
1#!/usr/bin/env python3
2from pexpect_helper import SpawnedProc
3import os
4import signal
5import tempfile
6
7# Ensure that on-exit handlers run even if we get SIGHUP.
8with tempfile.NamedTemporaryFile(mode="r", encoding="utf8") as tf:
9    sp = SpawnedProc()
10    fish_pid = sp.spawn.pid
11    sp.expect_prompt()
12    sp.sendline(
13        "function myexit --on-event fish_exit; command echo $fish_pid > {filename}; end".format(
14            filename=tf.name
15        )
16    )
17    sp.expect_prompt()
18    os.kill(fish_pid, signal.SIGHUP)
19    # Note that fish's SIGHUP handling in interactive mode races with the call to select.
20    # So actually close its stdin, like a terminal emulator would do.
21    sp.spawn.close(force=False)
22    sp.spawn.wait()
23    tf.seek(0)
24    line = tf.readline().strip()
25    if line != str(fish_pid):
26        colors = sp.colors()
27        print(
28            """{RED}Failed to find pid written by exit handler{RESET}""".format(
29                **colors
30            )
31        )
32        print("""Expected '{}', found '{}'""".format(fish_pid, line))