Skip to content

Commit

Permalink
Add switching between "Parsing" and "Serialization" suites
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Aug 5, 2023
1 parent 9cdf56b commit 909c595
Showing 1 changed file with 71 additions and 32 deletions.
103 changes: 71 additions & 32 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@
<div class="form-group col-md-4">
<input name="filterTarget" class="form-control" v-model="filterTarget" placeholder="Search target...">
</div>
<div class="col-md-4 options-column">
<label class="checkbox-inline" for="only-failures-checkbox">
<input type="checkbox" v-model="skipPassed" id="only-failures-checkbox">
Only failures
</label>
<label class="checkbox-inline" for="group-by-lang">
<input type="checkbox" v-model="groupByLang" id="group-by-lang">
Group columns by language
</label>
<div class="col-md-4">
<div class="options-column">
<label class="checkbox-inline" for="only-failures-checkbox">
<input type="checkbox" v-model="skipPassed" id="only-failures-checkbox">
Only failures
</label>
<label class="checkbox-inline" for="group-by-lang">
<input type="checkbox" v-model="groupByLang" id="group-by-lang">
Group columns by language
</label>
</div>
<div class="options-column">
<label class="radio-inline" for="suite-readonly">
<input type="radio" name="suite" id="suite-readonly" value="readonly" v-model="suite">
Parsing
</label>
<label class="radio-inline" for="suite-readwrite">
<input type="radio" name="suite" id="suite-readwrite" value="readwrite" v-model="suite">
Serialization
</label>
</div>
</div>
</div>
</form>
Expand All @@ -43,10 +55,11 @@
}
.form-row .options-column {
display: inline-block;
padding-left: 12px;
}
.col-md-4 label.checkbox-inline {
.col-md-4 label.checkbox-inline, .col-md-4 label.radio-inline {
padding-top: 6px;
padding-bottom: 6px;
}
Expand Down Expand Up @@ -101,44 +114,68 @@ const TARGET_PAIRS = [
TARGET_PAIRS.forEach(pair => Object.freeze(pair));
Object.freeze(TARGET_PAIRS);
const TARGET_LANGS_READWRITE = new Set([
"java",
"python",
]);
Object.freeze(TARGET_LANGS_READWRITE);
export default {
name: 'app',
components: {
CiGrid
},
data: function () {
return {
testData: {},
filterTest: '',
filterTarget: '',
gridColumns: [],
gridData: [],
gridMeta: {},
suiteData: {
readonly: {
testData: {},
gridColumns: [],
gridData: [],
gridMeta: {},
},
readwrite: {
testData: {},
gridColumns: [],
gridData: [],
gridMeta: {},
},
},
skipPassed: false,
groupByLang: true,
suite: 'readonly',
};
},
created: function () {
const pairCmpFunc = this.getPairCompareFunc(TARGET_PAIRS);
TARGET_PAIRS.forEach(pair => this.addOneJson(pair[0], pair[1], pairCmpFunc));
TARGET_PAIRS.forEach(pair => {
this.addOneJson(pair[0], pair[1], pairCmpFunc, 'readonly');
if (TARGET_LANGS_READWRITE.has(pair[0])) {
this.addOneJson(pair[0], pair[1], pairCmpFunc, 'readwrite');
}
});
},
computed: {
groupedGridColumns: function () {
const gridColumns = this.suiteData[this.suite].gridColumns;
if (!this.groupByLang) {
return this.gridColumns;
return gridColumns;
}
return Array.from(
new Set(
this.gridColumns.map(pair => pair.split('/')[0])
gridColumns.map(pair => pair.split('/')[0])
)
);
},
groupedGridData: function () {
const gridData = this.suiteData[this.suite].gridData;
if (!this.groupByLang) {
return this.gridData;
return gridData;
}
const pairCmpFunc = this.getPairCompareFunc(TARGET_PAIRS);
return this.gridData.map(testRow => {
return gridData.map(testRow => {
const newTestRow = {};
const keys = Object.keys(testRow).sort(pairCmpFunc);
keys.forEach((key) => {
Expand Down Expand Up @@ -206,11 +243,12 @@ export default {
});
},
groupedGridMeta: function () {
const gridMeta = this.suiteData[this.suite].gridMeta;
if (!this.groupByLang) {
return this.gridMeta;
return gridMeta;
}
const newGridMeta = {};
Object.entries(this.gridMeta).forEach(([pair, meta]) => {
Object.entries(gridMeta).forEach(([pair, meta]) => {
const lang = pair.split('/')[0];
if (!Object.prototype.hasOwnProperty.call(newGridMeta, lang)) {
newGridMeta[lang] = {
Expand Down Expand Up @@ -240,8 +278,10 @@ export default {
},
},
methods: {
addOneJson: function (lang, version, pairCmpFunc) {
addOneJson: function (lang, version, pairCmpFunc, suite) {
var pair = lang + "/" + version;
lang += (suite === 'readwrite' ? "-write" : "");
const suiteData = this.suiteData[suite];
console.log("Querying data for", pair);
fetch(
"https://raw.githubusercontent.com/kaitai-io/ci_artifacts/" + pair + "/test_out/" + lang + "/ci.json"
Expand All @@ -259,11 +299,10 @@ export default {
var numPassed = 0;
var numKst = 0;
for (const testName in json) {
if (!Object.prototype.hasOwnProperty.call(this.testData, testName)) {
this.testData[testName] = {"name": testName};
if (!Object.prototype.hasOwnProperty.call(suiteData.testData, testName)) {
suiteData.testData[testName] = {"name": testName};
}
var row = this.testData[testName];
delete json[testName]["name"];
var row = suiteData.testData[testName];
row[pair] = json[testName];
if (row[pair].status === 'passed')
numPassed++;
Expand All @@ -272,18 +311,18 @@ export default {
}
// Generate output
this.gridColumns.push(pair);
this.gridColumns = this.gridColumns.sort(pairCmpFunc);
this.gridData = [];
for (const testName in this.testData) {
this.gridData.push(this.testData[testName]);
suiteData.gridColumns.push(pair);
suiteData.gridColumns.sort(pairCmpFunc);
suiteData.gridData = [];
for (const testName in suiteData.testData) {
suiteData.gridData.push(suiteData.testData[testName]);
}
meta.passed = numPassed;
meta.kst = numKst;
meta.timestamp = new Date(meta.timestamp);
meta.artifactsUrl = "https://github.com/kaitai-io/ci_artifacts/tree/" + pair + "/test_out/" + lang;
this.gridMeta[pair] = meta;
suiteData.gridMeta[pair] = meta;
}).catch(err => {
console.warn("Cannot fetch data for " + pair + ". " + err);
});
Expand Down

0 comments on commit 909c595

Please sign in to comment.