Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds test coverage reporting for@finos/perspective #920

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ docs/static/js/logo.js.map
python/perspective/pip-wheel-metadata
darwin.json
darwin.interactive.json
junit.xml
python/perspective/python_junit.xml
python/perspective/coverage.xml
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[![Build Status](https://dev.azure.com/finosfoundation/perspective/_apis/build/status/finos.perspective?branchName=master)](https://dev.azure.com/finosfoundation/perspective/_build/latest?definitionId=1&branchName=master)
[![npm](https://img.shields.io/npm/v/@finos/perspective.svg?style=flat-square)](https://www.npmjs.com/package/@finos/perspective)
[![PyPI](https://img.shields.io/pypi/v/perspective-python.svg)](https://pypi.python.org/pypi/perspective-python)
[![FINOS - Operating](https://cdn.rawgit.com/finos/contrib-toolbox/master/images/badge-operating.svg)](https://finosfoundation.atlassian.net/wiki/display/FINOS/Operating)


A streaming data visualization engine for Javascript, Perspective makes it
simple to build real-time & user configurable analytics entirely in the browser.
Expand Down
3 changes: 1 addition & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

jobs:
- job: 'LinuxJS'
- job: 'WebAssembly'
pool:
vmImage: 'ubuntu-16.04'

Expand Down Expand Up @@ -33,7 +33,6 @@ jobs:
testRunner: JUnit
testResultsFiles: 'junit.xml'


- job: 'Linux'
pool:
vmImage: 'ubuntu-16.04'
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@typescript-eslint/parser": "^2.4.0",
"arraybuffer-loader": "^1.0.2",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.5.0",
"babel-jest": "^25.1.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-transform-custom-element-classes": "^0.1.0",
"babel-polyfill": "^6.26.0",
Expand All @@ -56,7 +56,7 @@
"html-loader": "^0.5.1",
"html-loader-jest": "^0.2.1",
"inquirer": "^7.0.0",
"jest": "^24.5.0",
"jest": "^25.1.0",
"jest-junit": "^10.0.0",
"js-beautify": "^1.8.6",
"jsdoc": "3.5.5",
Expand All @@ -77,14 +77,15 @@
"source-map-explorer": "^2.0.1",
"style-loader": "^0.18.2",
"term-img": "^4.1.0",
"ts-jest": "^24.1.0",
"ts-jest": "^25.1.0",
"ts-loader": "^6.2.0",
"typescript": "^3.7.4",
"webpack": "^4.31.0",
"webpack-cli": "^3.3.2",
"webpack-fix-style-only-entries": "^0.4.0"
},
"resolutions": {
"**/jest": "^25.1.0",
"**/write-file-atomic": "2.4.1",
"**/webpack": "^4.31.0",
"**/webpack-cli": "^3.3.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/perspective-test/jest.all.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = {
".js$": "@finos/perspective-test/src/js/transform.js",
".html$": "html-loader-jest"
},
collectCoverage: true,
collectCoverageFrom: ["packages/perspective/dist/cjs/**"],
coverageProvider: "v8",
coverageReporters: ["cobertura", "text"],
transformIgnorePatterns: ["/node_modules/(?!lit-html).+$"],
automock: false,
setupFiles: ["@finos/perspective-test/src/js/beforeEachSpec.js"],
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"worker-loader": "^2.0.0"
},
"peerDependencies": {
"@finos/perspective": "0.4.0-rc.3",
"@finos/perspective": "^0.4.2",
"webpack": "^4.35"
}
}
2 changes: 1 addition & 1 deletion packages/perspective/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
safari: "12",
edge: "44"
},
modules: false,
modules: process.env.BABEL_MODULE || false,
useBuiltIns: "usage",
corejs: 3
}
Expand Down
11 changes: 5 additions & 6 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@finos/perspective",
"version": "0.4.2",
"description": "Perspective.js",
"main": "dist/umd/perspective.node.js",
"main": "dist/cjs/perspective.node.js",
"unpkg": "dist/umd/perspective.js",
"browser": "dist/umd/perspective.inline.js",
"module": "dist/umd/perspective.inline.js",
Expand All @@ -18,18 +18,17 @@
"scripts": {
"prebuild": "mkdirp dist && mkdirp obj",
"build": "npm-run-all build:babel:* build:webpack build:webpack:umd:inline",
"build:babel:js": "babel src/js --source-maps --out-dir dist/esm",
"build:babel:emsdk": "babel obj --source-maps --out-dir dist/esm",
"build:babel:esm": "babel src/js --source-maps --out-dir dist/esm",
"build:babel:emsdk": "BABEL_MODULE=auto babel dist/obj --source-maps --out-dir dist/cjs",
"build:babel:cjs": "BABEL_MODULE=auto babel dist/esm --source-maps --out-dir dist/cjs",
"build:webpack": "npm-run-all -p build:webpack:* ",
"build:webpack:umd:inline": "webpack --color --config src/config/perspective.inline.config.js",
"build:webpack:umd": "webpack --color --config src/config/perspective.config.js",
"build:webpack:node": "webpack --color --config src/config/perspective.node.config.js",
"docs": "npm-run-all docs:jsdoc docs:deploy",
"docs:jsdoc": "jsdoc2md src/js/perspective.js -p list --separators --no-gfm > README.md",
"docs:deploy": "(echo \"---\nid: perspective\ntitle: perspective API\n---\n\n\"; cat README.md) > ../../docs/obj/perspective.md",
"test:build": "cpx \"test/html/*\" build",
"test:run": "jest --color --ci",
"test": "npm-run-all test:build test:run",
"test": "npm-run-all test:run",
"clean": "rimraf dist"
},
"jest": {
Expand Down
11 changes: 4 additions & 7 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const {Client} = require("./api/client.js");
const {Server} = require("./api/server.js");

Expand All @@ -21,13 +22,9 @@ const path = require("path");
const load_perspective = require("./psp.async.js").default;

// eslint-disable-next-line no-undef
const RESOLVER = typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__.resolve : module.require.resolve;

const LOCAL_PATH = path.join(process.cwd(), "node_modules");

const wasm = require("./psp.async.wasm.js");

const buffer = fs.readFileSync(path.join(__dirname, wasm)).buffer;
const buffer = require("./psp.async.wasm.js").default;

const SYNC_SERVER = new (class extends Server {
init(msg) {
Expand Down Expand Up @@ -117,9 +114,9 @@ function create_http_server(assets, host_psp) {
if (host_psp || typeof host_psp === "undefined") {
for (let rootDir of DEFAULT_ASSETS) {
try {
let paths = RESOLVER.paths(rootDir + url);
let paths = require.resolve.paths(rootDir + url);
paths = [...paths, ...assets.map(x => path.join(x, "node_modules")), LOCAL_PATH];
let filePath = RESOLVER(rootDir + url, {paths});
let filePath = require.resolve(rootDir + url, {paths});
let content = await read_promise(filePath);
if (typeof content !== "undefined") {
console.log(`200 ${url}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective/src/js/perspective.wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

import load_perspective from "../../obj/psp.async.js";
import load_perspective from "../../dist/obj/psp.async.js";
import perspective from "./perspective.js";

let _perspective_instance;
Expand Down
15 changes: 13 additions & 2 deletions packages/perspective/src/js/psp.async.wasm.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
import wasm from "../../build/psp.async.wasm";
export default wasm;
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

import fs from "fs";
import path from "path";

export default fs.readFileSync(path.join(__dirname, "..", "umd", "psp.async.wasm")).buffer;
2 changes: 1 addition & 1 deletion packages/perspective/test/js/perspective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

const node_perspective = require("../../dist/umd/perspective.node.js");
const node_perspective = require("../../dist/cjs/perspective.node.js");

const RUNTIMES = {
NODE: node_perspective
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective/test/js/sync_load.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

describe("perspective.js module", function() {
it("does not access the WASM module until it is ready", async () => {
const tbl = require("../../dist/umd/perspective.node.js").table([{x: 1}]);
const tbl = require("../../dist/cjs/perspective.node.js").table([{x: 1}]);
const size = await tbl.size();
expect(size).toEqual(1);
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function compileRuntime({inputFile, inputWasmFile, format, packageName}) {
const OUTPUT_DIRECTORY = getOuputDir(packageName);
const BUILD_DIRECTORY = getBuildDir(packageName);

mkdirp.sync(path.join(OUTPUT_DIRECTORY, "obj"));
mkdirp.sync(path.join(OUTPUT_DIRECTORY, "dist", "obj"));
mkdirp.sync(path.join(OUTPUT_DIRECTORY, "dist", "umd"));

if (inputWasmFile) {
Expand All @@ -77,7 +77,7 @@ function compileRuntime({inputFile, inputWasmFile, format, packageName}) {
});
}

fs.writeFileSync(path.join(OUTPUT_DIRECTORY, "obj", inputFile), source);
fs.writeFileSync(path.join(OUTPUT_DIRECTORY, "dist", "obj", inputFile), source);
}

function docker(image = "emsdk") {
Expand Down
Loading