How to include a directory and your subdirectories with simplecov - ruby

How can I add folder and subfolders of my libs to simplecov generate the coverage?
My SimpleCov Config
SimpleCov.start do
add_group 'Bot', 'app/bots'
add_group 'Bot', 'lib/bot'
add_group 'Controllers', 'app/controllers'
add_group 'Models', 'app/models'
add_group 'Helpers', 'app/helpers'
add_group 'Libraries', 'lib'
end
This is my lib tree
├── assets
├── bot
│   ├── base_bot_logic.rb
│   ├── bot_logic.rb
│   ├── core
│   │   ├── blacklist.rb
│   │   ├── bot_core.rb
│   │   ├── broadcast.rb
│   │   ├── emoji.rb
│   │   ├── profile.rb
│   │   ├── reply.rb
│   │   ├── setup.rb
│   │   ├── state_machine.rb
│   │   └── webview.rb
│   └── geoutils
│   └── geoutils.rb
├── estrutura.txt
├── solar
│   ├── api.rb
│   ├── assistido.rb
│   ├── atendimento.rb
│   └── validation
│   └── cpf.rb
├── solar.rb
└── tasks
7 directories, 18 files
But only two files are recognized by SimpleCov.
How I can add missing folders?
EDIT:
I add track_files '{app,lib}/**/*.rb' in my SimpleCov.start and it recognize mys files, but don't calculate the coverage rate.

Although I missed the party, I will answer
Getting started contains answer on your question:
If SimpleCov starts after your application code is already loaded (via
require), it won't be able to track your files and their coverage! The
SimpleCov.start must be issued before any of your application code is
required!
In this way, its correctly:
require 'simplecov'
require 'yourapp'
its NOT correctly:
require 'yourapp'
require 'simplecov'
track_files just includes files matched by this glob, whether or not they were explicitly required.

Related

Copying entire folder structure from a role merging/overwriting with already existing files

I use Ansible to deploy my userspecific configuration (shell, texteditor, etc.) on a newly installed system. That's why i have all config files in my roles file directory, structured the same way as they should be placed in my home directory.
What's the correct way to realize this? I don't want to list every single file in the role and exisiting files should be overwriten, existing directories should be merged.
I've tried the copy module, but the whole task is skipped; I assume because the parent directory(.config) already exist.
Edit: add the requested additional information
Ansible Version: 2.9.9
The roles copy task:
- name: Install user configurations
copy:
src: "home/"
dest: "{{ ansible_env.HOME }}"
The Files to copy in the role directory:
desktop-enviroment
├── defaults
│   └── main.yml
├── files
│   └── home
│   ├── .config
│   │   ├── autostart-scripts
│   │   │   └── ssh-keys.sh
│   │   ├── MusicBrainz
│   │   │   ├── Picard
│   │   │   ├── Picard.conf
│   │   │   └── Picard.ini
│   │   ├── sublime-text-3
│   │   │   ├── Installed Packages
│   │   │   ├── Lib
│   │   │   ├── Local
│   │   │   └── Packages
│   │   └── yakuakerc
│   └── .local
│   └── share
│   ├── plasma
│   └── yakuake
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── tasks
│   ├── desktop-common.yaml
│   ├── desktop-gnome.yaml
│   ├── desktop-kde.yaml
│   └── main.yml
├── templates
└── vars
└── main.yml
The relevant ansible output:
TASK [desktop-enviroment : Install user configurations] **
ok: [localhost]

Correct directory structure for Puppet RSpec testing

