Skip to content

Commit

Permalink
Merge pull request o2r-project#1 from o2r-project/master
Browse files Browse the repository at this point in the history
integrate changes from origin
  • Loading branch information
tomniers authored Dec 10, 2019
2 parents 04101bd + e351dac commit 42b0c21
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 131 deletions.
15 changes: 14 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
---
language: node_js

os:
- linux
- osx
- windows

node_js:
- "8"
- "12"

cache:
directories:
- "node_modules"

env:
- DEBUG=*

install:
- npm install

script:
- DEBUG=* npm test
- npm run-script testci
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# erc-checker

![Travis CI](https://travis-ci.org/Timmimim/erc-checker.svg?branch=master) [![npm](https://img.shields.io/npm/v/erc-checker.svg)](https://www.npmjs.com/package/erc-checker)
[![Build Status](https://travis-ci.org/o2r-project/erc-checker.svg?branch=master)](https://travis-ci.org/o2r-project/erc-checker) [![Build status](https://ci.appveyor.com/api/projects/status/xbla7j4wpbwauk7p/branch/master?svg=true)](https://ci.appveyor.com/project/nuest/erc-checker-r035a/branch/master) [![npm](https://img.shields.io/npm/v/erc-checker.svg)](https://www.npmjs.com/package/erc-checker)

- [NodeJS module usage](#nodejs-module-usage)
- [Installation](#installation)
Expand Down
27 changes: 15 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
image:
# - Visual Studio 2019
- Ubuntu
- macOS
- Visual Studio 2019
# - Ubuntu
# - macOS

# branches to build
branches:
# whitelist
only:
- master

environment:
nodejs_version: "13"
environment:
matrix:
- nodejs_version: "12" # lts
DEBUG: "*"

install:
- npm install -g npm@latest
platform:
- x64 # dependency 'sharp' is not available for x86

- npm install sharp@latest --save
- npm install
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install -g npm@latest
- npm install sharp@latest --save
- npm install

test_script:
- npm test
- npm run-script testci

build: off
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 26 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"start": "DEBUG='index:*,checker:general,checker:ERROR' node index.js",
"debug": "DEBUG=* node index.js",
"test": "DEBUG=*,-eslint:* mocha test"
"test": "DEBUG='*,-eslint:*' mocha test",
"testci": "mocha test"
},
"repository": {
"type": "git",
Expand All @@ -15,16 +16,33 @@
"keywords": [
"cli",
"erc",
"executable research compendium",
"o2r",
"o2r-project",
"opening reproducible research",
"ifgi",
"ifgi-muenster",
"validating",
"compare",
"html"
"comparison",
"reproducibility",
"reproducible research"
],
"author": {
"name": "o2r project",
"url": "https://o2r.info",
"email": "[email protected]"
},
"contributors": [
{
"name": "Timm Kühnel",
"url": "https://github.com/Timmimim"
},
{
"name": "Tom Niers",
"url": "https://github.com/tnier01"
},
{
"name": "Daniel Nüst",
"url": "https://github.com/nuest"
}
],
"author": "Timm Kühnel",
"license": "Apache-2.0",
"bin": {
"erc-checker": "./index.js"
Expand All @@ -39,7 +57,7 @@
"colors": "^1.4.0",
"commander": "^4.0.1",
"debug": "^4.1.1",
"deglob": "^4.0.1",
"deglob": "o2r-project/deglob#master",
"image-size": "^0.8.3",
"leven": "^3.1.0",
"levenshtein": "^1.0.5",
Expand Down
12 changes: 6 additions & 6 deletions test/indexDiscriminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('Testing erc-checker', function () {
assert.isNotEmpty(rejectMetadata.errors);
assert.include(JSON.stringify(rejectMetadata.errors), "wrong path here");
assert.include(JSON.stringify(rejectMetadata.errors), "no such file");
assert.include(JSON.stringify(rejectMetadata.errors), config.pathToOriginalHTML);
assert.include(JSON.stringify(rejectMetadata.errors), "nothing.html");
});
});
}).timeout(10000);

it('called with only one invalid path should return metadata containing an Error', function () {
let config = Object.assign({}, checkConfig);
Expand All @@ -66,10 +66,10 @@ describe('Testing erc-checker', function () {
}, function (rejectMetadata) {
assert.isNotEmpty(rejectMetadata.errors);
assert.include(JSON.stringify(rejectMetadata.errors), "wrong path here");
assert.include(JSON.stringify(rejectMetadata.errors), config.pathToReproducedHTML);
assert.notInclude(JSON.stringify(rejectMetadata.errors), config.pathToOriginalHTML);
assert.include(JSON.stringify(rejectMetadata.errors), "nothing.html");
assert.notInclude(JSON.stringify(rejectMetadata.errors), "testPaper_1_shortened_a.html");
});
});
}).timeout(10000);

