Skip to content

Commit

Permalink
tests; increase output
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 21, 2022
1 parent ad6097f commit 7c5a260
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@ function finish (filename) {
console.error('\n\nError occured with file: ' + filename);
throw err;
}
}
}

function isGraphicsMagickInstalled() {
try {
cp.execSync('gm -version');
return true;
} catch (_) {
return false;
}
}

process.stdout.write('\033[2K');
process.stdout.write('\033[0G');
process.stdout.write('pending ' + (q.length()+q.running()));
function isConvertInstalled() {
try {
cp.execSync('convert -version');
return true;
} catch (_) {
return false;
}
}

Expand All @@ -56,42 +70,44 @@ function isMagickInstalled() {
}
}

process.stdout.write('\033[?25l');

var q = Async.queue(function (task, callback) {
var filename = task.filename;
var im = task.imagemagick;

console.log(`Testing ${filename} ..`);
require(filename)(test(im), dir, function (err) {
finish(filename)(err);
callback();
}, gm, im);
}, 1);

q.drain = function(){
process.stdout.write('\033[?25h');
process.stdout.write('\033[2K');
process.stdout.write('\033[0G');
console.error("\n\u001B[32mAll tests passed\u001B[0m");
console.log("\n\u001B[32mAll tests passed\u001B[0m");
};

files = files.map(function (file) {
return path.join(__dirname, file);
});

files.forEach(function (filename) {
q.push({
imagemagick: false,
filename
})
});
if (isGraphicsMagickInstalled()) {
console.log('gm is installed');
files.forEach(function (filename) {
q.push({
imagemagick: false,
filename
})
});
}

files.forEach(function (filename) {
q.push({
imagemagick: true,
filename
})
});
if (isConvertInstalled()) {
console.log('convert is installed');
files.forEach(function (filename) {
q.push({
imagemagick: true,
filename
})
});
}

if (isMagickInstalled()) {
console.log('magick is installed');
Expand Down

0 comments on commit 7c5a260

Please sign in to comment.