Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Oct 27, 2023
1 parent 4c4203a commit c0dd204
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/test_workarounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
import json
import signal
import sys
from subprocess import PIPE, check_call, run
import time
from subprocess import PIPE, check_call, run, Popen

import pytest


def test_matchspec_star_version():
Expand Down Expand Up @@ -56,3 +60,35 @@ def test_build_string_filters():
assert pkg["version"].startswith("3.8")
if pkg["name"] == "numpy":
assert "py38" in pkg["build_string"]


@pytest.mark.parametrize("stage", ["Collecting package metadata", "Solving environment"])
def test_ctrl_c(stage):
p = Popen(
[
sys.executable,
"-m",
"conda",
"create",
"-p",
"UNUSED",
"--dry-run",
"--solver=libmamba",
"--override-channels",
"--channel=conda-forge",
"vaex",
],
text=True,
stdout=PIPE,
stderr=PIPE,
)
t0 = time.time()
while stage not in p.stdout.readline():
time.sleep(0.1)
if time.time() - t0 > 30:
raise RuntimeError("Timeout")

p.send_signal(signal.SIGINT if sys.platform != "win32" else signal.CTRL_C_EVENT)
p.wait()
assert p.returncode != 0
assert "KeyboardInterrupt" in p.stdout.read() + p.stderr.read()

0 comments on commit c0dd204

Please sign in to comment.