it('called with equal papers should return Promise state *resolved* with metadata containing no Errors, but also value 0 for differences', function () {
let config = Object.assign({}, checkConfig);
Expand All @@ -83,6 +83,6 @@ describe('Testing erc-checker', function () {
}, function (reject) {
assert.ifError(reject);
});
});
}).timeout(10000);
})
});
178 changes: 78 additions & 100 deletions test/testModuleUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Using ERC-Checker as node-module', function () {
assert.ifError(reason);
}
);
}).timeout(10000);
}).timeout(30000);
});
});

Expand Down Expand Up @@ -389,122 +389,100 @@ describe('Using ERC-Checker as node-module', function () {
}).timeout(10000);
});

describe("Running the erc-checker in an environment with a `.ercignore` file and/or with acceptable file endings specified in `config` object", function () {

describe("the checker should create a ComparisonSet list of files to be checked, which", function () {
it("should only contain files, which have the required file ending", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "test/test_ercignore";
configTestIgnore.checkFileTypes = ['html', 'htm', 'mp3'];

return checker(configTestIgnore)
.then(function (resultMetadata) {

let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
let endingHTM = (filePath.substr(filePath.length - 4, 4)) == ".htm";
let endingHTML = (filePath.substr(filePath.length - 5, 5)) == ".html";
let endingMP3 = (filePath.substr(filePath.length - 4, 4)) == ".mp3";
describe("Running the erc-checker in an environment with a `.ercignore` file and/or with acceptable file endings specified in `config` object, the ComparisonSet", function () {

it("should only contain files, which have the required file ending", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "test/test_ercignore";
configTestIgnore.checkFileTypes = ['html', 'htm', 'mp3'];

if (!endingHTM && !endingHTML && !endingMP3) {
allFilesCorrect = false;
}
});
return checker(configTestIgnore)
.then(function (resultMetadata) {

assert.strictEqual(allFilesCorrect, true, "ComparisonSet contains files which do not match the required file endings: \n" + resultMetadata.comparisonSet);
assert.strictEqual(resultMetadata.comparisonSet.length, 7, "ComparisonSet should include 7 file paths, but it contained " + resultMetadata.comparisonSet.length);
assert.strictEqual(resultMetadata.errors.length, 0, "Check should not have produced Errors, yet it did: " + resultMetadata.errors);
}, function (reason) {
return Promise.reject(reason);
let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
assert.match(filePath, /(htm|html|mp3)/, "file path does include wanted file ending");
assert.notMatch(filePath, /(txt|png)/, "file path does not include unwanted file ending");
});
}).timeout(10000);

it("should by default only contain files having a \".htm\" or \".html\" ending.", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "./test/test_ercignore";
delete configTestIgnore.checkFileTypes;
assert.strictEqual(resultMetadata.comparisonSet.length, 6);
}, function (reason) {
return Promise.reject(reason);
});
});

return checker(configTestIgnore)
.then(function (resultMetadata) {
it("should not return any errors", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "test/test_ercignore";
configTestIgnore.checkFileTypes = ['html', 'htm', 'mp3'];

return checker(configTestIgnore)
.then(function (resultMetadata) {
assert.strictEqual(resultMetadata.errors.length, 0);
}, function (reason) {
return Promise.reject(reason);
});
});

let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
let endingHTM = (filePath.substr(filePath.length - 4, 4)) == ".htm";
let endingHTML = (filePath.substr(filePath.length - 5, 5)) == ".html";
it("should by default only contain files having a '.htm' or '.html' ending.", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "./test/test_ercignore";
delete configTestIgnore.checkFileTypes;

if (!endingHTM && !endingHTML) {
allFilesCorrect = false;
}
});
assert.strictEqual(allFilesCorrect, true, "ComparisonSet contains files which do not match the required file endings: \n" + resultMetadata.comparisonSet);

assert.strictEqual(resultMetadata.comparisonSet.length, 6, "ComparisonSet should include 6 file paths, but it contained " + resultMetadata.comparisonSet.length);
return checker(configTestIgnore)
.then(function (resultMetadata) {

assert.strictEqual(resultMetadata.errors.length, 0, "Check should not have produced Errors, yet it did: " + resultMetadata.errors);
let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
assert.match(filePath, /(htm|html)/, "file path does include wanted file ending");
assert.notMatch(filePath, /(txt|png|mp3)/, "file path does not include unwanted file ending");
});
});

it("should only contain files which are not ignored by `.ercignore`", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "./test/test_ercignore";
configTestIgnore.checkFileTypes = [".*"];

return checker(configTestIgnore)
.then(function (resultMetadata) {
assert.strictEqual(resultMetadata.comparisonSet.length, 5);
});
});

