Files
Sprinter-SDCC/toolchain/vscode-sprinter-debug/build.test.js
T

41 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const assert = require('node:assert/strict');
const path = require('node:path');
const test = require('node:test');
const {projectForLaunch, isSprinterMakefile, taskLabel} =
require('./build');
const manifest = require('./package.json');
const workspace = path.resolve(__dirname, '..', '..');
const hello = path.join(workspace, 'tests', 'hello');
test('launch находит Makefile рядом с debug-пакетом', () => {
assert.equal(projectForLaunch({
build: '${workspaceFolder}/tests/hello/.sprinter-cc-hello',
}, workspace), hello);
assert.equal(taskLabel(hello, workspace), 'Sprinter: Build tests/hello');
assert.equal(isSprinterMakefile(path.join(hello, 'Makefile')), true);
});
test('пакет в build/ находит Makefile приложения уровнем выше', () => {
const project = path.join(workspace, 'applications', 'SprPoP');
assert.equal(projectForLaunch({
build: '${workspaceFolder}/applications/SprPoP/build/.sprinter-cc-sprpop',
}, workspace), project);
});
test('явный project без Makefile даёт ошибку вместо stale запуска', () => {
assert.throws(() => projectForLaunch({
project: 'tests/sdbg/fixtures', build: 'tests/hello/.sprinter-cc-hello',
}, workspace), /Нет Makefile/);
});
test('matcher разрешает относительную ошибку SDCC внутри проекта', () => {
const matcher = manifest.contributes.problemMatchers[0];
const line = 'hello.c:62: error 20: Undefined identifier \'missing_name\'';
const match = new RegExp(matcher.pattern.regexp).exec(line);
assert.deepEqual(match?.slice(1),
['hello.c', '62', 'error', '20',
"Undefined identifier 'missing_name'"]);
assert.equal(matcher.fileLocation, 'relative');
});