-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split regression extracter and runner (#1451)
A lot of new sources of regression tests may come and it's important to make debug simpler. Now regression-extract.js downloads and write svg files into test/regression-fixtures. regression.js run each svg in this folder. Mismatched svg diff is written into test/regression-diffs.
- Loading branch information
Showing
5 changed files
with
133 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
node_modules | ||
dist | ||
diffs | ||
test/regression-fixtures | ||
test/regression-diffs | ||
coverage | ||
bin/svgo-profiling | ||
.DS_Store | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const util = require('util'); | ||
const zlib = require('zlib'); | ||
const stream = require('stream'); | ||
const fetch = require('node-fetch'); | ||
const tarStream = require('tar-stream'); | ||
|
||
const pipeline = util.promisify(stream.pipeline); | ||
|
||
const extractTarGz = async (url, baseDir, include) => { | ||
const extract = tarStream.extract(); | ||
extract.on('entry', async (header, stream, next) => { | ||
try { | ||
if (include == null || include.test(header.name)) { | ||
if (header.name.endsWith('.svg')) { | ||
const file = path.join(baseDir, header.name); | ||
await fs.promises.mkdir(path.dirname(file), { recursive: true }); | ||
await pipeline(stream, fs.createWriteStream(file)); | ||
} | ||
if (header.name.endsWith('.svgz')) { | ||
// .svgz -> .svg | ||
const file = path.join(baseDir, header.name.slice(0, -1)); | ||
await fs.promises.mkdir(path.dirname(file), { recursive: true }); | ||
await pipeline( | ||
stream, | ||
zlib.createGunzip(), | ||
fs.createWriteStream(file) | ||
); | ||
} | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
stream.resume(); | ||
next(); | ||
}); | ||
const response = await fetch(url); | ||
await pipeline(response.body, extract); | ||
}; | ||
|
||
(async () => { | ||
try { | ||
console.info('Download W3C SVG 1.1 Test Suite and extract svg files'); | ||
await extractTarGz( | ||
'https://www.w3.org/Graphics/SVG/Test/20110816/archives/W3C_SVG_11_TestSuite.tar.gz', | ||
path.join(__dirname, 'regression-fixtures', 'w3c-svg-11-test-suite'), | ||
/^svg\// | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters