amie
Version:
Amalgamation Made Insanely Easy. A tool to easily amalgamate stuff!
90 lines (82 loc) • 3.63 kB
JavaScript
;
const path = require('path');
const amie = require('../../');
const should = require('should');
describe('Basic amalgamation with files in same directory', function() {
describe('Successes', function() {
describe('From real file', function() {
it('should properly amalgamate a basic include', function(done) {
amie({
input: path.join(__dirname, 'cpp', 'main.cpp')
}, (err, result) => {
should.not.exist(err);
should.exist(result);
result.should.be.a.String();
result.should.equal('// This is file from cpp\n\n\n// main.cpp\n');
done();
});
});
it('should work with no include', function(done) {
amie({
input: path.join(__dirname, 'cpp', 'main_noinc.cpp')
}, (err, result) => {
should.not.exist(err);
should.exist(result);
result.should.be.a.String();
result.should.equal('//main_noinc.cpp\n');
done();
});
});
it('should ignore system include', function(done) {
amie({
input: path.join(__dirname, 'cpp', 'main_sys.cpp')
}, (err, result) => {
should.not.exist(err);
should.exist(result);
result.should.be.a.String();
result.should.equal('#include <iostream>\n//main_sys.cpp\n');
done();
});
});
it('should properly amalgamate a deep include list', function(done) {
amie({
input: path.join(__dirname, 'cpp', 'maindeep.cpp')
}, (err, result) => {
should.not.exist(err);
should.exist(result);
result.should.be.a.String();
result.should.equal('// This is filedeep from cpp\n// This is file from cpp\n\n// This is file2 from cpp\n\n\n// This is filedeep2 from cpp\n// This is file from cpp\n\n// This is file2 from cpp\n\n// This is filedeep from cpp\n// This is file from cpp\n\n// This is file2 from cpp\n\n\n\n\n// This is maindeep.cpp\n');
done();
});
});
});
});
describe('Errors', function() {
describe('from real file', function() {
it('should error if include is not found', function(done) {
amie({
input: path.join(__dirname, 'cpp', 'main_err.cpp')
}, (err, result) => {
should.exist(err);
should.not.exist(result);
err.message.should.equal('Unable to find file \'fakefile.hh\'');
done();
});
});
});
describe('from string', function() {
it('cannot resolve includes from string if no includePath is specified', function(done) {
amie({
input: '#include "file.hh"\n#include "file.hh"',
fromString: true
}, (err, result) => {
should.exist(err);
should.not.exist(result);
err.message.should.be.a.String();
err.message.should.equal('Unable to find file \'file.hh\'');
done();
});
});
});
});
});