From c13a8359d4cc3f4c8b551246c053920614b91c9d Mon Sep 17 00:00:00 2001 From: mvlabat Date: Tue, 20 Feb 2018 11:30:01 +0200 Subject: [PATCH] Fix Rust wasm-gc test --- test/rust.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/rust.js b/test/rust.js index d06b664f28a..a6c4dc7e183 100644 --- a/test/rust.js +++ b/test/rust.js @@ -102,12 +102,21 @@ describe('rust', function() { it('should use wasm-gc to minify output', async function() { this.timeout(500000); + + // Store the size of not minified bundle in order to test it against + // the size of minified one. let b = await bundle(__dirname + '/integration/rust/index.js', { + minify: false, + sourceMaps: false + }); + const size = fs.statSync(Array.from(b.childBundles)[0].name).size; + + let bMinified = await bundle(__dirname + '/integration/rust/index.js', { minify: true, sourceMaps: false }); - assertBundleTree(b, { + const bundleTree = { name: 'index.js', assets: [ 'bundle-loader.js', @@ -122,12 +131,16 @@ describe('rust', function() { childBundles: [] } ] - }); + }; - var res = await run(b); + assertBundleTree(b, bundleTree); + assertBundleTree(bMinified, bundleTree); + + var res = await run(bMinified); assert.equal(res, 5); - // assert that it is smaller - assert(fs.statSync(Array.from(b.childBundles)[0].name).size < 200); + const sizeMinified = fs.statSync(Array.from(bMinified.childBundles)[0].name) + .size; + assert(sizeMinified < size); }); });