Skip to content
This repository was archived by the owner on Jun 14, 2018. It is now read-only.

Commit 6d9e041

Browse files
committed
test: re-use static build directory for caching between test runs, fixes ConsenSys-archive/truffle#343
1 parent 05577f1 commit 6d9e041

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/commands/test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var command = {
44
builder: {},
55
run: function (options, done) {
66
var OS = require("os");
7+
var path = require('path');
78
var dir = require("node-dir");
89
var temp = require("temp");
910
var Config = require("truffle-config");
@@ -43,12 +44,31 @@ var command = {
4344
dir.files(config.test_directory, callback);
4445
};
4546

47+
function getTestTempDir(cb) {
48+
var tempDir = path.join(config.working_directory, '.tmp');
49+
var testDir = path.join(tempDir, 'test');
50+
51+
try {
52+
if (!fs.existsSync(tempDir)) {
53+
fs.mkdirSync(tempDir);
54+
}
55+
56+
if (!fs.existsSync(testDir)) {
57+
fs.mkdirSync(testDir);
58+
}
59+
60+
cb(null, testDir);
61+
} catch (err) {
62+
cb(err);
63+
}
64+
}
65+
4666
getFiles(function(err, files) {
4767
files = files.filter(function(file) {
4868
return file.match(config.test_file_extension_regexp) != null;
4969
});
5070

51-
temp.mkdir('test-', function(err, temporaryDirectory) {
71+
getTestTempDir(function (err, temporaryDirectory) {
5272
if (err) return done(err);
5373

5474
function cleanup() {

0 commit comments

Comments
 (0)