Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@diffblue/java-combiner

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diffblue/java-combiner - npm Package Compare versions

Comparing version 0.1.2-rc1 to 0.1.2

build/utils.d.ts

9

build/combineTests.d.ts

@@ -0,1 +1,2 @@

import { ILooseTestData } from './test';
/**

@@ -48,9 +49,3 @@ * Convert fully qualified class name to a simple one

existingImports?: string[];
tests: Array<{
imports: string[];
staticImports: string[];
test?: string;
testBody?: string;
body?: string;
}>;
tests: ILooseTestData[];
}): Readonly<{

@@ -57,0 +52,0 @@ imports: string[];

@@ -9,2 +9,3 @@ "use strict";

const parse_1 = require("./parse");
const utils_1 = require("./utils");
/**

@@ -79,2 +80,3 @@ * Convert fully qualified class name to a simple one

const tests = options.tests;
const standardisedTests = utils_1.standardiseTests(tests);
const existingImports = options.existingImports || [];

@@ -85,3 +87,3 @@ const reservedShortNames = new Set(existingImports.map(simpleClassName));

const testMethods = [];
for (const test of tests) {
for (const test of standardisedTests) {
if (test.imports) {

@@ -98,3 +100,3 @@ imports = [...imports, ...resolveImports(reservedShortNames, test.imports)];

imports: [...existingImports, ...imports, ...staticImports],
body: test.test || test.testBody || test.body || '',
body: test.body,
}));

@@ -101,0 +103,0 @@ }

import { IClangStyle } from './clangFormat';
import { ITestData } from './test';
import { ILooseTestData } from './test';
/**

@@ -39,2 +39,2 @@ * Remove number from function name, separating it from it's base name, e.g.

*/
export declare function mergeTests(fileContents: string, tests: ITestData[], clangStyle?: IClangStyle): Promise<string>;
export declare function mergeTests(fileContents: string, tests: ILooseTestData[], clangStyle?: IClangStyle): Promise<string>;

@@ -7,2 +7,3 @@ "use strict";

const parse_1 = require("./parse");
const utils_1 = require("./utils");
// tslint:disable:no-magic-numbers

@@ -231,4 +232,5 @@ /**

const { splitCode, functionLocations, importLocations, classAnnotationLocations, pkgLocation, classLocation, } = splitExistingCode(fileContents);
const { importsToAdd, staticImportsToAdd } = await insertTests(splitCode, functionLocations, importLocations, tests, clangStyle);
insertAnnotations(splitCode, tests, classAnnotationLocations, classLocation);
const standardisedTests = utils_1.standardiseTests(tests);
const { importsToAdd, staticImportsToAdd } = await insertTests(splitCode, functionLocations, importLocations, standardisedTests, clangStyle);
insertAnnotations(splitCode, standardisedTests, classAnnotationLocations, classLocation);
insertImports(splitCode, pkgLocation, importLocations, importsToAdd, staticImportsToAdd);

@@ -261,7 +263,7 @@ return splitCode.join('');

// to ensure insertion positions are not modified by previous insertions
tests.sort((a, b) => (a.name || a.testName || '') > (b.name || b.testName || '') ? -1 : 1);
tests.sort((a, b) => a.name > b.name ? -1 : 1);
/** Position of funcion we want to insert before, start after last function */
let currFunc = functionLocations.length;
for (const test of tests) {
const [testName] = getPrefixAndNumber(test.name || test.testName || '');
const [testName] = getPrefixAndNumber(test.name);
const last = funcPrefixes.get(testName);

@@ -278,5 +280,5 @@ const newName = testName + (last ? String(last + 1) : '');

imports: [...importLocations.map((i) => i[0]), ...importsToAdd, ...staticImportsToAdd],
body: test.test || test.testBody || test.body || '',
body: test.body,
})
.replace(test.name || test.testName || '', newName);
.replace(test.name, newName);
if (clangStyle) {

@@ -283,0 +285,0 @@ // Prefix with '{' and remove after so that clang-format gets indentation right

@@ -1,3 +0,3 @@

/** Data required to generate a test */
export interface ITestData {
/** Generated test data from test-gen, supporting legacy field names */
export interface ILooseTestData {
classAnnotations: string[];

@@ -13,1 +13,10 @@ imports: string[];

}
/** Generated test data from test-gen, with strict field names */
export interface ITestData {
classAnnotations: string[];
imports: string[];
id?: string;
name: string;
staticImports: string[];
body: string;
}

@@ -1,2 +0,2 @@

import { ITestData } from './test';
import { ILooseTestData, ITestData } from './test';
/**

@@ -22,2 +22,2 @@ * Create an import string

*/
export declare function genTestClass(tests: ITestData[], className: string, testedClasses: string, packageName: string): string;
export declare function genTestClass(tests: ILooseTestData[], className: string, testedClasses: string, packageName: string): string;

@@ -5,2 +5,3 @@ "use strict";

const combineTests_1 = require("./combineTests");
const utils_1 = require("./utils");
const LEGACY_IMPORTS = `import org.junit.Assert;

@@ -57,8 +58,7 @@ import org.junit.rules.ExpectedException;

for (const test of tests) {
const testName = test.name || test.testName;
const testName = test.name;
const numberTestOccurances = testNames.get(testName) || 0;
testNames.set(testName, numberTestOccurances + 1);
const newTestName = numberTestOccurances > 0 ? `${testName}${numberTestOccurances}` : testName;
let body = test.body || test.test;
body = body.replace(test.id, newTestName);
test.body = test.body.replace(test.id, newTestName);
dedupedTests.push(test);

@@ -84,3 +84,4 @@ }

const classAnnotations = new Set([].concat(...tests.map((test) => test.classAnnotations)));
const uniqueTests = tests[0].id ? deduplicateTestNames(tests) : tests;
const standardisedTests = utils_1.standardiseTests(tests);
const uniqueTests = standardisedTests[0].id ? deduplicateTestNames(standardisedTests) : standardisedTests;
const combinedTests = combineTests_1.combineTests({ tests: uniqueTests, existingImports: [] });

@@ -87,0 +88,0 @@ const testImports = combinedTests.imports;

@@ -0,1 +1,7 @@

0.1.2 (2019-06-17)
==================
* Added config to allow running unit test in a debugger
* Accept tests with properties called `name` or `testName` for the test name and called `body`, `testBody` or `test` for the test body.
0.1.1 (2019-06-06)

@@ -2,0 +8,0 @@ ==================

{
"name": "@diffblue/java-combiner",
"description": "Java test combining library",
"version": "0.1.2-rc1",
"version": "0.1.2",
"main": "build/index.js",

@@ -24,3 +24,4 @@ "types": "build/index.d.ts",

"lint": "tslint --project tsconfig.json",
"test": "mocha"
"test": "mocha",
"test-debug": "mocha --inspect-brk=0.0.0.0:9229"
},

@@ -27,0 +28,0 @@ "nyc": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc