override fun analyze()

in plugin-dotnet-agent/src/main/kotlin/jetbrains/buildServer/dotnet/commands/vstest/VSTestLoggerEnvironmentAnalyzerImpl.kt [18:50]


    override fun analyze(targets: List<File>) {
        LOG.debug("Analyze targets to run tests")
        val checkoutDir = _pathsService.getPath(PathType.Checkout)
        val checkoutCanonical = checkoutDir.absoluteFile.canonicalPath
        val invalidTargets = mutableListOf<File>()
        val allTargets = targets.toMutableList()
        var useWorkingDirectory = false
        if (allTargets.isEmpty()) {
            allTargets.add(_pathsService.getPath(PathType.WorkingDirectory))
            useWorkingDirectory = true
        }

        for (target in allTargets) {
            if (_fileSystemService.isAbsolute(target)) {
                if (!target.absoluteFile.canonicalPath.startsWith(checkoutCanonical)) {
                    invalidTargets.add(target)
                    LOG.debug("\"$target\" is invalid to run tests")
                }

                continue
            }

            LOG.debug("\"$target\" is ok to run tests")
        }

        if (invalidTargets.isNotEmpty()) {
            val invalidTargetsList = invalidTargets.distinctBy { it.absolutePath }.joinToString(", ") { it.path }
            val targetType = if (useWorkingDirectory) "directory \"$invalidTargetsList\" is" else "file(s) \"$invalidTargetsList\" are"
            val warning = "The $targetType located outside of the build checkout directory: \"$checkoutDir\". In this case there can be problems with running this build tests on TeamCity agent. Please refer to this issue for details: https://youtrack.jetbrains.com/issue/TW-52485"
            LOG.warn(warning)
            _loggerService.writeWarning(warning)
        }
    }