Skip to content

Commit

Permalink
Mark test constructors as TestOnly or remove
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Aug 9, 2024
1 parent 2a71206 commit f6dc9eb
Show file tree
Hide file tree
Showing 55 changed files with 175 additions and 262 deletions.
4 changes: 2 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPull.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import groovy.util.logging.Slf4j
import nextflow.exception.AbortOperationException
import nextflow.plugin.Plugins
import nextflow.scm.AssetManager
import nextflow.util.TestOnly
/**
* CLI sub-command PULL
*
Expand Down Expand Up @@ -49,7 +50,7 @@ class CmdPull extends CmdBase implements HubOptions {
@Override
final String getName() { NAME }

/* only for testing purpose */
@TestOnly
protected File root

@Override
Expand All @@ -64,7 +65,6 @@ class CmdPull extends CmdBase implements HubOptions {
return
}

/* only for testing purpose */
if( root ) {
AssetManager.root = root
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import nextflow.file.FileMutex
import nextflow.util.CacheHelper
import nextflow.util.Duration
import nextflow.util.Escape
import nextflow.util.TestOnly
import org.yaml.snakeyaml.Yaml
/**
* Handle Conda environment creation and caching
Expand Down Expand Up @@ -86,9 +87,8 @@ class CondaCache {
return "conda"
}

/** Only for testing purpose - do not use */
@PackageScope
CondaCache() {}
@TestOnly
protected CondaCache() {}

/**
* Create a Conda env cache object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import groovy.transform.CompileStatic
@CompileStatic
class ApptainerCache extends SingularityCache {

/** only for testing */
protected ApptainerCache() {}

ApptainerCache(ContainerConfig config, Map<String,String> env=null) {
super(config, env)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ class CharliecloudCache {

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

private String registry

/** Only for debugging purpose - do not use */
@PackageScope
CharliecloudCache() {}

/**
* Create a Charliecloud cache object
*
Expand All @@ -81,14 +75,6 @@ class CharliecloudCache {
def p = imageUrl.indexOf('://')
def name = p != -1 ? imageUrl.substring(p+3) : imageUrl

// add registry
if( registry ) {
if( !registry.endsWith('/') ) {
registry += '/'
}
name = registry + name
}

name = name.replace(':','+').replace('/','%')
return name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class SingularityCache {

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

/** Only for debugging purpose - do not use */
@PackageScope
SingularityCache() {}

protected String getBinaryName() { return 'singularity' }

protected String getAppName() { getBinaryName().capitalize() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import nextflow.processor.TaskRun
import nextflow.secret.SecretsLoader
import nextflow.util.Escape
import nextflow.util.MemoryUnit
import nextflow.util.TestOnly
/**
* Builder to create the Bash script which is used to
* wrap and launch the user task
Expand Down Expand Up @@ -124,8 +125,8 @@ class BashWrapperBuilder {
this.copyStrategy = strategy ?: new SimpleFileCopyStrategy(bean)
}

/** only for testing -- do not use */
protected BashWrapperBuilder() { }
@TestOnly
protected BashWrapperBuilder() {}

/**
* @return The bash script fragment to change to the 'scratch' directory if it has been specified in the task configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import nextflow.processor.TaskRun
import nextflow.trace.TraceRecord
import nextflow.util.CmdLineHelper
import nextflow.util.Duration
import nextflow.util.TestOnly
import nextflow.util.Throttle
/**
* Handles a job execution in the underlying grid platform
Expand Down Expand Up @@ -83,7 +84,7 @@ class GridTaskHandler extends TaskHandler implements FusionAwareTask {

BatchCleanup batch

/** only for testing purpose */
@TestOnly
protected GridTaskHandler() {}

GridTaskHandler( TaskRun task, AbstractGridExecutor executor ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ class DumpOp {
return this
}

/** Only for testing -- do not use */
protected DumpOp() {}


boolean isEnabled() {
if( !dumpNames )
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class TransposeOp {
this.remainder = params?.remainder as Boolean
}

/**
* Only for test -- do not use
*/
@PackageScope
TransposeOp() {}

private List<Integer> parseByParam(value) {
if( value == null )
return Collections.emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import java.nio.file.attribute.BasicFileAttributes

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.util.TestOnly
import nextflow.util.Threads

/**
Expand Down Expand Up @@ -79,7 +80,7 @@ class DirWatcher implements DirListener {

private volatile boolean terminated

/* only for testing */
@TestOnly
protected DirWatcher() {}

DirWatcher(String syntax, String folder, String pattern, boolean skipHidden, String events, FileSystem fs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import java.nio.file.WatchEvent
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.util.Duration
import nextflow.util.TestOnly
import org.apache.commons.io.monitor.FileAlterationListener
import org.apache.commons.io.monitor.FileAlterationMonitor
import org.apache.commons.io.monitor.FileAlterationObserver
Expand Down Expand Up @@ -73,7 +74,8 @@ class DirWatcherV2 implements DirListener, FileAlterationListener {

private FileAlterationMonitor monitor

protected DirWatcherV2() { }
@TestOnly
protected DirWatcherV2() {}

DirWatcherV2(String syntax, String folder, String pattern, boolean skipHidden, String events, FileSystem fs) {
assert syntax in ['regex','glob']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class FusionScriptLauncher extends BashWrapperBuilder {
private Path remoteWorkDir
private Map<String,String> env

/* ONLY FOR TESTING - DO NOT USE */
protected FusionScriptLauncher() { }

static FusionScriptLauncher create(TaskBean bean, String scheme) {

final remoteWorkDir = bean.workDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import nextflow.processor.TaskStatus
import nextflow.trace.TraceRecord
import nextflow.util.Escape
import nextflow.util.PathTrie
import nextflow.util.TestOnly
/**
* Implements the {@link TaskHandler} interface for Kubernetes pods
*
Expand Down Expand Up @@ -97,10 +98,8 @@ class K8sTaskHandler extends TaskHandler implements FusionAwareTask {
this.resourceType = executor.k8sConfig.useJobResource() ? ResourceType.Job : ResourceType.Pod
}

/** only for testing -- do not use */
protected K8sTaskHandler() {

}
@TestOnly
protected K8sTaskHandler() {}

/**
* @return The workflow execution unique run name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ class K8sWrapperBuilder extends BashWrapperBuilder {
this.headerScript = "NXF_CHDIR=${Escape.path(task.workDir)}"
}

/**
* only for testing purpose -- do not use
*/
protected K8sWrapperBuilder() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import nextflow.Global
import nextflow.exception.ProcessException
import nextflow.script.ScriptBinding
import nextflow.util.KryoHelper
import nextflow.util.TestOnly
/**
* Map used to delegate variable resolution to script scope
*
Expand Down Expand Up @@ -91,7 +92,7 @@ class TaskContext implements Map<String,Object>, Cloneable {
log.trace "Binding names for '$name' > $variableNames"
}

/** ONLY FOR TEST PURPOSE -- do not use */
@TestOnly
protected TaskContext() { }

TaskContext clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.trace.TraceRecord
import nextflow.util.TestOnly
/**
* Actions to handle the underlying job running the user task.
*
Expand All @@ -41,8 +42,8 @@ abstract class TaskHandler {
this.task = task
}

/** Only for testing purpose */
protected TaskHandler() { }
@TestOnly
protected TaskHandler() {}

/**
* The task managed by this handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ class TaskProcessor {
currentProcessor0 = this
}

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

/**
* Create and initialize the processor object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class IncludeDef {
this.modules = new ArrayList<>(modules)
}

/** only for testing purpose -- do not use */
protected IncludeDef() { }

IncludeDef from(Object path) {
this.path = path
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import nextflow.script.params.TupleInParam
import nextflow.script.params.TupleOutParam
import nextflow.script.params.ValueInParam
import nextflow.script.params.ValueOutParam
import nextflow.util.TestOnly

/**
* Holds the process configuration properties
Expand Down Expand Up @@ -185,9 +186,8 @@ class ProcessConfig implements Map<String,Object>, Cloneable {
this.processName = name
}

/* Only for testing purpose */
@PackageScope
ProcessConfig( Map delegate ) {
@TestOnly
protected ProcessConfig( Map delegate ) {
configProperties = delegate
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class ProcessFactory {

private ExecutorFactory executorFactory

/* only for test -- do not use */
protected ProcessFactory() { }

ProcessFactory( BaseScript ownerScript, Session session ) {
this.owner = ownerScript
this.session = session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class ScriptMeta {
}
}

/** only for testing */
protected ScriptMeta() {}

@PackageScope
void setScriptPath(Path path) {
scriptPath = path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import nextflow.exception.MissingProcessException
import nextflow.exception.MissingValueException
import nextflow.exception.ScriptRuntimeException
import nextflow.extension.CH
import nextflow.util.TestOnly
/**
* Models a script workflow component
*
Expand Down Expand Up @@ -67,7 +68,7 @@ class WorkflowDef extends BindableDef implements ChainableDef, IterableDef, Exec
this.variableNames = getVarNames0()
}

/* ONLY FOR TESTING PURPOSE */
@TestOnly
protected WorkflowDef() {}

WorkflowDef clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import nextflow.config.Manifest
import nextflow.exception.WorkflowScriptErrorException
import nextflow.trace.WorkflowStats
import nextflow.util.Duration
import nextflow.util.TestOnly
import org.codehaus.groovy.runtime.InvokerHelper
/**
* Models workflow metadata properties and notification handler
Expand Down Expand Up @@ -286,11 +287,8 @@ class WorkflowMetadata {
return config.isEnabled() ? config.getEngine() : null
}

/**
* Only for testing purpose -- do not use
*/
@PackageScope
WorkflowMetadata() {}
@TestOnly
protected WorkflowMetadata() {}

/**
* Implements the following idiom in the pipeline script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import nextflow.exception.IllegalFileException
import nextflow.file.FilePatternSplitter
import nextflow.script.TokenVar
import nextflow.util.BlankSeparatedList
import nextflow.util.TestOnly
/**
* Model a process *file* output parameter
*
Expand All @@ -35,9 +36,7 @@ import nextflow.util.BlankSeparatedList
@InheritConstructors
class FileOutParam extends BaseOutParam implements OutParam, ArityParam, OptionalParam, PathQualifier {

/**
* ONLY FOR TESTING DO NOT USE
*/
@TestOnly
protected FileOutParam(Map params) {
super(new Binding(), [])
}
Expand Down
Loading

0 comments on commit f6dc9eb

Please sign in to comment.