Skip to content

Commit

Permalink
Use shell directive with trace command in wrapper script
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Sep 8, 2023
1 parent 79c677a commit 6e914aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class BashWrapperBuilder {
final traceWrapper = isTraceRequired()
if( traceWrapper ) {
// executes the stub which in turn executes the target command
launcher = "/bin/bash ${fileStr(wrapperFile)} nxf_trace"
launcher = "${shell.join(' ')} ${fileStr(wrapperFile)} nxf_trace"
}
else {
launcher = "${interpreter} ${fileStr(scriptFile)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,25 @@ class BashWrapperBuilderTest extends Specification {
when:
binding = newBashWrapperBuilder(statsEnabled: true).makeBinding()
then:
binding.launch_cmd == '/bin/bash /work/dir/.command.run nxf_trace'
binding.launch_cmd == '/bin/bash -ue /work/dir/.command.run nxf_trace'
binding.unstage_controls == null
binding.containsKey('unstage_controls')

when:
binding = newBashWrapperBuilder(statsEnabled: true, scratch: true).makeBinding()
then:
binding.launch_cmd == '/bin/bash /work/dir/.command.run nxf_trace'
binding.launch_cmd == '/bin/bash -ue /work/dir/.command.run nxf_trace'
binding.unstage_controls == '''\
cp .command.out /work/dir/.command.out || true
cp .command.err /work/dir/.command.err || true
cp .command.trace /work/dir/.command.trace || true
'''.stripIndent()

when:
binding = newBashWrapperBuilder(statsEnabled: true, shell: ['/usr/local/bin/bash', '-ue']).makeBinding()
then:
binding.launch_cmd == '/usr/local/bin/bash -ue /work/dir/.command.run nxf_trace'

}

def 'should create launcher command with input' () {
Expand Down Expand Up @@ -1041,6 +1046,7 @@ class BashWrapperBuilderTest extends Specification {
given:
def bean = Mock(TaskBean) {
inputFiles >> [:]
shell >> BashWrapperBuilder.BASH
}
def copy = Mock(ScriptFileCopyStrategy)
bean.workDir >> Paths.get('/work/dir')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ on_term() {
}

nxf_launch() {
/bin/bash {{folder}}/.command.run nxf_trace
/bin/bash -ue {{folder}}/.command.run nxf_trace
}

nxf_stage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class AwsBatchScriptLauncherTest extends Specification {
nxf_parallel "${uploads[@]}"
'''.stripIndent().leftTrim()

binding.launch_cmd == '/bin/bash .command.run nxf_trace'
binding.launch_cmd == '/bin/bash -ue .command.run nxf_trace'

binding.task_env == ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class AzFileCopyStrategyTest extends Specification {
nxf_parallel "${uploads[@]}"
'''.stripIndent().leftTrim()

binding.launch_cmd == '/bin/bash .command.run nxf_trace'
binding.launch_cmd == '/bin/bash -ue .command.run nxf_trace'

binding.task_env == '''\
export PATH="$PWD/.nextflow-bin:$AZ_BATCH_NODE_SHARED_DIR/bin/:$PATH"
Expand Down

0 comments on commit 6e914aa

Please sign in to comment.