Skip to content

Commit

Permalink
- fixed a unit test parsing bug (special thanks @bobyboba18).
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryOffsec committed Sep 20, 2024
1 parent 04904a9 commit af38977
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 3.19.3 (Pre-Release)

- fixed a unit test parsing bug (special thanks @Bobyboba18).

## 3.19.2 (Pre-Release)

- bug fix [#200](https://github.com/Security-Experts-Community/vscode-xp/issues/200) - saving unit tests with multiple expect blocks and comments.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 3.19.3 (Pre-Release)

- исправлена ошибка парсинга модульных тестов (special thanks @Bobyboba18).

## 3.19.2 (Pre-Release)

- исправление ошибки [#200](https://github.com/Security-Experts-Community/vscode-xp/issues/200) - сохранение модульных тестов с несколькими блоками expect и комментариями.
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Language client",
"author": "Dmitry Fedosov (@DmitryOffsec)",
"license": "MIT",
"version": "3.19.2",
"version": "3.19.3",
"repository": {
"type": "git",
"url": "https://github.com/Security-Experts-Community/vscode-xp"
Expand Down
31 changes: 18 additions & 13 deletions client/src/models/tests/correlationUnitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class CorrelationUnitTest extends BaseUnitTest {

const table_list = /(?:^#.*$|\r?\n)*^table_list\s+\{.*?\}$/m.exec(testFileContent);
if (table_list && table_list.length === 1) {
inputDataStrings.push(table_list_default[0].trim());
inputDataStrings.push(table_list[0].trim());
}

let m: RegExpExecArray;
Expand Down Expand Up @@ -97,18 +97,23 @@ export class CorrelationUnitTest extends BaseUnitTest {
return [];
}

const tests = fs.readdirSync(testsFullPath)
.map(f => path.join(testsFullPath, f))
.filter(f => f.endsWith(".sc"))
.filter(f => fs.existsSync(f))
.map((f, _) => {
return CorrelationUnitTest.readFromFile(f, rule);
})
.filter((t): t is CorrelationUnitTest => !!t)
// Сортируем тесты, ибо в противном случае сначала будет 1, потом 10 и т.д.
.sort((a, b) => a.getNumber() - b.getNumber());

return tests;
try {
const tests = fs.readdirSync(testsFullPath)
.map(f => path.join(testsFullPath, f))
.filter(f => f.endsWith(".sc"))
.filter(f => fs.existsSync(f))
.map((f, _) => {
return CorrelationUnitTest.readFromFile(f, rule);
})
.filter((t): t is CorrelationUnitTest => !!t)
// Сортируем тесты, ибо в противном случае сначала будет 1, потом 10 и т.д.
.sort((a, b) => a.getNumber() - b.getNumber());

return tests;
}
catch (error) {
throw new XpException("Error parsing unit tests rules", error);
}
}

public static create(rule: RuleBaseItem) : CorrelationUnitTest {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Dmitry Fedosov (@DmitryOffsec)",
"icon": "resources/xp.png",
"license": "MIT",
"version": "3.19.2",
"version": "3.19.3",
"repository": {
"type": "git",
"url": "https://github.com/Security-Experts-Community/vscode-xp"
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "server",
"description": "Language server",
"version": "3.19.2",
"version": "3.19.3",
"author": "Dmitry Fedosov (@DmitryOffsec)",
"license": "MIT",
"engines": {
Expand Down

0 comments on commit af38977

Please sign in to comment.