Skip to content

Commit d4fadd4

Browse files
Remove test constructors or mark as TestOnly (#5216)
--------- Signed-off-by: Ben Sherman <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
1 parent 9280b59 commit d4fadd4

File tree

54 files changed

+156
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+156
-186
lines changed

modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import groovy.util.logging.Slf4j
2222
import nextflow.exception.AbortOperationException
2323
import nextflow.plugin.Plugins
2424
import nextflow.scm.AssetManager
25+
import nextflow.util.TestOnly
2526
/**
2627
* CLI sub-command PULL
2728
*
@@ -49,7 +50,7 @@ class CmdPull extends CmdBase implements HubOptions {
4950
@Override
5051
final String getName() { NAME }
5152

52-
/* only for testing purpose */
53+
@TestOnly
5354
protected File root
5455

5556
@Override
@@ -64,7 +65,6 @@ class CmdPull extends CmdBase implements HubOptions {
6465
return
6566
}
6667

67-
/* only for testing purpose */
6868
if( root ) {
6969
AssetManager.root = root
7070
}

modules/nextflow/src/main/groovy/nextflow/conda/CondaCache.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import nextflow.file.FileMutex
3333
import nextflow.util.CacheHelper
3434
import nextflow.util.Duration
3535
import nextflow.util.Escape
36+
import nextflow.util.TestOnly
3637
/**
3738
* Handle Conda environment creation and caching
3839
*
@@ -86,9 +87,8 @@ class CondaCache {
8687
return "conda"
8788
}
8889

89-
/** Only for testing purpose - do not use */
90-
@PackageScope
91-
CondaCache() {}
90+
@TestOnly
91+
protected CondaCache() {}
9292

9393
/**
9494
* Create a Conda env cache object

modules/nextflow/src/main/groovy/nextflow/container/ApptainerCache.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ import groovy.transform.CompileStatic
2727
@CompileStatic
2828
class ApptainerCache extends SingularityCache {
2929

30-
/** only for testing */
31-
protected ApptainerCache() {}
32-
3330
ApptainerCache(ContainerConfig config, Map<String,String> env=null) {
3431
super(config, env)
3532
}

modules/nextflow/src/main/groovy/nextflow/container/CharliecloudCache.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import groovyx.gpars.dataflow.LazyDataflowVariable
2929
import nextflow.Global
3030
import nextflow.file.FileMutex
3131
import nextflow.util.Duration
32+
import nextflow.util.TestOnly
3233
/**
3334
* Handle caching of remote Charliecloud images
3435
*
@@ -52,7 +53,7 @@ class CharliecloudCache {
5253

5354
private String registry
5455

55-
/** Only for debugging purpose - do not use */
56+
@TestOnly
5657
@PackageScope
5758
CharliecloudCache() {}
5859

modules/nextflow/src/main/groovy/nextflow/container/SingularityCache.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ class SingularityCache {
5252

5353
private Duration pullTimeout = Duration.of('20min')
5454

55-
/** Only for debugging purpose - do not use */
56-
@PackageScope
57-
SingularityCache() {}
58-
5955
protected String getBinaryName() { return 'singularity' }
6056

6157
protected String getAppName() { getBinaryName().capitalize() }

modules/nextflow/src/main/groovy/nextflow/executor/BashWrapperBuilder.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import nextflow.processor.TaskRun
3939
import nextflow.secret.SecretsLoader
4040
import nextflow.util.Escape
4141
import nextflow.util.MemoryUnit
42+
import nextflow.util.TestOnly
4243
/**
4344
* Builder to create the Bash script which is used to
4445
* wrap and launch the user task
@@ -124,8 +125,8 @@ class BashWrapperBuilder {
124125
this.copyStrategy = strategy ?: new SimpleFileCopyStrategy(bean)
125126
}
126127

127-
/** only for testing -- do not use */
128-
protected BashWrapperBuilder() { }
128+
@TestOnly
129+
protected BashWrapperBuilder() {}
129130

130131
/**
131132
* @return The bash script fragment to change to the 'scratch' directory if it has been specified in the task configuration

modules/nextflow/src/main/groovy/nextflow/executor/GridTaskHandler.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import nextflow.processor.TaskRun
4444
import nextflow.trace.TraceRecord
4545
import nextflow.util.CmdLineHelper
4646
import nextflow.util.Duration
47+
import nextflow.util.TestOnly
4748
import nextflow.util.Throttle
4849
/**
4950
* Handles a job execution in the underlying grid platform
@@ -83,7 +84,7 @@ class GridTaskHandler extends TaskHandler implements FusionAwareTask {
8384

8485
BatchCleanup batch
8586

86-
/** only for testing purpose */
87+
@TestOnly
8788
protected GridTaskHandler() {}
8889

8990
GridTaskHandler( TaskRun task, AbstractGridExecutor executor ) {

modules/nextflow/src/main/groovy/nextflow/extension/DumpOp.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ class DumpOp {
6363
return this
6464
}
6565

66-
/** Only for testing -- do not use */
67-
protected DumpOp() {}
68-
69-
7066
boolean isEnabled() {
7167
if( !dumpNames )
7268
return false

modules/nextflow/src/main/groovy/nextflow/extension/TransposeOp.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import groovyx.gpars.dataflow.DataflowReadChannel
2222
import groovyx.gpars.dataflow.DataflowWriteChannel
2323
import nextflow.Channel
2424
import nextflow.util.CheckHelper
25+
import nextflow.util.TestOnly
2526
/**
2627
* Implements channel transpose operator
2728
*
@@ -48,9 +49,7 @@ class TransposeOp {
4849
this.remainder = params?.remainder as Boolean
4950
}
5051

51-
/**
52-
* Only for test -- do not use
53-
*/
52+
@TestOnly
5453
@PackageScope
5554
TransposeOp() {}
5655

modules/nextflow/src/main/groovy/nextflow/file/DirWatcher.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import java.nio.file.attribute.BasicFileAttributes
3333

3434
import groovy.transform.CompileStatic
3535
import groovy.util.logging.Slf4j
36+
import nextflow.util.TestOnly
3637
import nextflow.util.Threads
3738

3839
/**
@@ -79,7 +80,7 @@ class DirWatcher implements DirListener {
7980

8081
private volatile boolean terminated
8182

82-
/* only for testing */
83+
@TestOnly
8384
protected DirWatcher() {}
8485

8586
DirWatcher(String syntax, String folder, String pattern, boolean skipHidden, String events, FileSystem fs) {

modules/nextflow/src/main/groovy/nextflow/file/DirWatcherV2.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import java.nio.file.WatchEvent
2727
import groovy.transform.CompileStatic
2828
import groovy.util.logging.Slf4j
2929
import nextflow.util.Duration
30+
import nextflow.util.TestOnly
3031
import org.apache.commons.io.monitor.FileAlterationListener
3132
import org.apache.commons.io.monitor.FileAlterationMonitor
3233
import org.apache.commons.io.monitor.FileAlterationObserver
@@ -73,7 +74,8 @@ class DirWatcherV2 implements DirListener, FileAlterationListener {
7374

7475
private FileAlterationMonitor monitor
7576

76-
protected DirWatcherV2() { }
77+
@TestOnly
78+
protected DirWatcherV2() {}
7779

7880
DirWatcherV2(String syntax, String folder, String pattern, boolean skipHidden, String events, FileSystem fs) {
7981
assert syntax in ['regex','glob']

modules/nextflow/src/main/groovy/nextflow/fusion/FusionScriptLauncher.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ class FusionScriptLauncher extends BashWrapperBuilder {
4141
private Path remoteWorkDir
4242
private Map<String,String> env
4343

44-
/* ONLY FOR TESTING - DO NOT USE */
45-
protected FusionScriptLauncher() { }
46-
4744
static FusionScriptLauncher create(TaskBean bean, String scheme) {
4845

4946
final remoteWorkDir = bean.workDir

modules/nextflow/src/main/groovy/nextflow/processor/TaskContext.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import nextflow.Global
3434
import nextflow.exception.ProcessException
3535
import nextflow.script.ScriptBinding
3636
import nextflow.util.KryoHelper
37+
import nextflow.util.TestOnly
3738
/**
3839
* Map used to delegate variable resolution to script scope
3940
*
@@ -91,7 +92,7 @@ class TaskContext implements Map<String,Object>, Cloneable {
9192
log.trace "Binding names for '$name' > $variableNames"
9293
}
9394

94-
/** ONLY FOR TEST PURPOSE -- do not use */
95+
@TestOnly
9596
protected TaskContext() { }
9697

9798
TaskContext clone() {

modules/nextflow/src/main/groovy/nextflow/processor/TaskHandler.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import groovy.transform.CompileDynamic
2525
import groovy.transform.CompileStatic
2626
import groovy.util.logging.Slf4j
2727
import nextflow.trace.TraceRecord
28+
import nextflow.util.TestOnly
2829
/**
2930
* Actions to handle the underlying job running the user task.
3031
*
@@ -44,8 +45,8 @@ abstract class TaskHandler {
4445
this.task = task
4546
}
4647

47-
/** Only for testing purpose */
48-
protected TaskHandler() { }
48+
@TestOnly
49+
protected TaskHandler() {}
4950

5051
/**
5152
* The task managed by this handler

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ class TaskProcessor {
284284
currentProcessor0 = this
285285
}
286286

287-
/* for testing purpose - do not remove */
288-
protected TaskProcessor() { }
287+
@TestOnly
288+
protected TaskProcessor() {}
289289

290290
/**
291291
* Create and initialize the processor object

modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class IncludeDef {
7171
this.modules = new ArrayList<>(modules)
7272
}
7373

74-
/** only for testing purpose -- do not use */
75-
protected IncludeDef() { }
76-
7774
IncludeDef from(Object path) {
7875
this.path = path
7976
return this

modules/nextflow/src/main/groovy/nextflow/script/ProcessConfig.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import nextflow.script.params.TupleInParam
4949
import nextflow.script.params.TupleOutParam
5050
import nextflow.script.params.ValueInParam
5151
import nextflow.script.params.ValueOutParam
52+
import nextflow.util.TestOnly
5253

5354
/**
5455
* Holds the process configuration properties
@@ -180,9 +181,8 @@ class ProcessConfig implements Map<String,Object>, Cloneable {
180181
this.processName = name
181182
}
182183

183-
/* Only for testing purpose */
184-
@PackageScope
185-
ProcessConfig( Map delegate ) {
184+
@TestOnly
185+
protected ProcessConfig( Map delegate ) {
186186
configProperties = delegate
187187
}
188188

modules/nextflow/src/main/groovy/nextflow/script/ProcessFactory.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ class ProcessFactory {
4040

4141
private ExecutorFactory executorFactory
4242

43-
/* only for test -- do not use */
44-
protected ProcessFactory() { }
45-
4643
ProcessFactory( BaseScript ownerScript, Session session ) {
4744
this.owner = ownerScript
4845
this.session = session

modules/nextflow/src/main/groovy/nextflow/script/ScriptMeta.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ class ScriptMeta {
133133
}
134134
}
135135

136-
/** only for testing */
137-
protected ScriptMeta() {}
138-
139136
void setScriptPath(Path path) {
140137
scriptsByPath.put(path, script)
141138
scriptPath = path

modules/nextflow/src/main/groovy/nextflow/script/WorkflowDef.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import nextflow.exception.MissingProcessException
2424
import nextflow.exception.MissingValueException
2525
import nextflow.exception.ScriptRuntimeException
2626
import nextflow.extension.CH
27+
import nextflow.util.TestOnly
2728
/**
2829
* Models a script workflow component
2930
*
@@ -67,7 +68,7 @@ class WorkflowDef extends BindableDef implements ChainableDef, IterableDef, Exec
6768
this.variableNames = getVarNames0()
6869
}
6970

70-
/* ONLY FOR TESTING PURPOSE */
71+
@TestOnly
7172
protected WorkflowDef() {}
7273

7374
WorkflowDef clone() {

modules/nextflow/src/main/groovy/nextflow/script/WorkflowMetadata.groovy

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import nextflow.config.Manifest
3333
import nextflow.exception.WorkflowScriptErrorException
3434
import nextflow.trace.WorkflowStats
3535
import nextflow.util.Duration
36+
import nextflow.util.TestOnly
3637
import org.codehaus.groovy.runtime.InvokerHelper
3738
/**
3839
* Models workflow metadata properties and notification handler
@@ -292,11 +293,8 @@ class WorkflowMetadata {
292293
return config.isEnabled() ? config.getEngine() : null
293294
}
294295

295-
/**
296-
* Only for testing purpose -- do not use
297-
*/
298-
@PackageScope
299-
WorkflowMetadata() {}
296+
@TestOnly
297+
protected WorkflowMetadata() {}
300298

301299
/**
302300
* Implements the following idiom in the pipeline script:

modules/nextflow/src/main/groovy/nextflow/script/params/FileOutParam.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import nextflow.exception.IllegalFileException
2626
import nextflow.file.FilePatternSplitter
2727
import nextflow.script.TokenVar
2828
import nextflow.util.BlankSeparatedList
29+
import nextflow.util.TestOnly
2930
/**
3031
* Model a process *file* output parameter
3132
*
@@ -35,9 +36,7 @@ import nextflow.util.BlankSeparatedList
3536
@InheritConstructors
3637
class FileOutParam extends BaseOutParam implements OutParam, ArityParam, OptionalParam, PathQualifier {
3738

38-
/**
39-
* ONLY FOR TESTING DO NOT USE
40-
*/
39+
@TestOnly
4140
protected FileOutParam(Map params) {
4241
super(new Binding(), [])
4342
}

modules/nextflow/src/main/groovy/nextflow/spack/SpackCache.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import nextflow.file.FileMutex
3232
import nextflow.util.CacheHelper
3333
import nextflow.util.Duration
3434
import nextflow.util.Escape
35+
import nextflow.util.TestOnly
3536
import org.yaml.snakeyaml.Yaml
3637
/**
3738
* Handle Spack environment creation and caching
@@ -71,9 +72,8 @@ class SpackCache {
7172

7273
@PackageScope Path getConfigCacheDir0() { configCacheDir0 }
7374

74-
/** Only for testing purpose - do not use */
75-
@PackageScope
76-
SpackCache() {}
75+
@TestOnly
76+
protected SpackCache() {}
7777

7878
/**
7979
* Create a Spack env cache object

modules/nextflow/src/main/groovy/nextflow/trace/TraceHelper.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import java.time.format.DateTimeFormatter
3030
import groovy.transform.CompileStatic
3131
import groovy.transform.Memoized
3232
import nextflow.exception.AbortOperationException
33+
import nextflow.util.TestOnly
3334

3435
/**
3536
* Helper methods for trace and observer feature
@@ -39,7 +40,7 @@ import nextflow.exception.AbortOperationException
3940
@CompileStatic
4041
class TraceHelper {
4142

42-
/* only for testing -- do not use */
43+
@TestOnly
4344
static protected String testTimestampFmt
4445

4546
static public final Instant launchTimestamp = Instant.now()

0 commit comments

Comments
 (0)