abi-gen should regenerate contract-wrappers if template files change (#1875)

This commit is contained in:
Xianny
2019-06-18 16:03:37 -07:00
committed by GitHub
parent 01a1b19556
commit 9775f8d83c
4 changed files with 36 additions and 16 deletions

View File

@@ -42,7 +42,7 @@ describe('writeOutputFile()', () => {
describe('isOutputFileUpToDate()', () => {
it('should throw ENOENT when there is no abi file', () => {
expect(utils.isOutputFileUpToDate.bind('nonexistant1', 'nonexistant2')).to.throw('ENOENT');
expect(utils.isOutputFileUpToDate.bind('', 'nonexistant1', ['nonexistant2'])).to.throw('ENOENT');
});
describe('when the abi input file exists', () => {
@@ -55,7 +55,7 @@ describe('isOutputFileUpToDate()', () => {
describe('without an existing output file', () => {
it('should return false', () => {
expect(utils.isOutputFileUpToDate(abiFile, 'nonexistant_file')).to.be.false();
expect(utils.isOutputFileUpToDate('nonexistant_file', [abiFile])).to.be.false();
});
});
@@ -71,7 +71,7 @@ describe('isOutputFileUpToDate()', () => {
});
it('should return true when output file is newer than abi file', async () => {
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.true();
expect(utils.isOutputFileUpToDate(outputFile, [abiFile])).to.be.true();
});
it('should return false when output file exists but is older than abi file', () => {
@@ -79,7 +79,19 @@ describe('isOutputFileUpToDate()', () => {
const abiFileModTimeMs = outFileModTimeMs + 1;
fs.utimesSync(abiFile, abiFileModTimeMs, abiFileModTimeMs);
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.false();
expect(utils.isOutputFileUpToDate(outputFile, [abiFile])).to.be.false();
});
it('should return false when any source file is newer than output file', () => {
const templateFile = tmp.fileSync(
{ discardDescriptor: true }, // close file (set timestamp)
).name;
const templateFileModTimeMs = fs.statSync(outputFile).mtimeMs + 1;
const abiFileModTimeMs = fs.statSync(outputFile).mtimeMs;
fs.utimesSync(templateFile, templateFileModTimeMs, templateFileModTimeMs);
fs.utimesSync(abiFile, abiFileModTimeMs, abiFileModTimeMs);
expect(utils.isOutputFileUpToDate(outputFile, [abiFile, templateFile])).to.be.false();
});
});
});