let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
let containsFilteredDirectory = (filePath.includes("false_positive_dir/"));
let endingPNG = (filePath.substr(filePath.length - 4, 4)) == ".png";
it("should only contain files which are not ignored by `.ercignore`", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "test/test_ercignore";
configTestIgnore.checkFileTypes = [".*"];

if (containsFilteredDirectory || endingPNG) {
allFilesCorrect = false;
}
});
assert.strictEqual(allFilesCorrect, true, "ComparisonSet contains files which do not match the required file endings: \n" + resultMetadata.comparisonSet);
console.log(resultMetadata.comparisonSet);
assert.strictEqual(resultMetadata.comparisonSet.length, 8, "ComparisonSet should include 8 file paths, but it contained " + resultMetadata.comparisonSet.length);
return checker(configTestIgnore)
.then(function (resultMetadata) {

assert.strictEqual(resultMetadata.errors.length, 0, "Check should not have produced Errors, yet it did: " + resultMetadata.errors);
let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
assert.notInclude(filePath, "false_positive_dir", "file path does not contain ignored directory");
assert.notInclude(filePath, "png", "comparison set file is not a png");
});
});

it("should only contain files, which have the required file ending, and are not filtered by the `.ercignore` file.", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "./test/test_ercignore";
configTestIgnore.checkFileTypes = ["html", "htm"];

return checker(configTestIgnore)
.then(function (resultMetadata) {
let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
let containsFilteredDirectory = (filePath.includes("false_positive_dir/"));
let endingPNG = (filePath.substr(filePath.length - 4, 4)) == ".png";
});
});

let endingHTM = (filePath.substr(filePath.length - 4, 4)) == ".htm";
let endingHTML = (filePath.substr(filePath.length - 5, 5)) == ".html";
it("should not contain files which are not in check files types, nor files from `.ercignore`.", function () {
let configTestIgnore = Object.assign({}, checkConfig);
configTestIgnore.pathToOriginalHTML = "test_ignore8.htm";
configTestIgnore.pathToReproducedHTML = "test_ignore10.html";
configTestIgnore.comparisonSetBaseDir = "./test/test_ercignore";
configTestIgnore.checkFileTypes = ["html", "htm"];

if (containsFilteredDirectory || endingPNG) {
allFilesCorrect = false;
}
if (!endingHTM && !endingHTML) {
allFilesCorrect = false;
}
});

assert.strictEqual(allFilesCorrect, true, "ComparisonSet contains files which do not match the required file endings: \n" + resultMetadata.comparisonSet);
assert.strictEqual(resultMetadata.comparisonSet.length, 6, "ComparisonSet should include 6 file paths, but it contained " + resultMetadata.comparisonSet.length);
assert.strictEqual(resultMetadata.errors.length, 0, "Check should not have produced Errors, yet it did: " + resultMetadata.errors);
return checker(configTestIgnore)
.then(function (resultMetadata) {
let allFilesCorrect = true;
resultMetadata.comparisonSet.forEach(filePath => {
assert.notInclude(filePath, "false_positive_dir", "file path does not contain ignored directory");
assert.notInclude(filePath, "png", "comparison set file is not a png");
assert.notInclude(filePath, "mp3", "comparison set file is not a png");
assert.notInclude(filePath, "txt", "comparison set file is not a png");
});
});
});
});
});

Expand Down
Empty file.

0 comments on commit 42b0c21

Please sign in to comment.