blob: d7e501f71d69f43ad13019b84565806277c0e37a [file]
// Copyright 2025 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export class FuchsiaTestData {
constructor(
readonly label: string,
readonly name: string,
readonly os: string,
) { }
get prettyName(): string {
let prettyName = this.name;
let result = prettyName.match(/^([^_:]+)_[^/:]+\/(.+)/);
if (result) {
let targetName = result[1];
let testName = result[2];
return `<${targetName}> · ${testName}`;
}
const FUCHSIA_PKG_PREFIX = 'fuchsia-pkg://fuchsia.com/';
if (prettyName.startsWith(FUCHSIA_PKG_PREFIX)) {
prettyName = prettyName.slice(FUCHSIA_PKG_PREFIX.length);
}
prettyName = prettyName.replace('#meta/', ' · ');
const CM_SUFFIX = '.cm';
if (prettyName.endsWith(CM_SUFFIX)) {
prettyName = prettyName.slice(0, -CM_SUFFIX.length);
}
return prettyName;
}
get relativePath(): string | null {
let relativePath = this.label;
let result = relativePath.match(/^\/\/([^(:]+)(?::[^(]+)?(?:\([^)]+\))?$/);
if (result) {
return `${result[1]}/BUILD.gn`;
}
return null;
}
static fromJSON(object: any): FuchsiaTestData | null {
const label = object['label'];
if (typeof label !== 'string') {
return null;
}
const name = object['name'];
if (typeof name !== 'string') {
return null;
}
const os = object['os'];
if (typeof os !== 'string') {
return null;
}
return new FuchsiaTestData(label, name, os);
}
}