I'm having some issues creating unit tests for my Puppet control repository.
I mostly work with roles and profiles with the following directory structure:
[root#puppet]# tree site
site
├── profile
│   ├── files
│   │   └── demo-website
│   │   └── index.html
│   └── manifests
│   ├── base.pp
│   ├── ci_runner.pp
│   ├── docker.pp
│   ├── gitlab.pp
│   ├── logrotate.pp
│   └── website.pp
├── role
│   └── manifests
│   ├── gitlab_server.pp
│   └── nginx_webserver.pp
Where do I need to place my spec files and what are the correct filenames?
I tried placing them here:
[root#puppet]# cat spec/classes/profile_ci_runner_spec.rb
require 'spec_helper'
describe 'profile::ci_runner' do
...
But I get an error:
Could not find class ::profile::ci_runner
The conventional place for a module's spec tests is in the module, with the spec/ directory in the module root. So site/profile/spec/classes/ci_runner_spec.rb, for example.
You could consider installing PDK, which can help you set up the structure and run tests, among other things.

How do I split up the settings.kts file for TeamCity's Kotlin Configuration?

I have a TeamCity settings.kts file where it consists of the Root Project and hence all subsequent sub project. Currently, it's one big massive file and I am trying to split up the KTS file based on projects.
What's the best practice to split up the settings file? Should I do a file per project and how do I reference them from the main settings file?
TeamCity generates a singe settings.kts file only for small projects.
You can try and play with some big project, download settings in Kotlin format for it.
E.g., here is how generated by TeamCity big project settings look like:
nadias-mbp:projectSettings 2 nburnasheva$ tree
.
├── README
├── ServiceMessages
│   ├── Project.kt
│   └── buildTypes
│   ├── ServiceMessagesChangeBuildStatus.kt
│   ├── ServiceMessages_BuildProgressServiceMessage.kt
│   ├── ServiceMessages_ErrorParsingServiceMessage.kt
│   ├── ServiceMessages_FailBuild.kt
│   └── ServiceMessages_ReportBuildParameterDoNotReport.kt
├── ServiceMessages_ReportBuildParametersChar
│   ├── Project.kt
│   └── buildTypes
│   ├── ServiceMessages_ReportBuildParametersChar_ReportBuildParameter.kt
│   ├── ServiceMessages_ReportBuildParametersChar_ReportBuildParameterWaitReasonWithTooLongValue.kt
│   └── ServiceMessages_ReportBuildParametersChar_ThreadSleep.kt
├── ServiceMessages_ReportBuildParametersChartCopy
│   ├── Project.kt
│   └── buildTypes
│   └── ServiceMessages_ReportBuildParametersChartCopy_ReportBuildPara.kt
├── _Self
│   ├── Project.kt
│   ├── buildTypes
│   │   ├── AnsiParseAnsiColorLoggerOutput.kt
│   │   ├── BuildStepsAutodetection.kt
│   │   ├── CheckPromptParameter.kt
│   │   ├── EchoBuildIdToFile.kt
│   │   ├── EchoParametersToConsole.kt
│   │   ├── EchoUmlaut.kt
│   │   ├── FailBuildOnTextInTheLogs.kt
│   │   ├── MpsQuottingTest.kt
│   │   ├── RunGitCommand.kt
│   │   ├── RunMavenFromCommandLine.kt
│   │   ├── SetPasswordParameterInServiceMessages.kt
│   │   ├── SimpleWindowsEcho.kt
│   │   ├── SparseFile.kt
│   │   └── StderrRunAsOnMacOS.kt
│   └── vcsRoots
│   ├── HttpsGithubComBanadigaPhotoBackupGitRefsHeadsMaster.kt
│   └── HttpsGithubComBurnashevaCommandLineRunnerGitRefsHeadsMaster.kt
├── pom.xml
└── settings.kts
9 directories, 32 files
And here is the content of settings.kts:
import jetbrains.buildServer.configs.kotlin.v2018_2.*
version = "2019.1"
project(_Self.Project)

How should the gradle build scripts be to modularize this application?

I am trying to apply an example from the book Gradle in Action to learn how to separate a gradle application into subprojects. I did the example in the book and everything worked out fine.
I decided to apply the same concepts to a sample application from the Griffon Framework called minimalistic build, source code: sources. I selected this application because it follows the normal application structure instead of Griffon's, and I was trying to fill the gap (IMHO) in Griffon's documentation for multi project builds: it has one exaple that uses Open-Dolphin, Swing, JavaFX, Servlets that I felt it was too complicated to learn the basics.
Of course I hit the wall big time, multiple times...
Griffon's JavaFX application has the following structure:
├── build.gradle
├── config
│   └── HEADER
├── gradle
│   ├── functional-test.gradle
│   ├── integration-test.gradle
│   ├── javafx-plugin.gradle
│   └── wrapper
│   ├── gradle-wrapper.jar
│   └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── src
├── functional-test
│   └── java
│   └── org
│   └── example
│   └── SampleFunctionalTest.java
├── integration-test
│   └── java
│   └── org
│   └── example
│   └── SampleIntegrationTest.java
├── main
│   ├── java
│   │   ├── Config.java
│   │   └── org
│   │   └── example
│   │   ├── Launcher.java
│   │   ├── SampleController.java
│   │   ├── SampleModel.java
│   │   ├── SampleService.java
│   │   └── SampleView.java
│   └── resources
│   ├── application.properties
│   ├── griffon-icon-128x128.png
│   ├── griffon-icon-16x16.png
│   ├── griffon-icon-24x24.png
│   ├── griffon-icon-256x256.png
│   ├── griffon-icon-32x32.png
│   ├── griffon-icon-48x48.png
│   ├── griffon-icon-64x64.png
│   ├── griffon.png
│   ├── log4j.properties
│   ├── messages.properties
│   ├── META-INF
│   │   └── griffon
│   │   ├── griffon.core.artifact.GriffonController
│   │   ├── griffon.core.artifact.GriffonModel
│   │   ├── griffon.core.artifact.GriffonService
│   │   └── griffon.core.artifact.GriffonView
│   ├── org
│   │   └── example
│   │   └── sample.fxml
│   └── resources.properties
└── test
└── java
└── org
└── example
├── SampleControllerTest.java
└── SampleServiceTest.java
The build.gradle file content is:
// tag::plugins[]
plugins {
id 'java'
id 'idea'
id 'com.github.ben-manes.versions' version '0.12.0'
id 'com.github.hierynomus.license' version '0.11.0'
}
apply from: 'gradle/javafx-plugin.gradle'
apply from: 'gradle/integration-test.gradle'
apply from: 'gradle/functional-test.gradle'
// end::plugins[]
// tag::javafx[]
javafx {
mainClass = 'org.example.Launcher'
}
// end::javafx[]
// tag::dependencies[]
repositories {
jcenter()
mavenLocal()
}
dependencies {
compile "org.codehaus.griffon:griffon-javafx:${griffonVersion}"
compile "org.codehaus.griffon:griffon-guice:${griffonVersion}"
runtime('log4j:log4j:1.2.17') {
exclude group: 'ant', module: 'ant-nodeps'
exclude group: 'ant', module: 'ant-junit'
exclude group: 'ant-contrib', module: 'ant-contrib'
}
runtime 'org.slf4j:slf4j-log4j12:1.7.21'
testCompile "org.codehaus.griffon:griffon-javafx-test:${griffonVersion}"
testCompile 'pl.pragmatists:JUnitParams:1.0.5'
testCompile 'org.mockito:mockito-core:2.0.59-beta'
}
// end::dependencies[]
// tag::resources[]
processResources {
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.properties'
exclude '**/*.xml'
}
from(sourceSets.main.resources.srcDirs) {
include '**/*.properties'
include '**/*.xml'
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
'application.name' : project.name,
'application.version': project.version,
'griffon.version' : griffonVersion
])
}
}
// end::resources[]
license {
header = rootProject.file('config/HEADER')
strictCheck = true
ignoreFailures = true
mapping {
java = 'SLASHSTAR_STYLE'
fxml = 'XML_STYLE'
}
ext.year = '2016'
exclude '**/*.png'
}
And the structure I was trying to achieve is:
├── build.gradle
├── config
│   └── HEADER
├── gradle
│   ├── functional-test.gradle
│   ├── integration-test.gradle
│   ├── javafx-plugin.gradle
│   └── wrapper
│   ├── gradle-wrapper.jar
│   └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── launcher
│   ├── launcher-build.gradle
│   └── src
│   └── main
│   └── java
│   ├── Config.java
│   └── org
│   └── example
│   └── Launcher.java
├── resources
│   ├── resources-build.gradle
│   └── src
│   └── main
│   └── resources
│   ├── application.properties
│   ├── griffon-icon-128x128.png
│   ├── griffon-icon-16x16.png
│   ├── griffon-icon-24x24.png
│   ├── griffon-icon-256x256.png
│   ├── griffon-icon-32x32.png
│   ├── griffon-icon-48x48.png
│   ├── griffon-icon-64x64.png
│   ├── griffon.png
│   ├── log4j.properties
│   ├── messages.properties
│   └── resources.properties
├── service
│   ├── resources
│   │   └── META-INF
│   │   └── griffon
│   │   └── griffon.core.artifact.GriffonController
│   ├── service-build.gradle
│   └── src
│   ├── main
│   │   └── java
│   │   └── org
│   │   └── example
│   │   └── SampleService.java
│   └── test
│   └── java
│   └── org
│   └── example
│   └── SampleServiceTest.java
├── settings.gradle
└── view
├── src
│   ├── functional-test
│   │   └── java
│   │   └── org
│   │   └── example
│   │   └── SampleFunctionalTest.java
│   ├── integration-test
│   │   └── java
│   │   └── org
│   │   └── example
│   │   └── SampleIntegrationTest.java
│   ├── main
│   │   ├── java
│   │   │   └── org
│   │   │   └── example
│   │   │   ├── SampleController.java
│   │   │   ├── SampleModel.java
│   │   │   └── SampleView.java
│   │   └── resources
│   │   ├── META-INF
│   │   │   └── griffon
│   │   │   ├── griffon.core.artifact.GriffonModel
│   │   │   ├── griffon.core.artifact.GriffonService
│   │   │   └── griffon.core.artifact.GriffonView
│   │   └── org
│   │   └── example
│   │   └── sample.fxml
│   └── test
│   └── java
│   └── org
│   └── example
│   └── SampleControllerTest.java
└── view-build.gradle
I don't know if that structure is the one that makes more sense, but is the one I first thought of.
Regardless everything I tried I could not build this project and I am wondering if anyone could tell me if I made a mistake with the selection of the subprojects and what should be the content for the build files.
I created a zip file with the rearranged source here keeping the original build.gradle file untouched, with a settings.gradle file that makes Gradle properly recognize the new structure.
Thanks!
The problem is caused by missing resource files in the service project. You'll find a similar problem in the view project. This is is because all resource files were moved to another location (the resources project). There was no problem before splitting the application into subprojects because all resources were at the right place.
You can fix the build by following these steps:
$ cd service
$ mkdir -p src/test/resources
$ touch src/test/resources/Config.properties
$ mkdir -p src/main/resources
$ mv ../resources/src/main/resources/messages.properties src/main/resources/
$ cd ../view
$ mkdir -p src/test/resources
$ touch src/test/resources/Config.properties
This should be enough to make the tests green again.
Marcelo,
I've posted a new version of the multi-project build here. This version keeps common setup at the root level, leaving what's specific to each subproject on each subproject's build file.

