From 8655bd8d309537ee7bb9c696c909ebffe3501483 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 18 Jun 2021 17:29:05 -0400 Subject: [PATCH] 17801: Handle glob capture of keep URI with a trailing slash Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- sdk/cwl/arvados_cwl/fsaccess.py | 2 +- sdk/cwl/tests/17801-runtime-outdir.cwl | 15 ++++++++++++ sdk/cwl/tests/arvados-tests.yml | 34 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 sdk/cwl/tests/17801-runtime-outdir.cwl diff --git a/sdk/cwl/arvados_cwl/fsaccess.py b/sdk/cwl/arvados_cwl/fsaccess.py index 1e339d5bb7..4da8f85569 100644 --- a/sdk/cwl/arvados_cwl/fsaccess.py +++ b/sdk/cwl/arvados_cwl/fsaccess.py @@ -129,7 +129,7 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess): def glob(self, pattern): collection, rest = self.get_collection(pattern) - if collection is not None and not rest: + if collection is not None and rest in (None, "", "."): return [pattern] patternsegments = rest.split("/") return sorted(self._match(collection, patternsegments, "keep:" + collection.manifest_locator())) diff --git a/sdk/cwl/tests/17801-runtime-outdir.cwl b/sdk/cwl/tests/17801-runtime-outdir.cwl new file mode 100644 index 0000000000..c01ef057d9 --- /dev/null +++ b/sdk/cwl/tests/17801-runtime-outdir.cwl @@ -0,0 +1,15 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +cwlVersion: v1.2 +class: CommandLineTool +inputs: [] +outputs: + stuff: + type: Directory + outputBinding: + glob: $(runtime.outdir) +requirements: + ShellCommandRequirement: {} +arguments: [{shellQuote: false, valueFrom: "mkdir -p foo && touch baz.txt && touch foo/bar.txt"}] diff --git a/sdk/cwl/tests/arvados-tests.yml b/sdk/cwl/tests/arvados-tests.yml index 41feb7796b..b22c9aaa27 100644 --- a/sdk/cwl/tests/arvados-tests.yml +++ b/sdk/cwl/tests/arvados-tests.yml @@ -393,3 +393,37 @@ } tool: 10380-trailing-slash-dir.cwl doc: "Test issue 10380 - bug with trailing slash when capturing an output directory" + +- job: null + output: { + "stuff": { + "basename": "78f3957c41d044352303a3fa326dff1e+102", + "class": "Directory", + "listing": [ + { + "basename": "baz.txt", + "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709", + "class": "File", + "location": "78f3957c41d044352303a3fa326dff1e+102/baz.txt", + "size": 0 + }, + { + "basename": "foo", + "class": "Directory", + "listing": [ + { + "basename": "bar.txt", + "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709", + "class": "File", + "location": "78f3957c41d044352303a3fa326dff1e+102/foo/bar.txt", + "size": 0 + } + ], + "location": "78f3957c41d044352303a3fa326dff1e+102/foo" + } + ], + "location": "78f3957c41d044352303a3fa326dff1e+102" + } + } + tool: 17801-runtime-outdir.cwl + doc: "Test issue 17801 - bug using $(runtime.outdir) to capture the output directory" -- 2.39.5