Phabricator phpunit configuration - coverage - phpunit

I am trying to set up a coverage report within the DIFF view for phabricator. I have the following configs:
.arcconfig
{
"project_id" : "SuperProject",
"conduit_uri" : "https://phabricator.dev/",
"unit.engine": "PhpunitTestEngine",
"unit.phpunit.binary": "./vendor/bin/phpunit",
"phpunit_config": "tests/phpunit.xml"
}
tests/phpunit.xml
<phpunit>
<testsuite name="unit">
<directory suffix="Test.php">unit/accountancy</directory>
....
<directory suffix="Test.php">unit/store</directory>
</testsuite>
<logging>
<log type="coverage-clover" target="../build/logs/clover.xml" />
</logging>
</phpunit>
But when I run arc unit --coverage --json, I get something like the following:
{
"0": {
"namespace": null,
"name": "Restriction\\CalculatorTest::testGetDiscount with data set #0",
"link": null,
"result": "pass",
"duration": 0.00362205505371,
"extra": null,
"userData": "",
"coverage": [] <-- why is it empty?
},
...
}
Seems like arcanist is not picking up coverage info. I've tried even looking through the phabricator source code, but couldn't find a clue on how to enable that.
Any suggestions are very welcome!

add whitelist to your tests/phpunit.xml. Check https://phpunit.de/manual/current/en/code-coverage-analysis.html#code-coverage-analysis.whitelisting-files

Related

Phpunit doesn't recognize my project namespaces and class names

