Skip to content

Commit a40aace

Browse files
committed
Committing version 0.3.4 fixing a couple of bugs
1 parent 10ceb1a commit a40aace

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
apply plugin: 'groovy'
2121
apply plugin: 'codenarc'
22-
version = '0.3.3'
22+
version = '0.3.4'
2323

2424
repositories {
2525
flatDir(dirs: file('lib'))

changelog.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ NEXTFLOW CHANGE-LOG
22
===================
33

44
0.3.4
5-
- Extending semnatics for method File.copyTo(source,target) so that when 'target' argument
5+
- Extending semantic for method File.copyTo(source,target) so that when 'target' argument
66
is a directory, it copy the 'source' file to that folder, with the same name of the original file.
7+
- Bug: Fixed a ClassCastEx exception when the 'bin' folder is added to the PATH
8+
- Bug: Fixed an issue that raised an error "error=26 Text file busy" on some platforms (CentOS)
79

810
0.3.3 - 8 Aug 2013
911
- Added optional parameters to 'chunkLines' and 'chunkFasta' methods

src/main/groovy/nextflow/Const.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ class Const {
5757
/**
5858
* The application version
5959
*/
60-
static final String APP_VER = "0.3.3"
60+
static final String APP_VER = "0.3.4"
6161

6262
/**
6363
* The app build time as linux/unix timestamp
6464
*/
65-
static final long APP_TIMESTAMP = 1376051851359
65+
static final long APP_TIMESTAMP = 1377297870371
6666

6767
/**
6868
* The app build number
6969
*/
70-
static final int APP_BUILDNUM = 752
70+
static final int APP_BUILDNUM = 763
7171

7272
/**
7373
* The date time formatter string

src/main/groovy/nextflow/executor/LocalExecutor.groovy

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class LocalExecutor extends AbstractExecutor {
3434

3535
private static final COMMAND_OUT_FILENAME = '.command.out'
3636

37-
private static final COMMAND_RUNNER_FILENAME = '.command.run'
37+
private static final COMMAND_BASH_FILENAME = '.command.sh'
3838

3939
private static final COMMAND_ENV_FILENAME = '.command.env'
4040

41-
private static final COMMAND_SCRIPT_FILENAME = '.command.sh'
41+
private static final COMMAND_SCRIPT_FILENAME = '.command.run'
4242

4343

4444
/**
@@ -64,22 +64,23 @@ class LocalExecutor extends AbstractExecutor {
6464
/*
6565
* save the main script file
6666
*/
67+
def scriptStr = task.processor.normalizeScript(task.script.toString())
6768
def scriptFile = new File(scratch, COMMAND_SCRIPT_FILENAME)
68-
scriptFile.text = task.processor.normalizeScript(task.script.toString())
69+
scriptFile.text = scriptStr
70+
def interpreter = task.processor.fetchInterpreter(scriptStr)
6971

7072
/*
7173
* create the runner script which will launch the script
7274
*/
7375
def runnerText = """
74-
source ${COMMAND_ENV_FILENAME}
75-
chmod +x ${COMMAND_SCRIPT_FILENAME}
76-
./${COMMAND_SCRIPT_FILENAME}
76+
source $COMMAND_ENV_FILENAME
77+
$interpreter $COMMAND_SCRIPT_FILENAME
7778
"""
78-
def runnerFile = new File(scratch, COMMAND_RUNNER_FILENAME)
79+
def runnerFile = new File(scratch, COMMAND_BASH_FILENAME)
7980
runnerFile.text = task.processor.normalizeScript(runnerText)
8081

8182
// the cmd list to launch it
82-
List cmd = new ArrayList(taskConfig.shell ?: 'bash' as List ) << COMMAND_RUNNER_FILENAME
83+
List cmd = new ArrayList(taskConfig.shell ?: 'bash' as List ) << COMMAND_BASH_FILENAME
8384
log.trace "Launch cmd line: ${cmd.join(' ')}"
8485

8586
/*

src/main/groovy/nextflow/processor/MergeTaskProcessor.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class MergeTaskProcessor extends TaskProcessor {
118118
scriptClosure.setResolveStrategy(Closure.DELEGATE_FIRST)
119119

120120
def commandToRun = normalizeScript(scriptClosure.call()?.toString())
121+
def interpreter = fetchInterpreter(commandToRun)
121122

122123
/*
123124
* create a unique hash-code for this task run and save it into a list
@@ -137,7 +138,6 @@ class MergeTaskProcessor extends TaskProcessor {
137138
def scriptName = ".merge_command.sh.${index.toString().padLeft(4,'0')}"
138139
def scriptFile = new File(mergeTempFolder, scriptName)
139140
scriptFile.text = commandToRun
140-
scriptFile.setExecutable(true)
141141

142142
// the command to launch this command
143143
def scriptCommand = scriptFile.absolutePath
@@ -153,7 +153,7 @@ class MergeTaskProcessor extends TaskProcessor {
153153
}
154154

155155
// create a unique script collecting all the commands
156-
mergeScript << scriptCommand << '\n'
156+
mergeScript << interpreter << ' ' << scriptCommand << '\n'
157157

158158
}
159159

src/main/groovy/nextflow/processor/TaskProcessor.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ abstract class TaskProcessor {
224224
return result.toString()
225225
}
226226

227+
def String fetchInterpreter( String script ) {
228+
assert script != null
229+
230+
if( script[0] == '#' && script[1] == '!') {
231+
return script.readLines()[0].substring(2)
232+
}
233+
234+
return null
235+
}
236+
227237
/**
228238
* Wraps the target method by a closure declaring as many arguments as many are the user declared inputs
229239
* object.

src/test/groovy/nextflow/processor/TaskProcessorTest.groovy

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TaskProcessorTest extends Specification {
4040
when:
4141
def session = new Session([env: [X:"1", Y:"2"]])
4242
session.setBaseDir(home)
43-
def processor = new DummyProcessor(new NopeExecutor(), session, new DummyScript(), new TaskConfig(), {})
43+
def processor = new DummyProcessor(new NopeExecutor(), session, new TaskConfig())
4444
def builder = new ProcessBuilder()
4545
builder.environment().putAll( processor.getProcessEnvironment() )
4646

@@ -53,7 +53,7 @@ class TaskProcessorTest extends Specification {
5353
when:
5454
session = new Session([env: [X:"1", Y:"2", PATH:'/some']])
5555
session.setBaseDir(home)
56-
processor = new DummyProcessor(new NopeExecutor(), session, new DummyScript(), new TaskConfig(), {})
56+
processor = new DummyProcessor(new NopeExecutor(), session, new TaskConfig())
5757
builder = new ProcessBuilder()
5858
builder.environment().putAll( processor.getProcessEnvironment() )
5959

@@ -69,11 +69,32 @@ class TaskProcessorTest extends Specification {
6969

7070
}
7171

72+
def testFetchInterpreter() {
73+
74+
when:
75+
def processor = new DummyProcessor(new NopeExecutor(), new Session(), new TaskConfig())
76+
def script =
77+
'''
78+
#!/bin/perl
79+
do this
80+
do that
81+
'''
82+
def i = processor.fetchInterpreter(script.stripIndent().trim())
83+
then:
84+
i == '/bin/perl'
85+
86+
when:
87+
processor = new DummyProcessor(new NopeExecutor(), new Session(), new TaskConfig())
88+
i = processor.fetchInterpreter('do this')
89+
then:
90+
i == null
91+
}
92+
7293

7394
static class DummyProcessor extends TaskProcessor {
7495

75-
DummyProcessor(AbstractExecutor executor, Session session, BaseScript script, TaskConfig taskConfig, Closure taskBlock) {
76-
super(executor, session, script, taskConfig, taskBlock)
96+
DummyProcessor(AbstractExecutor executor, Session session, TaskConfig taskConfig) {
97+
super(executor, session, new DummyScript(), taskConfig, {})
7798
}
7899

79100
@Override

0 commit comments

Comments
 (0)