Skip to content

Commit 53dfddb

Browse files
committed
🔥 Removed support Ceedling before version 1.0.0
1 parent d1b6a5f commit 53dfddb

File tree

1 file changed

+43
-56
lines changed

1 file changed

+43
-56
lines changed

‎src/adapter.ts‎

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { Logger } from './logger';
2424
import { ProblemMatcher, ProblemMatchingPattern } from './problemMatcher';
2525
import deepmerge from 'deepmerge';
2626

27+
const MINIMUM_CEEDLING_VERSION = '1.0.0';
28+
2729
type ProjectData = {
2830
projectPath: string,
2931
ymlFileName: any,
@@ -55,7 +57,6 @@ interface ExtendedTestInfo extends TestInfo {
5557
export class CeedlingAdapter implements TestAdapter {
5658

5759
private ceedlingVersionChecked = false;
58-
private isOldCeedlingVersion = true;
5960
private disposables: { dispose(): void }[] = [];
6061

6162
private readonly testsEmitter = new vscode.EventEmitter<TestLoadStartedEvent | TestLoadFinishedEvent>();
@@ -149,26 +150,38 @@ export class CeedlingAdapter implements TestAdapter {
149150
try {
150151
const version = await this.getCeedlingVersion();
151152
this.logger.debug(`checkCeedlingVersion()=${version}`);
153+
this.logger.debug(`MINIMUM_CEEDLING_VERSION=${MINIMUM_CEEDLING_VERSION}`);
154+
this.logger.debug(`semver.lt result=${semver.lt(version, MINIMUM_CEEDLING_VERSION)}`);
152155
this.ceedlingVersionChecked = true;
153-
if (semver.satisfies(version, "<0.31.2")) {
154-
this.isOldCeedlingVersion = true;
155-
return
156-
}
157-
this.isOldCeedlingVersion = false;
156+
157+
if (semver.lt(version, MINIMUM_CEEDLING_VERSION)) {
158+
const errorMessage = `Ceedling version ${version} is not supported. This extension requires Ceedling version ${MINIMUM_CEEDLING_VERSION} or higher. Please upgrade your Ceedling installation.`;
159+
this.logger.error(errorMessage);
160+
throw new Error(errorMessage);
161+
}
158162
}
159163
catch (e) {
160164
this.logger.error(`Ceedling Version Check failed: ${util.format(e)}`);
165+
throw e; // Re-throw to propagate the error
161166
}
162167
}
163168

164169
async load(): Promise<void> {
165170
this.ceedlingVersionChecked = false;
166171
this.logger.trace(`load()`);
167172
this.testsEmitter.fire({ type: 'started' } as TestLoadStartedEvent);
168-
await this.checkCeedlingVersion();
169-
if (!this.ceedlingVersionChecked) {
173+
174+
try {
175+
await this.checkCeedlingVersion();
176+
} catch (e) {
177+
const errorMessage = e instanceof Error ? e.message : `Ceedling version check failed: ${util.format(e)}`;
178+
this.testsEmitter.fire({
179+
type: 'finished',
180+
errorMessage: errorMessage
181+
} as TestLoadFinishedEvent);
170182
return;
171183
}
184+
172185
for (const projectKey of this.getProjectKeys()) {
173186
const ymlProjectData = await this.getYmlProjectData(projectKey);
174187
this.logger.debug(`load(projectKey=${projectKey}, ymlProjectData=${util.format(ymlProjectData)})`);
@@ -192,11 +205,7 @@ export class CeedlingAdapter implements TestAdapter {
192205
return;
193206
}
194207
this.watchFilesForReload(ymlPaths);
195-
let filetypes = ['test']
196-
if (!this.isOldCeedlingVersion) {
197-
filetypes = ['assembly', 'header', 'source', 'test']
198-
199-
}
208+
let filetypes = ['assembly', 'header', 'source', 'test']
200209
for (const fileType of filetypes as (keyof ProjectData["files"])[]) {
201210
this.logger.debug(`loadFileLists(fileType=${fileType})`);
202211
await this.loadFileLists(fileType);
@@ -284,10 +293,8 @@ export class CeedlingAdapter implements TestAdapter {
284293
// Get test executable file name without extension
285294
const testFileName = `${/([^/]*).c$/.exec(testToExec)![1]}`;
286295
// Set current test executable
287-
if (this.detectTestSpecificDefines(ymlProjectData, testFileName) || !this.isOldCeedlingVersion) {
296+
if (this.detectTestSpecificDefines(ymlProjectData, testFileName)) {
288297
this.setDebugTestExecutable(`${testFileName}/${testFileName}${ext}`);
289-
} else {
290-
this.setDebugTestExecutable(`${testFileName}${ext}`);
291298
}
292299

293300
// trigger testsuite start event
@@ -474,17 +481,14 @@ export class CeedlingAdapter implements TestAdapter {
474481
return `Failed to find or load the project.yml file for ${projectKey}. ` +
475482
`Please check the ceedlingExplorer.projectPath option.`;
476483
}
477-
if (!this.isOldCeedlingVersion) {
478-
try {
479-
if (!ymlProjectData[':plugins'][':enabled'].includes('report_tests_log_factory')) {
480-
throw 'Report tests log factory plugin not enabled';
481-
}
482-
} catch (e) {
483-
return `The required Ceedling plugin 'report_tests_log_factory' is not enabled. ` +
484-
`You have to edit ${this.getYmlProjectPath(projectKey)} file to enable the plugin.\n` +
485-
`see https://github.com/ThrowTheSwitch/Ceedling/blob/master/docs/CeedlingPacket.md` +
486-
`#tool-element-runtime-substitution-notational-substitution`;
484+
try {
485+
if (!ymlProjectData[':plugins'][':enabled'].includes('report_tests_log_factory')) {
486+
throw 'Report tests log factory plugin not enabled';
487487
}
488+
} catch (e) {
489+
return `The required Ceedling plugin 'report_tests_log_factory' is not enabled. ` +
490+
`You have to edit ${this.getYmlProjectPath(projectKey)} file to enable the plugin.\n` +
491+
`see https://github.com/ThrowTheSwitch/Ceedling/blob/master/plugins/report_tests_log_factory/README.md`;
488492
}
489493
}
490494

@@ -647,7 +651,7 @@ export class CeedlingAdapter implements TestAdapter {
647651
this.logger.error(`fail to get the ceedling version: ${util.format(result)}`);
648652
return '0.0.0';
649653
}
650-
return match[1];
654+
return match[1].trim();
651655
}
652656

653657
private execCeedlingAllProjects(args: ReadonlyArray<string>): Promise<any>[] {
@@ -661,17 +665,11 @@ export class CeedlingAdapter implements TestAdapter {
661665
private execCeedling(args: ReadonlyArray<string>, projectKey = Object.keys(this.projectData)[0]): Promise<any> {
662666
let cwd = ".";
663667
if (this.ceedlingVersionChecked && projectKey in this.projectData) {
664-
if (!this.isOldCeedlingVersion) {
665-
let projectParam = ` --project project.yml`;
666-
if (this.projectData[projectKey].ymlFileName != 'project.yml') {
667-
projectParam += ` --mixin ${this.projectData[projectKey].ymlFileName}`;
668-
}
669-
args = [...args, projectParam];
670-
} else {
671-
const project = this.projectData[projectKey].ymlFileName.substr(0, this.projectData[projectKey].ymlFileName.lastIndexOf('.'));
672-
let projectParam = ` project:${project} `;
673-
args = [...args, projectParam];
668+
let projectParam = ` --project project.yml`;
669+
if (this.projectData[projectKey].ymlFileName != 'project.yml') {
670+
projectParam += ` --mixin ${this.projectData[projectKey].ymlFileName}`;
674671
}
672+
args = [...args, projectParam];
675673
cwd = this.projectData[projectKey].absPath;
676674
}
677675
let command = this.getCeedlingCommand(args);
@@ -754,26 +752,15 @@ export class CeedlingAdapter implements TestAdapter {
754752

755753
private setXmlReportPath(projectKey: string, ymlProjectData: any = undefined) {
756754
let reportFilename = 'report.xml';
757-
if (this.isOldCeedlingVersion) {
758-
if (ymlProjectData) {
759-
try {
760-
const ymlProjectReportFilename = ymlProjectData[':xml_tests_report'][':artifact_filename'];
761-
if (ymlProjectReportFilename != undefined) {
762-
reportFilename = ymlProjectReportFilename;
763-
}
764-
} catch (e) { }
765-
}
766-
} else {
767-
reportFilename = 'cppunit_tests_report.xml';
755+
reportFilename = 'cppunit_tests_report.xml';
768756

769-
if (ymlProjectData) {
770-
try {
771-
const ymlProjectReportFilename = ymlProjectData[':report_tests_log_factory'][':cppunit'][':filename'];
772-
if (ymlProjectReportFilename != undefined) {
773-
reportFilename = ymlProjectReportFilename;
774-
}
775-
} catch (e) { }
776-
}
757+
if (ymlProjectData) {
758+
try {
759+
const ymlProjectReportFilename = ymlProjectData[':report_tests_log_factory'][':cppunit'][':filename'];
760+
if (ymlProjectReportFilename != undefined) {
761+
reportFilename = ymlProjectReportFilename;
762+
}
763+
} catch (e) { }
777764
}
778765
this.reportFilenames[projectKey] = reportFilename;
779766
}

0 commit comments

Comments
 (0)