recently I've recognized that the project opis/closure is facing issues with deprecated serialization solution for php 8.1.1. So I created a fork of that and tried to fix the issue, while I was fixing the issue, I tried to test the output with the phpunit. but I've got some errors shown bellow. can you please check and feed me back about how to solve these issues:
Title
Description
Operating system
macintosh
PHP version:
PHP 8.1.1 (cli) (built: Dec 17 2021 23:49:52) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.1, Copyright (c) Zend Technologies
PHP Unit version:
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Project Git repo:
https://github.com/rhashnull/closure (my fork)
The error message:
PHP Fatal error: Uncaught Error: Class "Opis\Closure\SerializableClosure" not found in /<private_path>/Projects/closure/tests/ClosureTest.php:447
Stack trace:
#0 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Util/FileLoader.php(56): include_once()
#1 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Util/FileLoader.php(43): PHPUnit\Util\FileLoader::load('/Users/arash/Pr...')
#2 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Framework/TestSuite.php(311): PHPUnit\Util\FileLoader::checkAndLoad('/Users/arash/Pr...')
#3 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Framework/TestSuite.php(394): PHPUnit\Framework\TestSuite->addTestFile('/Users/arash/Pr...')
#4 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Runner/BaseTestRunner.php(85): PHPUnit\Framework\TestSuite->addTestFiles(Array)
#5 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/TextUI/Command.php(108): PHPUnit\Runner\BaseTestRunner->getTest('/Users/arash/Pr...', Array)
phpunit.xml
<phpunit bootstrap="./vendor/autoload.php" verbose="true">
<testsuites>
<testsuite name="Main">
<file phpVersion="5.4.0" phpVersionOperator=">=">./tests/ClosureTest.php</file>
</testsuite>
<testsuite name="Serialize">
<file phpVersion="5.4.0" phpVersionOperator=">=">./tests/SerializeTest.php</file>
</testsuite>
<testsuite name="Recursive">
<file phpVersion="7.1.0" phpVersionOperator="<">./tests/RecursiveArrayTest.php</file>
</testsuite>
<testsuite name="Signed">
<file phpVersion="5.4.0" phpVersionOperator=">=">./tests/SignedClosureTest.php</file>
</testsuite>
<testsuite name="Namespace">
<file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceTest.php</file>
<file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceUnqualifiedTest.php</file>
<file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceFullyQualifiedTest.php</file>
<file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespacePartiallyQualifiedTest.php</file>
</testsuite>
<testsuite name="ReflectionClosure">
<file phpVersion="5.4.0" phpVersionOperator=">=">./tests/ReflectionClosureTest.php</file>
</testsuite>
<testsuite name="ReflectionClosure2">
<file phpVersion="7.0.0" phpVersionOperator=">=">./tests/ReflectionClosure2Test.php</file>
</testsuite>
<testsuite name="ReflectionClosure3">
<file phpVersion="7.1.0" phpVersionOperator=">=">./tests/ReflectionClosure3Test.php</file>
</testsuite>
<testsuite name="ReflectionClosure4">
<file phpVersion="7.2.0" phpVersionOperator=">=">./tests/ReflectionClosure4Test.php</file>
</testsuite>
<testsuite name="ReflectionClosure5">
<file phpVersion="7.4.0" phpVersionOperator=">=">./tests/ReflectionClosure5Test.php</file>
<file phpVersion="7.4.0" phpVersionOperator=">=">./tests/NamespaceGroupTest.php</file>
</testsuite>
<testsuite name="ReflectionClosure6">
<file phpVersion="8.0.0-dev" phpVersionOperator=">=">./tests/ReflectionClosure6Test.php</file>
</testsuite>
</testsuites>
</phpunit>
composer.json
{
"name": "opis/closure",
"description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.",
"keywords": ["closure", "serialization", "function", "serializable", "serialize", "anonymous functions"],
"homepage": "https://opis.io/closure",
"license": "MIT",
"authors": [
{
"name": "Marius Sarca",
"email": "marius.sarca#gmail.com"
},
{
"name": "Sorin Sarca",
"email": "sarca_sorin#hotmail.com"
}
],
"require": {
"php": "^5.4 || ^7.0 || ^8.0"
},
"require-dev": {
"jeremeamia/superclosure": "^2.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"autoload": {
"psr-4": {
"Opis\\Closure\\": "src/"
},
"files": ["functions.php"]
},
"autoload-dev": {
"psr-4": {
"Opis\\Closure\\Test\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.6.x-dev"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
Special thanks to your attention.

Shorthand to speficy tests to run in dotnet core

I am aware of the --filter option to select the tests to run in dotnet core from the command line. For instance:
dotnet test --filter FullyQualifiedName!~IntegrationTests
What I am looking for is a way to do something like this?
dotnet test --onlyUnitTests
Where --onlyUnitTests would defined by the user in a settings file of some sort. Something like:
{
"onlyUnitTests": "--filter FullyQualifiedName\!~IntegrationTests"
}
Is this possible?
The closer a I got is adding a task in the file tasks.json
"tasks": [
{
"label": "Run Unit Tests",
"command": "dotnet",
"type": "shell",
"args": [
"test",
"--filter",
"FullyQualifiedName\!~IntegrationTests"],
"problemMatcher": []
},
Now if I do Ctrl+Shift+P -> Run Tasks -> Run Unit Tests all my unit tests get executed.

Is there a plugin for WordPress .po file support in IntelliJ?

Since I've posted this question in several software forms and got no useful answer, I hope to get an answer here from you as my colleges.
If you program in WordPress, you might now translations files .po/.mo. I'm looking now for a plugin in IntelliJ / WebStorm that can generate .mo files and extend the .po files above each translation by the used places:
#: /includes/.......
msgid "Cheatin’ huh?"
msgstr "So geht das leider nicht.."
So does anyone knows if there is a plugin that can do this? It would be enough to not enter the usage each time manually because this annoys me so much. The generation would only be a nice to have.
Thanks a lot!
As of writing this answer there is still no plugin that does this seemlessly. However you can acheive automation using a GRUNT task.
Using Grunt requires you have a nodejs development environment configured
Create a package.json in your project root similar to
{
"name": "yourProject",
"majorVersion": "0",
"minorVersion": "0",
"incrementalVersion": "1",
"qualifier": "-alpha",
"version": "0.0.1-alpha",
"description": "My great idea",
"main": "GruntFile.js",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://yourgitrepo.com/name/project.git"
},
"dependencies": {},
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-exec": "^3.0.0",
"grunt-pot": "^0.3.0",
"grunt-replace": "^2.0.2",
"load-grunt-tasks": "^5.1.0",
"npm-cli": "^0.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Your Name",
"license": "SEE LICENCE IN LICENCE.txt"
}
Once created navigate using a terminal and run
npm install
This creates a node environment.
Now create a GruntFile.js
See below for example.
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
prvPkg: grunt.file.readJSON('private.json'),
clean: {
standard: ['myproject/target',
],
},
makepot: {
target: {
options: {
cwd: 'myproject/target/generated/myproject',
include: ['.*'],
domainPath: 'languages/', // Where to save the POT file.
mainFile: 'myproject.php', // Main project file.
potFilename: 'myproject.pot', // Name of the POT file.
type: 'wp-plugin',
potHeaders: {
'report-msgid-bugs-to': 'https://www.myproject.com.au',
'plural-forms': 'nplurals=2; plural=n != 1;',
'last-translator': 'Author Name <author#myproject.com.au>',
'language-team': 'My Team <author#myproject.com.au>',
poedit:true,
'x-poedit-keywordslist': true,
'x-textdomain-support': 'yes'
}
}
}
},
});
// Default task(s).
grunt.registerTask('createMachineLanguage', '', function () {
let exec = require('child_process').execSync;
let options = {
cwd: 'myproject/target/generated/myproject/languages/',
encoding: 'utf8'
}
let result = exec("msginit --no-translator --input=myproject.pot --locale=en --output=myproject_en_AU.po",options);
result += exec("msgfmt myproject_en_AU.po -o myproject_en_AU.mo",options);
result += exec("rm myproject_en_AU.po",options);
grunt.log.writeln(result);
});
grunt.registerTask('default',['clean:standard','makepot','createMachineLanguage'] );
}
The critical components are the grunt-pot grunt plugin. Your terminal environment must have the GNU gettext intalled which provides the function
msginit and msgfmt. The grunt process executes these tasks automatically.
Please note my environment was Ubuntu so you can see I use an rm to remove the po file once it is converted to an mo file.
So using the GruntTask plugin you can create your language files automatically. Executing them from GruntTask.

