Skip to content

Commit 8c3dc6e

Browse files
Copilotextremeheat
andauthored
Add version regression test and fix data path inconsistencies (#1086)
* Initial plan * Add version regression test with snapshot handling Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com> * Complete working version regression test implementation Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com> * Simplify version regression test using versions.json ordering Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com> * Simplify test logic and fix data path regressions per review feedback Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com>
1 parent 3f0dd2a commit 8c3dc6e

File tree

2 files changed

+101
-6
lines changed

2 files changed

+101
-6
lines changed

data/dataPaths.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@
14751475
"mapIcons": "pc/1.20.2",
14761476
"commands": "pc/1.20.3",
14771477
"sounds": "pc/1.21.1",
1478-
"proto": "pc/1.21.3"
1478+
"proto": "pc/1.21.1"
14791479
},
14801480
"1.21.1": {
14811481
"attributes": "pc/1.21.1",
@@ -2441,11 +2441,11 @@
24412441
"language": "bedrock/1.20.10"
24422442
},
24432443
"1.21.50": {
2444-
"blocks": "bedrock/1.21.0",
2444+
"blocks": "bedrock/1.21.42",
24452445
"blockStates": "bedrock/1.21.50",
2446-
"blockCollisionShapes": "bedrock/1.21.0",
2446+
"blockCollisionShapes": "bedrock/1.21.42",
24472447
"biomes": "bedrock/1.20.0",
2448-
"entities": "bedrock/1.21.0",
2448+
"entities": "bedrock/1.21.42",
24492449
"items": "bedrock/1.21.0",
24502450
"recipes": "bedrock/1.19.10",
24512451
"instruments": "bedrock/1.17.0",
@@ -2455,8 +2455,8 @@
24552455
"protocol": "bedrock/1.21.50",
24562456
"windows": "bedrock/1.16.201",
24572457
"steve": "bedrock/1.21.50",
2458-
"blocksB2J": "bedrock/1.21.0",
2459-
"blocksJ2B": "bedrock/1.21.0",
2458+
"blocksB2J": "bedrock/1.21.42",
2459+
"blocksJ2B": "bedrock/1.21.42",
24602460
"proto": "bedrock/1.21.50",
24612461
"types": "bedrock/1.21.50",
24622462
"version": "bedrock/1.21.50",
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/* eslint-env mocha */
2+
3+
const assert = require('assert')
4+
5+
/**
6+
* Gets the chronological index of a version from the versions.json file
7+
* Returns -1 if version is not found, or null for non-version strings like "latest"
8+
*/
9+
function getVersionIndex (platform, version) {
10+
// Skip non-version entries like "latest"
11+
if (version === 'latest') return null
12+
13+
try {
14+
const versions = require(`../../../data/${platform}/common/versions.json`)
15+
return versions.indexOf(version)
16+
} catch (error) {
17+
return -1
18+
}
19+
}
20+
21+
describe('audit version regression in dataPaths', function () {
22+
const dataPaths = require('../../../data/dataPaths.json')
23+
24+
const platforms = ['pc', 'bedrock']
25+
26+
platforms.forEach(function (platform) {
27+
if (!dataPaths[platform]) return
28+
29+
describe(`${platform} version regression`, function () {
30+
it('should not have newer versions pointing to older data than previously seen', function () {
31+
const platformData = dataPaths[platform]
32+
33+
// Load the chronological version order from versions.json
34+
const versions = require(`../../../data/${platform}/common/versions.json`)
35+
36+
// Track the highest version index seen for each data type
37+
const highestVersionIndexForDataType = {}
38+
39+
// Iterate through versions in chronological order, but only process ones in dataPaths
40+
for (const version of versions) {
41+
if (!platformData[version]) continue
42+
43+
const versionData = platformData[version]
44+
45+
for (const [dataType, dataPath] of Object.entries(versionData)) {
46+
// Skip non-version data paths (like "latest" or cross-platform refs)
47+
const pathParts = dataPath.split('/')
48+
if (pathParts.length !== 2) continue
49+
50+
const [dataPathPlatform, dataPathVersion] = pathParts
51+
52+
// Skip cross-platform references (e.g., bedrock data pointing to pc data)
53+
if (dataPathPlatform !== platform) continue
54+
55+
// Get the chronological index of the data path version
56+
const dataPathIndex = getVersionIndex(platform, dataPathVersion)
57+
58+
// Skip if version not found in versions.json (like "latest")
59+
if (dataPathIndex === null || dataPathIndex === -1) continue
60+
61+
// Initialize tracking for this data type if not seen before
62+
if (!highestVersionIndexForDataType[dataType]) {
63+
highestVersionIndexForDataType[dataType] = {
64+
version: dataPath,
65+
index: dataPathIndex
66+
}
67+
continue
68+
}
69+
70+
// Check if current data path is older than the highest we've seen
71+
const previousHighest = highestVersionIndexForDataType[dataType]
72+
if (dataPathIndex < previousHighest.index) {
73+
assert.fail(
74+
`Version regression detected in ${platform}:\n` +
75+
` Version: ${version}\n` +
76+
` Data type: ${dataType}\n` +
77+
` Current path: ${dataPath} (index: ${dataPathIndex})\n` +
78+
` Expected at least: ${previousHighest.version} (index: ${previousHighest.index})\n` +
79+
' A newer version should not point to older data than previously seen.'
80+
)
81+
}
82+
83+
// Update the highest version if current is newer
84+
if (dataPathIndex > previousHighest.index) {
85+
highestVersionIndexForDataType[dataType] = {
86+
version: dataPath,
87+
index: dataPathIndex
88+
}
89+
}
90+
}
91+
}
92+
})
93+
})
94+
})
95+
})

0 commit comments

Comments
 (0)