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/fixtures/temp-*
|
||||
/test/temp
|
||||
/test/ChangesAndRemovals
|
||||
/benchmark/js
|
||||
/benchmark/fixtures
|
||||
/examples/**/dist
|
||||
|
|
|
@ -12,7 +12,7 @@ const createCompiler = config => {
|
|||
return compiler;
|
||||
};
|
||||
|
||||
const tempFolderPath = path.join(__dirname, "temp");
|
||||
const tempFolderPath = path.join(__dirname, "ChangesAndRemovalsTemp");
|
||||
const tempFilePath = path.join(tempFolderPath, "temp-file.js");
|
||||
const tempFile2Path = path.join(tempFolderPath, "temp-file2.js");
|
||||
|
||||
|
@ -49,27 +49,19 @@ function cleanup(callback) {
|
|||
}
|
||||
|
||||
function createFiles() {
|
||||
// Set file timestamps to 5 seconds earlier,
|
||||
// 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.mkdirSync(tempFolderPath, { recursive: true });
|
||||
|
||||
fs.writeFileSync(
|
||||
tempFilePath,
|
||||
"module.exports = function temp() {return 'temp file';};\n require('./temp-file2')",
|
||||
"utf-8"
|
||||
);
|
||||
fs.utimesSync(tempFilePath, fakeTime, fakeTime);
|
||||
|
||||
fs.writeFileSync(
|
||||
tempFile2Path,
|
||||
"module.exports = function temp2() {return 'temp file 2';};",
|
||||
"utf-8"
|
||||
);
|
||||
fs.utimesSync(tempFile2Path, fakeTime, fakeTime);
|
||||
}
|
||||
|
||||
describe("ChangesAndRemovals", () => {
|
||||
|
@ -84,7 +76,9 @@ describe("ChangesAndRemovals", () => {
|
|||
cleanup(err => {
|
||||
if (err) return done(err);
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue