Skip to content

Commit

Permalink
Merge pull request #49 from proDOOMman/develop
Browse files Browse the repository at this point in the history
v2.3
  • Loading branch information
proDOOMman authored Jul 10, 2020
2 parents 5891496 + e0b9615 commit 7278f16
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 122 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'com.clouds42'
version '2.2-SNAPSHOT'
version '2.3'

sourceCompatibility = 11

Expand Down
35 changes: 9 additions & 26 deletions choco/coverage41c.nuspec
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<!-- == PACKAGE SPECIFIC SECTION == -->
<!-- This section is about this package, although id and version have ties back to the software -->
<!-- id is lowercase and if you want a good separator for words, use '-', not '.'. Dots are only acceptable as suffixes for certain types of packages, e.g. .install, .portable, .extension, .template -->
<!-- If the software is cross-platform, attempt to use the same id as the debian/rpm package(s) if possible. -->
<id>Coverage41C</id>
<!-- version should MATCH as closely as possible with the underlying software -->
<!-- Is the version a prerelease of a version? https://docs.nuget.org/create/versioning#creating-prerelease-packages -->
<!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
<version>2.2</version>
<version>2.3</version>
<packageSourceUrl>https://github.com/proDOOMman/Coverage41C</packageSourceUrl>
<owners>proDOOMman</owners>
<!-- ============================== -->
<!-- == SOFTWARE SPECIFIC SECTION == -->
<!-- This section is about the software itself -->
<title>Coverage41C (Install)</title>
<authors>https://github.com/proDOOMman</authors>
<!-- projectUrl is required for the community feed -->
<authors>Stanislav Kosolapov</authors>
<projectUrl>https://github.com/proDOOMman/Coverage41C</projectUrl>
<!--<iconUrl>http://cdn.rawgit.com/__REPLACE_YOUR_REPO__/master/icons/coverage41c.png</iconUrl>-->
<!-- <copyright>Year Software Vendor</copyright> -->
<!-- If there is a license Url available, it is required for the community feed -->
<!-- <licenseUrl>Software License Location __REMOVE_OR_FILL_OUT__</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>-->
<!--<projectSourceUrl>Software Source Location - is the software FOSS somewhere? Link to it with this</projectSourceUrl>-->
<!--<docsUrl>At what url are the software docs located?</docsUrl>-->
<!--<mailingListUrl></mailingListUrl>-->
<!--<bugTrackerUrl></bugTrackerUrl>-->
<copyright>2020 proDOOMman</copyright>
<licenseUrl>https://raw.githubusercontent.com/proDOOMman/Coverage41C/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<docsUrl>https://42clouds.com/ru-ru/techdocs/raschyot-pokrytiya-koda-1C-testami.html</docsUrl>
<bugTrackerUrl>https://github.com/proDOOMman/Coverage41C/issues</bugTrackerUrl>
<tags>Coverage41C 1С Java</tags>
<summary>1с dbgs client</summary>
<description>1с dbgs client</description>
<summary>Coverage tool for 1C:Enterprise</summary>
<description>Coverage41C measure coverage in 1C:Enterprise applications and export them to genericCoverage.xml for SonarQube</description>
</metadata>
<files>
<!-- this section controls what actually gets packaged into the Chocolatey package -->
<file src="tools\**" target="tools" />
<!--Building from Linux? You may need this instead: <file src="tools/**" target="tools" />-->
</files>
</package>
9 changes: 0 additions & 9 deletions choco/tools/chocolateybeforemodify.ps1

This file was deleted.

4 changes: 4 additions & 0 deletions choco/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = "https://github.com/proDOOMman/Coverage41C/releases/download/v$($env:chocolateyPackageVersion)/$($env:ChocolateyPackageName)-$($env:chocolateyPackageVersion).zip"

$checksum = "0A3D91E605E99B6462DD1B67501BD4AE2A06F27371ADB245B38B8CAFD1E7DB34"

$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
url = $url
checksumType = "sha256"
checksum = $checksum
}

$covBin = Join-Path $toolsDir "\$($env:ChocolateyPackageName)-$($env:chocolateyPackageVersion)\bin"
Expand Down
70 changes: 13 additions & 57 deletions choco/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -1,66 +1,22 @@
# IMPORTANT: Before releasing this package, copy/paste the next 2 lines into PowerShell to remove all comments from this file:
# $f='c:\path\to\thisFile.ps1'
# gc $f | ? {$_ -notmatch "^\s*#"} | % {$_ -replace '(^.*?)\s*?[^``]#.*','$1'} | Out-File $f+".~" -en utf8; mv -fo $f+".~" $f
$ErrorActionPreference = 'Stop';