concatenate all imports into one scss file

I'm currently working on a SASS library which is a long list of partials imported into 1 file.
The file structure is as following:
css-directory
├── functions
│   ├── _px2em.scss
│   └── _unitless.scss
├── helpers
│   ├── _align.scss
│   ├── _clearfix.scss
│   ├── _float.scss
│   ├── _hidden.scss
│   ├── _invisible.scss
│   ├── _ir.scss
│   └── _visuallyhidden.scss
├── layout
│   ├── _blockquote.scss
│   ├── _button.scss
│   ├── _fixed-footer.scss
│   ├── _form.scss
│   ├── _list.scss
│   ├── _loading.scss
│   ├── _triangle.scss
│   └── _truncate.scss
├── modules
│   ├── _grid.scss
│   └── _normalize.scss
├── prefixes
│   ├── _animation-delay.scss
│   ├── _animation.scss
│   ├── _background-clip.scss
│   ├── _borderbox.scss
│   ├── _border-radius.scss
│   ├── _box-shadow.scss
│   ├── _box-sizing.scss
│   ├── _flex.scss
│   ├── _font-face.scss
│   ├── _gradient.scss
│   ├── _hyphens.scss
│   ├── _keyframes.scss
│   ├── _transform-origin.scss
│   ├── _transform.scss
│   ├── _transition.scss
│   └── _user-select.scss
└── _verepo.scss
and the _verepo.scss file imports all the other partials.
I'd like to be able to concatenate _verepo.scss and it's partials into 1 .scss file so that I can then distribute it easily.
Found a solution, by using grunt and grunt-contrib-concat.
Fixed it with the following code block inside of grunt's initConfig:
concat: {
options: {
banner: '/*! veRepo.scss v%VERSION% | MIT License | https://github.com/varemenos/verepo */\n\n'
},
dist: {
src: [
'src/functions/_**.scss',
'src/prefixes/_**.scss',
'src/helpers/_**.scss',
'src/layout/_**.scss',
'src/modules/_**.scss',
],
dest: '_verepo.scss'
}
}

Resources