From dac396130043360bc190be16ab2a7e8f8cd55b56 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Wed, 13 Apr 2022 23:34:27 -0700 Subject: [PATCH 1/3] Don't set BCD to false if BCD has version number greater than our data --- update-bcd.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/update-bcd.js b/update-bcd.js index a616940ac..fadd8044b 100644 --- a/update-bcd.js +++ b/update-bcd.js @@ -316,6 +316,29 @@ const update = (bcd, supportMatrix, filter) => { continue; } + if ( + inferredStatement.version_added === false && + typeof simpleStatement.version_added === 'string' + ) { + // Make sure not to update BCD if it is set to a version newer than we have in our data + + for (const [version, result] of Array.from( + versionMap.entries() + ).reverse()) { + if ( + result !== null && + compareVersions.compare( + version, + simpleStatement.version_added.replace('≤', ''), + '<=' + ) + ) { + // A version we have data for is the same or newer than the version in BCD + return false; + } + } + } + if ( typeof simpleStatement.version_added === 'string' && typeof inferredStatement.version_added === 'string' && From 34a3648de190977b9f6777390852175e59b33806 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Wed, 13 Apr 2022 23:41:28 -0700 Subject: [PATCH 2/3] Add unittest --- unittest/unit/bcd.test.js | 3 +++ unittest/unit/find-missing-features.js | 13 ++++++--- unittest/unit/update-bcd.js | 37 ++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/unittest/unit/bcd.test.js b/unittest/unit/bcd.test.js index 71705add7..9426f484a 100644 --- a/unittest/unit/bcd.test.js +++ b/unittest/unit/bcd.test.js @@ -76,6 +76,9 @@ export default { }, RemovedInterface: { __compat: {support: {chrome: {version_added: null}}} + }, + SuperNewInterface: { + __compat: {support: {chrome: {version_added: '100'}}} } }, browsers: { diff --git a/unittest/unit/find-missing-features.js b/unittest/unit/find-missing-features.js index e02b17692..80f58fea1 100644 --- a/unittest/unit/find-missing-features.js +++ b/unittest/unit/find-missing-features.js @@ -40,6 +40,7 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-family', 'css.properties.font-face', 'javascript.builtins.Array', @@ -64,6 +65,7 @@ describe('find-missing-features', () => { 'api.TryingOutInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-family', 'css.properties.font-face', 'javascript.builtins.Array', @@ -91,10 +93,11 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-face', 'javascript.builtins.Date' ], - total: 17 + total: 18 }); }); @@ -118,9 +121,10 @@ describe('find-missing-features', () => { 'api.DummyAPI.dummy', 'api.ExperimentalInterface', 'api.NullAPI', - 'api.RemovedInterface' + 'api.RemovedInterface', + 'api.SuperNewInterface' ], - total: 13 + total: 14 }); }); @@ -138,10 +142,11 @@ describe('find-missing-features', () => { 'api.ExperimentalInterface', 'api.NullAPI', 'api.RemovedInterface', + 'api.SuperNewInterface', 'css.properties.font-face', 'javascript.builtins.Date' ], - total: 17 + total: 18 }); assert.isTrue( diff --git a/unittest/unit/update-bcd.js b/unittest/unit/update-bcd.js index 7b8121df9..f678326d7 100644 --- a/unittest/unit/update-bcd.js +++ b/unittest/unit/update-bcd.js @@ -83,6 +83,11 @@ const reports = [ info: {exposure: 'Window'}, result: true }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -158,6 +163,11 @@ const reports = [ info: {exposure: 'Window'}, result: false }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -227,6 +237,11 @@ const reports = [ info: {exposure: 'Window'}, result: true }, + { + name: 'api.SuperNewInterface', + info: {exposure: 'Window'}, + result: false + }, { name: 'css.properties.font-family', info: {exposure: 'Window'}, @@ -331,6 +346,7 @@ describe('BCD updater', () => { ['api.ExperimentalInterface', true], ['api.NullAPI', null], ['api.RemovedInterface', true], + ['api.SuperNewInterface', false], ['css.properties.font-family', true], ['css.properties.font-face', true] ]) @@ -351,6 +367,7 @@ describe('BCD updater', () => { ['api.NewInterfaceNotInBCD', false], ['api.NullAPI', null], ['api.RemovedInterface', false], + ['api.SuperNewInterface', false], ['css.properties.font-family', true], ['css.properties.font-face', true] ]) @@ -521,6 +538,20 @@ describe('BCD updater', () => { ] ]) ], + [ + 'api.SuperNewInterface', + new Map([ + [ + 'chrome', + new Map([ + ['82', null], + ['83', false], + ['84', false], + ['85', false] + ]) + ] + ]) + ], [ 'css.properties.font-family', new Map([ @@ -596,6 +627,9 @@ describe('BCD updater', () => { {version_added: '85'} ] }, + 'api.SuperNewInterface': { + chrome: [{version_added: false}] + }, 'css.properties.font-family': {chrome: [{version_added: '84'}]}, 'css.properties.font-face': {chrome: []} }; @@ -739,6 +773,9 @@ describe('BCD updater', () => { // {version_added: '≤83', version_removed: '84'} // ]}} __compat: {support: {chrome: {version_added: null}}} + }, + SuperNewInterface: { + __compat: {support: {chrome: {version_added: '100'}}} } }, browsers: { From 7aaed15456596ebff55ce153581e585539342393 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 14 Apr 2022 00:16:15 -0700 Subject: [PATCH 3/3] Use a variable rather than return (fix bug where updates just stop) --- update-bcd.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/update-bcd.js b/update-bcd.js index fadd8044b..14d80ae4e 100644 --- a/update-bcd.js +++ b/update-bcd.js @@ -316,6 +316,7 @@ const update = (bcd, supportMatrix, filter) => { continue; } + let dataIsOlder = false; if ( inferredStatement.version_added === false && typeof simpleStatement.version_added === 'string' @@ -334,12 +335,15 @@ const update = (bcd, supportMatrix, filter) => { ) ) { // A version we have data for is the same or newer than the version in BCD - return false; + dataIsOlder = true; + break; } } } - if ( + if (dataIsOlder) { + continue; + } else if ( typeof simpleStatement.version_added === 'string' && typeof inferredStatement.version_added === 'string' && inferredStatement.version_added.includes('≤')