Fresh install of Trellis by Roots on Ubuntu & VituralBox is missing composer.json under /srv/www/website.com/current

This is the error message I got when I first run 'vagrant provision' (after command 'vagrant up' blocked in 'Mounting NFS shared folders...') under the trellis directory:
TASK [wordpress-install : Install Dependencies with Composer] ******************
System info:
Ansible 2.9.11; Vagrant 2.2.9; Linux
Trellis version (per changelog): "Removes ID from Lets Encrypt bundled certificate and make filename stable"
---------------------------------------------------
Composer could not find a composer.json file in /srv/www/example.com/current
To initialize a project, please create a composer.json file
as described in the https://getcomposer.org/ "Getting Started"
section failed: [default] (item=example.com) =>
{
"ansible_loop_var": "item",
"changed": false,
"item": {
"key": "example.com",
"value": {
"admin_email": "admin#example.test",
"cache": {
"enabled": false
},
"local_path": "../site",
"multisite": {
"enabled": false
},
"site_hosts": [
{
"canonical": "example.test",
"redirects": [
"www.example.test"
]
}
],
"ssl": {
"enabled": false,
"provider": "self-signed"
}
}
},
"stdout": "Composer could not find a composer.json file in /srv/www/example.com/current\nTo initialize a project, please create a composer.json file as described in the https://getcomposer.org/ \"Getting Started\" section\n",
"stdout_lines": [
"Composer could not find a composer.json file in /srv/www/example.com/current",
"To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ \"Getting Started\" section"
]
}
PLAY RECAP *********************************************************************
default : ok=125 changed=83 unreachable=0 failed=1 skipped=34 rescued=0 ignored=0
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
How do I fix this? Where to find the right composer.json for Trellis, Bedrock, and Sage for local development on Linux?
Ubuntu 19.10

Packr windows exe not working

Downloaded the packr from https://github.com/libgdx/packr &
Packr json is
{
"platform": "windows64",
"jdk": "C:/Program Files/Java/jdk1.8.0_72",
"executable": "myapp",
"classpath": [
"input/test-hello.jar"
],
"mainclass": "Main",
"vmargs": [
"Xmx1G"
],
"minimizejre": "soft",
"output": "out-windows64",
"verbose": true
}
test-hello.jar has Main.class which simply writes "Hello" on System.out.
There is no error reported while packaging the exe. However, when I run the exe, there is no output on the console. Is there anything in the json that I am missing? Does anyone have a simple working example?
You need to include the path to the main class, for example
"mainclass": "com.example.Main",

Resources