mirror of https://github.com/webpack/webpack.git
use separate directory for test
wait a bit after creating files
This commit is contained in:
parent
b7bdd38bb6
commit
bc9da61390
|
@ -3,6 +3,7 @@
|
||||||
/test/browsertest/js
|
/test/browsertest/js
|
||||||
/test/fixtures/temp-*
|
/test/fixtures/temp-*
|
||||||
/test/temp
|
/test/temp
|
||||||
|
/test/ChangesAndRemovals
|
||||||
/benchmark/js
|
/benchmark/js
|
||||||
/benchmark/fixtures
|
/benchmark/fixtures
|
||||||
/examples/**/dist
|
/examples/**/dist
|
||||||
|
|
|
@ -12,7 +12,7 @@ const createCompiler = config => {
|
||||||
return compiler;
|
return compiler;
|
||||||
};
|
};
|
||||||
|
|
||||||
const tempFolderPath = path.join(__dirname, "temp");
|
const tempFolderPath = path.join(__dirname, "ChangesAndRemovalsTemp");
|
||||||
const tempFilePath = path.join(tempFolderPath, "temp-file.js");
|
const tempFilePath = path.join(tempFolderPath, "temp-file.js");
|
||||||
const tempFile2Path = path.join(tempFolderPath, "temp-file2.js");
|
const tempFile2Path = path.join(tempFolderPath, "temp-file2.js");
|
||||||
|
|
||||||
|
@ -49,27 +49,19 @@ function cleanup(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFiles() {
|
function createFiles() {
|
||||||
// Set file timestamps to 5 seconds earlier,
|
fs.mkdirSync(tempFolderPath, { recursive: true });
|
||||||
// otherwise the newly-created files will trigger the webpack watch mode to re-compile.
|
|
||||||
let fakeTime = new Date(Date.now() - 5000);
|
|
||||||
|
|
||||||
fs.mkdirSync(tempFolderPath);
|
|
||||||
fs.utimesSync(tempFolderPath, fakeTime, fakeTime);
|
|
||||||
fs.utimesSync(path.dirname(tempFolderPath), fakeTime, fakeTime);
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
tempFilePath,
|
tempFilePath,
|
||||||
"module.exports = function temp() {return 'temp file';};\n require('./temp-file2')",
|
"module.exports = function temp() {return 'temp file';};\n require('./temp-file2')",
|
||||||
"utf-8"
|
"utf-8"
|
||||||
);
|
);
|
||||||
fs.utimesSync(tempFilePath, fakeTime, fakeTime);
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
tempFile2Path,
|
tempFile2Path,
|
||||||
"module.exports = function temp2() {return 'temp file 2';};",
|
"module.exports = function temp2() {return 'temp file 2';};",
|
||||||
"utf-8"
|
"utf-8"
|
||||||
);
|
);
|
||||||
fs.utimesSync(tempFile2Path, fakeTime, fakeTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("ChangesAndRemovals", () => {
|
describe("ChangesAndRemovals", () => {
|
||||||
|
@ -84,7 +76,9 @@ describe("ChangesAndRemovals", () => {
|
||||||
cleanup(err => {
|
cleanup(err => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
createFiles();
|
createFiles();
|
||||||
done();
|
// Wait 2.5s after creating the files,
|
||||||
|
// otherwise the newly-created files will trigger the webpack watch mode to re-compile.
|
||||||
|
setTimeout(done, 2500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
afterEach(cleanup);
|
afterEach(cleanup);
|
||||||
|
|
Loading…
Reference in New Issue