## NOTE: In 80-90% of the cases (95% with licensed versions due to Package Synchronizer and other enhancements),
## AutoUninstaller should be able to detect and handle registry uninstalls without a chocolateyUninstall.ps1.
## See https://chocolatey.org/docs/commands-uninstall
## and https://chocolatey.org/docs/helpers-uninstall-chocolatey-package

## If this is an MSI, ensure 'softwareName' is appropriate, then clean up comments and you are done.
## If this is an exe, change fileType, silentArgs, and validExitCodes

$ErrorActionPreference = 'Stop'; # stop on all errors
$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'coverage41c*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique
softwareName = 'coverage41c*'
}

$uninstalled = $false
# Get-UninstallRegistryKey is new to 0.9.10, if supporting 0.9.9.x and below,
# take a dependency on "chocolatey-core.extension" in your nuspec file.
# This is only a fuzzy search if $softwareName includes '*'. Otherwise it is
# exact. In the case of versions in key names, we recommend removing the version
# and using '*'.
[array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName']

if ($key.Count -eq 1) {
$key | % {
$packageArgs['file'] = "$($_.UninstallString)" #NOTE: You may need to split this if it contains spaces, see below

if ($packageArgs['fileType'] -eq 'MSI') {
# The Product Code GUID is all that should be passed for MSI, and very
# FIRST, because it comes directly after /x, which is already set in the
# Uninstall-ChocolateyPackage msiargs (facepalm).
$packageArgs['silentArgs'] = "$($_.PSChildName) $($packageArgs['silentArgs'])"

# Don't pass anything for file, it is ignored for msi (facepalm number 2)
# Alternatively if you need to pass a path to an msi, determine that and
# use it instead of the above in silentArgs, still very first
$packageArgs['file'] = ''
} else {
# NOTES:
# - You probably will need to sanitize $packageArgs['file'] as it comes from the registry and could be in a variety of fun but unusable formats
# - Split args from exe in $packageArgs['file'] and pass those args through $packageArgs['silentArgs'] or ignore them
# - Ensure you don't pass double quotes in $file (aka $packageArgs['file']) - otherwise you will get "Illegal characters in path when you attempt to run this"
# - Review the code for auto-uninstaller for all of the fun things it does in sanitizing - https://github.com/chocolatey/choco/blob/bfe351b7d10c798014efe4bfbb100b171db25099/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs#L142-L192
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$PathToRemove = Join-Path $toolsDir "\$($env:ChocolateyPackageName)-$($env:chocolateyPackageVersion)\bin"
foreach ($path in [Environment]::GetEnvironmentVariable("PATH","Machine").split(';'))
{
If ($Path)
{
If (($path -ine "$PathToRemove") -AND ($path -ine "$PathToRemove\"))
{
[string[]]$Newpath += "$path"
}

Uninstall-ChocolateyPackage @packageArgs
}
} elseif ($key.Count -eq 0) {
Write-Warning "$packageName has already been uninstalled by other means."
} elseif ($key.Count -gt 1) {
Write-Warning "$($key.Count) matches found!"
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
Write-Warning "Please alert package maintainer the following keys were matched:"
$key | % {Write-Warning "- $($_.DisplayName)"}
}
$AssembledNewPath = ($newpath -join(';')).trimend(';')

## OTHER POWERSHELL FUNCTIONS
## https://chocolatey.org/docs/helpers-reference
#Uninstall-ChocolateyZipPackage $packageName # Only necessary if you did not unpack to package directory - see https://chocolatey.org/docs/helpers-uninstall-chocolatey-zip-package
#Uninstall-ChocolateyEnvironmentVariable # 0.9.10+ - https://chocolatey.org/docs/helpers-uninstall-chocolatey-environment-variable
#Uninstall-BinFile # Only needed if you used Install-BinFile - see https://chocolatey.org/docs/helpers-uninstall-bin-file
## Remove any shortcuts you added in the install script.

[Environment]::SetEnvironmentVariable("PATH",$AssembledNewPath,"Machine")
17 changes: 17 additions & 0 deletions src/main/java/com/clouds42/CommandLineOptions/OutputOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@

public class OutputOptions {

public enum OutputFormat {
GENERIC_COVERAGE,
LCOV
}

private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

@Option(names = {"-o", "--out"}, description = "Output file name")
private File outputFile;

@Option(names = {"-f", "--format"}, description = "Output file format: ${COMPLETION-CANDIDATES}. Default - ${DEFAULT-VALUE}", defaultValue = "GENERIC_COVERAGE")
private OutputFormat outputFormat;

public OutputFormat getOutputFormat() {
return outputFormat;
}

public void setOutputFormat(OutputFormat outputFormat) {
this.outputFormat = outputFormat;
}

public File getOutputFile() {
return outputFile;
}
Expand All @@ -22,4 +38,5 @@ public void setOutputFile(File outputFile) {
this.outputFile = outputFile;
}


}
6 changes: 3 additions & 3 deletions src/main/java/com/clouds42/Commands/ConvertCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ConvertCommand implements Callable<Integer> {
@Override
public Integer call() throws Exception {

Map<URI, Map<BigDecimal, Boolean>> coverageData = new HashMap<URI,Map<BigDecimal, Boolean>>();
Map<URI, Map<BigDecimal, Integer>> coverageData = new HashMap<URI,Map<BigDecimal, Integer>>();

Map<String, URI> uriListByKey = Utils.readMetadata(metadataOptions, coverageData);

Expand All @@ -68,7 +68,7 @@ public Integer call() throws Exception {
logger.error("Can't find file key: " + fileKey);
continue;
}
Map<BigDecimal, Boolean> coverMap = coverageData.get(fileUri);
Map<BigDecimal, Integer> coverMap = coverageData.get(fileUri);
if (!coverMap.isEmpty()) {
NodeList lineNoNodeList = fileNode.getChildNodes();
for (int lineNoNodeNumber = 0; lineNoNodeNumber < lineNoNodeList.getLength(); lineNoNodeNumber++) {
Expand All @@ -92,7 +92,7 @@ public Integer call() throws Exception {
}
}
} else {
coverMap.put(lineNo, true);
coverMap.put(lineNo, 1);
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/clouds42/Commands/CoverageCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public class CoverageCommand implements Callable<Integer> {

private RuntimeDebugHttpClient client;

private Map<URI, Map<BigDecimal, Boolean>> coverageData = new HashMap<URI,Map<BigDecimal, Boolean>> () {
private Map<URI, Map<BigDecimal, Integer>> coverageData = new HashMap<URI,Map<BigDecimal, Integer>> () {
@Override
public Map<BigDecimal, Boolean> get(Object key) {
Map<BigDecimal, Boolean> map = super.get(key);
public Map<BigDecimal, Integer> get(Object key) {
Map<BigDecimal, Integer> map = super.get(key);
if (map == null) {
map = new HashMap<BigDecimal, Boolean>();
map = new HashMap<BigDecimal, Integer>();
put((URI)key, map);
}
return map;
Expand Down Expand Up @@ -113,9 +113,9 @@ private Boolean listenSocket(Socket clientSocket) {
out.println(PipeMessages.OK_RESULT);
return true;
} else if (PipeMessages.CLEAN_COMMAND.equals(line)) {
coverageData.forEach((uri, bigDecimalBooleanMap) -> {
for (var key : bigDecimalBooleanMap.keySet()) {
bigDecimalBooleanMap.put(key, false);
coverageData.forEach((uri, bigDecimalIntegerMap) -> {
for (var key : bigDecimalIntegerMap.keySet()) {
bigDecimalIntegerMap.put(key, 0);
}
});
out.println(PipeMessages.OK_RESULT);
Expand Down Expand Up @@ -261,7 +261,7 @@ public void run()
EList<PerformanceInfoLine> lineInfoList = moduleInfo.getLineInfo();
lineInfoList.forEach(lineInfo -> {
BigDecimal lineNo = lineInfo.getLineNo();
Map<BigDecimal, Boolean> coverMap = coverageData.get(uri);
Map<BigDecimal, Integer> coverMap = coverageData.get(uri);
if (!coverMap.isEmpty() || rawMode) {
if (!rawMode && !coverMap.containsKey(lineNo)) {
if (loggingOptions.isVerbose()) {
Expand All @@ -275,7 +275,9 @@ public void run()
}
}
} else {
coverMap.put(lineNo, true);
coverMap.put(lineNo,
coverMap.getOrDefault(lineNo, 0)
+ lineInfo.getFrequency().intValue());
}
}
});
Expand Down
Loading

0 comments on commit 7278f16

Please sign in to comment.