Skip to content

Commit

Permalink
Merge pull request #65 from common-workflow-language/terminate-proces…
Browse files Browse the repository at this point in the history
…s-cleanup

If a test process didn't end on its own, terminate it.
  • Loading branch information
mr-c authored Apr 13, 2018
2 parents 65ec76c + 9b7fa7a commit aec2384
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MODULE=cwltest
PYSOURCES=$(wildcard ${MODULE}/**.py tests/*.py) setup.py
DEVPKGS=pep8 diff_cover autopep8 pylint coverage pep257 flake8 pytest
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pep257 sloccount python-flake8
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --date=`git log --first-parent \
VERSION=1.0.$(shell date +%Y%m%d%H%M%S --utc --date=`git log --first-parent \
--max-count=1 --format=format:%cI`)
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

Expand Down
24 changes: 22 additions & 2 deletions cwltest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from six.moves import range
from six.moves import zip
from typing import Any, Dict, List
import pkg_resources # part of setuptools

import junit_xml
from cwltest.utils import compare, CompareFail, TestResult, REQUIRED, get_test_number_by_key
Expand Down Expand Up @@ -84,6 +85,7 @@ def run_test(args, i, tests, timeout):
else:
suffix = "\n"
try:
process = None # type: subprocess.Popen
test_command = prepare_test_command(args, i, tests)

if t.get("short_name"):
Expand Down Expand Up @@ -129,6 +131,16 @@ def run_test(args, i, tests, timeout):
_logger.error(u"""Test timed out: %s""", " ".join([pipes.quote(tc) for tc in test_command]))
_logger.error(t.get("doc"))
return TestResult(2, outstr, outerr, timeout, args.classname, "Test timed out")
finally:
if process is not None and process.returncode is None:
_logger.error(u"""Terminating lingering process""")
process.terminate()
for a in range(0, 3):
time.sleep(1)
if process.poll() is not None:
break
if process.returncode is None:
process.kill()

fail_message = ''

Expand All @@ -153,7 +165,7 @@ def run_test(args, i, tests, timeout):


def arg_parser(): # type: () -> argparse.ArgumentParser
parser = argparse.ArgumentParser(description='Compliance tests for cwltool')
parser = argparse.ArgumentParser(description='Common Workflow Language testing framework')
parser.add_argument("--test", type=str, help="YAML file describing test cases", required=True)
parser.add_argument("--basedir", type=str, help="Basedir to use for tests", default=".")
parser.add_argument("-l", action="store_true", help="List tests then exit")
Expand All @@ -172,8 +184,16 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
parser.add_argument("--verbose", action="store_true", help="More verbose output during test run.")
parser.add_argument("--classname", type=str, default="", help="Specify classname for the Test Suite.")
parser.add_argument("--timeout", type=int, default=DEFAULT_TIMEOUT, help="Time of execution in seconds after "
"which the test will be skipped."
"which the test will be skipped. "
"Defaults to 900 sec (15 minutes)")

pkg = pkg_resources.require("cwltest")
if pkg:
ver = u"%s %s" % (sys.argv[0], pkg[0].version)
else:
ver = u"%s %s" % (sys.argv[0], "unknown version")
parser.add_argument('--version', action='version', version=ver)

return parser


Expand Down
308 changes: 308 additions & 0 deletions typeshed/2.7/pkg_resources/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
# Stubs for pkg_resources (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, Text
from os import open as os_open
from collections import namedtuple

require = ... # type: Any
working_set = ... # type: Any

class PEP440Warning(RuntimeWarning): ...

class _SetuptoolsVersionMixin:
def __hash__(self): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __eq__(self, other): ...
def __ge__(self, other): ...
def __gt__(self, other): ...
def __ne__(self, other): ...
def __getitem__(self, key): ...
def __iter__(self): ...

def parse_version(v): ...

class ResolutionError(Exception): ...

class VersionConflict(ResolutionError):
@property
def dist(self): ...
@property
def req(self): ...
def report(self): ...
def with_context(self, required_by): ...

class ContextualVersionConflict(VersionConflict):
@property
def required_by(self): ...

class DistributionNotFound(ResolutionError):
@property
def req(self): ...
@property
def requirers(self): ...
@property
def requirers_str(self): ...
def report(self): ...

class UnknownExtra(ResolutionError): ...

EGG_DIST = ... # type: Any
BINARY_DIST = ... # type: Any
SOURCE_DIST = ... # type: Any
CHECKOUT_DIST = ... # type: Any
DEVELOP_DIST = ... # type: Any

def register_loader_type(loader_type, provider_factory): ...
def get_provider(moduleOrReq): ...

get_platform = ... # type: Any

def compatible_platforms(provided, required): ...
def run_script(dist_spec, script_name): ...

run_main = ... # type: Any

def get_distribution(dist): ...
def load_entry_point(dist, group, name): ...
def get_entry_map(dist, group=None): ...
def get_entry_info(dist, group, name): ...

class IMetadataProvider:
def has_metadata(name): ...
def get_metadata(name): ...
def get_metadata_lines(name): ...
def metadata_isdir(name): ...
def metadata_listdir(name): ...
def run_script(script_name, namespace): ...

class IResourceProvider(IMetadataProvider):
def get_resource_filename(manager, resource_name): ...
def get_resource_stream(manager, resource_name): ...
def get_resource_string(manager, resource_name): ...
def has_resource(resource_name): ...
def resource_isdir(resource_name): ...
def resource_listdir(resource_name): ...

class WorkingSet:
entries = ... # type: Any
entry_keys = ... # type: Any
by_key = ... # type: Any
callbacks = ... # type: Any
def __init__(self, entries=None): ...
def add_entry(self, entry): ...
def __contains__(self, dist): ...
def find(self, req): ...
def iter_entry_points(self, group, name=None): ...
def run_script(self, requires, script_name): ...
def __iter__(self): ...
def add(self, dist, entry=None, insert=True, replace=False): ...
def resolve(self, requirements, env=None, installer=None, replace_conflicting=False): ...
def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True): ...
def require(self, *requirements): ...
def subscribe(self, callback): ...

class _ReqExtras(dict):
def markers_pass(self, req): ...

class Environment:
platform = ... # type: Any
python = ... # type: Any
def __init__(self, search_path=None, platform=..., python=...): ...
def can_add(self, dist): ...
def remove(self, dist): ...
def scan(self, search_path=None): ...
def __getitem__(self, project_name): ...
def add(self, dist): ...
def best_match(self, req, working_set, installer=None): ...
def obtain(self, requirement, installer=None): ...
def __iter__(self): ...
def __iadd__(self, other): ...
def __add__(self, other): ...

AvailableDistributions = ... # type: Any

class ExtractionError(RuntimeError): ...

class ResourceManager:
extraction_path = ... # type: Any
cached_files = ... # type: Any
def __init__(self): ...
def resource_exists(self, package_or_requirement, resource_name): ...
def resource_isdir(self, package_or_requirement, resource_name): ...
def resource_filename(self, package_or_requirement, resource_name): ...
def resource_stream(self, package_or_requirement, resource_name): ...
def resource_string(self, package_or_requirement, resource_name): ...
def resource_listdir(self, package_or_requirement, resource_name): ...
def extraction_error(self): ...
def get_cache_path(self, archive_name, names=...): ...
def postprocess(self, tempname, filename): ...
def set_extraction_path(self, path): ...
def cleanup_resources(self, force=False): ...

def get_default_cache(): ...
def safe_name(name): ...
def safe_version(version): ...
def safe_extra(extra): ...
def to_filename(name): ...
def invalid_marker(text): ...
def evaluate_marker(text, extra=None): ...

class NullProvider:
egg_name = ... # type: Any
egg_info = ... # type: Any
loader = ... # type: Any
module_path = ... # type: Any
def __init__(self, module): ...
def get_resource_filename(self, manager, resource_name): ...
def get_resource_stream(self, manager, resource_name): ...
def get_resource_string(self, manager, resource_name): ...
def has_resource(self, resource_name): ...
def has_metadata(self, name): ...
def get_metadata(self, name): ...
def get_metadata_lines(self, name): ...
def resource_isdir(self, resource_name): ...
def metadata_isdir(self, name): ...
def resource_listdir(self, resource_name): ...
def metadata_listdir(self, name): ...
def run_script(self, script_name, namespace): ...

class EggProvider(NullProvider):
def __init__(self, module): ...

class DefaultProvider(EggProvider):
def get_resource_stream(self, manager, resource_name): ...

class EmptyProvider(NullProvider):
module_path = ... # type: Any
def __init__(self): ...

empty_provider = ... # type: Any

class ZipManifests(dict):
@classmethod
def build(cls, path): ...
load = ... # type: Any

class ZipProvider(EggProvider):
eagers = ... # type: Any
zip_pre = ... # type: Any
def __init__(self, module): ...
@property
def zipinfo(self): ...
def get_resource_filename(self, manager, resource_name): ...

class FileMetadata(EmptyProvider):
path = ... # type: Any
def __init__(self, path): ...
def has_metadata(self, name): ...
def get_metadata(self, name): ...
def get_metadata_lines(self, name): ...

class PathMetadata(DefaultProvider):
module_path = ... # type: Any
egg_info = ... # type: Any
def __init__(self, path, egg_info): ...

class EggMetadata(ZipProvider):
zip_pre = ... # type: Any
loader = ... # type: Any
module_path = ... # type: Any
def __init__(self, importer): ...

def register_finder(importer_type, distribution_finder): ...
def find_distributions(path_item, only=False): ...
def register_namespace_handler(importer_type, namespace_handler): ...
def declare_namespace(packageName): ...
def fixup_namespace_packages(path_item, parent=None): ...
def normalize_path(filename): ...
def yield_lines(strs): ...

class EntryPoint:
name = ... # type: Any
module_name = ... # type: Any
attrs = ... # type: Any
extras = ... # type: Any
dist = ... # type: Any
def __init__(self, name, module_name, attrs=..., extras=..., dist=None): ...
def load(self, require=True, *args, **kwargs): ...
def resolve(self): ...
def require(self, env=None, installer=None): ...
pattern = ... # type: Any
@classmethod
def parse(cls, src, dist=None): ...
@classmethod
def parse_group(cls, group, lines, dist=None): ...
@classmethod
def parse_map(cls, data, dist=None): ...

class Distribution:
PKG_INFO = ... # type: Any
project_name = ... # type: Any
py_version = ... # type: Any
platform = ... # type: Any
location = ... # type: Any
precedence = ... # type: Any
def __init__(self, location=None, metadata=None, project_name=None, version=None, py_version=..., platform=None, precedence=...): ...
@classmethod
def from_location(cls, location, basename, metadata=None, **kw): ...
@property
def hashcmp(self): ...
def __hash__(self): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __eq__(self, other): ...
def __ne__(self, other): ...
@property
def key(self): ...
@property
def parsed_version(self): ...
@property
def version(self): ...
def requires(self, extras=...): ...
def activate(self, path=None): ...
def egg_name(self): ...
def __getattr__(self, attr): ...
@classmethod
def from_filename(cls, filename, metadata=None, **kw): ...
def as_requirement(self): ...
def load_entry_point(self, group, name): ...
def get_entry_map(self, group=None): ...
def get_entry_info(self, group, name): ...
def insert_on(self, path, loc=None, replace=False): ...
def check_version_conflict(self): ...
def has_version(self): ...
def clone(self, **kw): ...
@property
def extras(self): ...

class EggInfoDistribution(Distribution): ...

class DistInfoDistribution(Distribution):
PKG_INFO = ... # type: Any
EQEQ = ... # type: Any

class RequirementParseError(ValueError): ...

def parse_requirements(strs): ...

def ensure_directory(path): ...
def split_sections(s): ...

def resource_stream(package_or_requirement: Text, resource_name: Text): ...

# Names in __all__ with no definition:
# add_activation_listener
# cleanup_resources
# iter_entry_points
# resource_exists
# resource_filename
# resource_isdir
# resource_listdir
# resource_stream
# resource_string
# set_extraction_path
4 changes: 2 additions & 2 deletions typeshed/2.7/subprocess32.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ class Popen:
def poll(self) -> int: ...
def wait(self, timeout: Optional[Any] = ..., endtime: Optional[Any] = ...): ...
def send_signal(self, sig): ...
def terminate(self): ...
def kill(self): ...
def terminate(self) -> None: ...
def kill(self) -> None: ...

0 comments on commit aec2384

Please sign in to comment.