mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00

* Make job control task queue thread-local This allows callable aliases to maintain a separate task queue from the main thread. * Make job control dictionary thread-local Use XSH.all_jobs for the main thread and a separate dictionary for other threads. This allows callable aliases to keep track of their jobs separate from the main thread. * Implement use_main_jobs() context manager This allows threaded commands like jobs, disown, and bg to handle the main thread's job control * Run commands in the same process group if in a thread * Fix tests that use jobs and tasks * Add tests for subprocess call inside alias * Add news * Remove type declarations for _jobs_thread_local Fixes the mypy error: "Type cannot be declared in assignment to non-self attribute" Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
36 lines
859 B
Python
36 lines
859 B
Python
import pytest
|
|
|
|
from xonsh import jobs
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"args, prefix, exp",
|
|
[
|
|
(
|
|
"disown",
|
|
"-",
|
|
{"-h", "--help", "-c", "--continue"},
|
|
),
|
|
(
|
|
"disown",
|
|
"",
|
|
{"1", "2"},
|
|
),
|
|
],
|
|
)
|
|
def test_disown_completion(
|
|
args, prefix, exp, xsh_with_aliases, monkeypatch, check_completer
|
|
):
|
|
job = {
|
|
"cmds": (["git-cola", "2>", "/dev/null"], "&"),
|
|
"pids": [37078],
|
|
"bg": True,
|
|
"pgrp": None,
|
|
"started": 1630158319.697764,
|
|
"status": "running",
|
|
}
|
|
all_jobs = {1: job, 2: job}
|
|
|
|
monkeypatch.setattr(jobs._jobs_thread_local, "jobs", all_jobs, raising=False)
|
|
monkeypatch.setattr(jobs._jobs_thread_local, "tasks", [2, 1], raising=False)
|
|
assert check_completer(args, prefix=prefix) == exp
|