mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 09:23:52 -05:00
Various type improvements, mostly in tests (#8144)
This commit is contained in:
@@ -36,7 +36,7 @@ import * as props from '../lib/properties.js';
|
||||
import {splitArguments} from '../shared/common-utils.js';
|
||||
import {CompilerOverrideType, ConfiguredOverrides} from '../types/compilation/compiler-overrides.interfaces.js';
|
||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||
|
||||
import {SelectedLibraryVersion} from '../types/libraries/libraries.interfaces.js';
|
||||
import {
|
||||
makeCompilationEnvironment,
|
||||
makeFakeCompilerInfo,
|
||||
@@ -195,12 +195,12 @@ describe('Compiler execution', () => {
|
||||
// }
|
||||
|
||||
it('basecompiler should handle spaces in options correctly', () => {
|
||||
const userOptions = [];
|
||||
const userOptions: string[] = [];
|
||||
const filters = makeFakeParseFiltersAndOutputOptions({});
|
||||
const backendOptions = {};
|
||||
const inputFilename = 'example.cpp';
|
||||
const outputFilename = 'example.s';
|
||||
const libraries = [];
|
||||
const libraries: SelectedLibraryVersion[] = [];
|
||||
|
||||
const args = compiler.prepareArguments(
|
||||
userOptions,
|
||||
@@ -224,12 +224,12 @@ describe('Compiler execution', () => {
|
||||
});
|
||||
|
||||
it('win32 compiler should handle spaces in options correctly', () => {
|
||||
const userOptions = [];
|
||||
const userOptions: string[] = [];
|
||||
const filters = makeFakeParseFiltersAndOutputOptions({});
|
||||
const backendOptions = {};
|
||||
const inputFilename = 'example.cpp';
|
||||
const outputFilename = 'example.s';
|
||||
const libraries = [];
|
||||
const libraries: SelectedLibraryVersion[] = [];
|
||||
|
||||
const win32args = win32compiler.prepareArguments(
|
||||
userOptions,
|
||||
|
||||
@@ -32,7 +32,7 @@ import * as properties from '../lib/properties.js';
|
||||
|
||||
describe('Live site checks', () => {
|
||||
let ceProps;
|
||||
let compilerProps;
|
||||
let compilerProps: properties.CompilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
properties.initialize('etc/config/', ['amazon']);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {DMDCompiler} from '../lib/compilers/dmd.js';
|
||||
import {LDCCompiler} from '../lib/compilers/ldc.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
@@ -35,7 +36,7 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('D', () => {
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
const info = {
|
||||
exe: '/dev/null',
|
||||
remote: {
|
||||
|
||||
@@ -26,17 +26,17 @@ import fs from 'node:fs';
|
||||
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {GolangCompiler} from '../lib/compilers/golang.js';
|
||||
import * as utils from '../lib/utils.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
|
||||
import {makeCompilationEnvironment, makeFakeCompilerInfo} from './utils.js';
|
||||
|
||||
const languages = {
|
||||
go: {id: 'go' as LanguageKey},
|
||||
};
|
||||
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
const info = {
|
||||
exe: '/dev/null',
|
||||
remote: {
|
||||
|
||||
@@ -74,7 +74,7 @@ const compilers: CompilerInfo[] = [
|
||||
];
|
||||
|
||||
describe('API handling', () => {
|
||||
let app;
|
||||
let app: express.Express;
|
||||
|
||||
beforeAll(() => {
|
||||
app = express();
|
||||
|
||||
@@ -64,18 +64,21 @@ describe('Compiler tests', () => {
|
||||
|
||||
describe('Noscript API', () => {
|
||||
it('supports compile', async () => {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
],
|
||||
null,
|
||||
);
|
||||
const res = await request(app)
|
||||
.post('/noscript/compile')
|
||||
.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -90,18 +93,21 @@ describe('Compiler tests', () => {
|
||||
|
||||
describe('Curl API', () => {
|
||||
it('supports compile', async () => {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
],
|
||||
null,
|
||||
);
|
||||
const res = await request(app)
|
||||
.post('/fake-for-test/compile')
|
||||
.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -114,20 +120,23 @@ describe('Compiler tests', () => {
|
||||
});
|
||||
|
||||
it('supports alias compile', async () => {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
id: 'newcompilerid',
|
||||
alias: ['oldid1', 'oldid2'],
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
id: 'newcompilerid',
|
||||
alias: ['oldid1', 'oldid2'],
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
],
|
||||
null,
|
||||
);
|
||||
const res = await request(app)
|
||||
.post('/oldid1/compile')
|
||||
.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -141,29 +150,35 @@ describe('Compiler tests', () => {
|
||||
});
|
||||
|
||||
async function setFakeResult(fakeResult?: any) {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: fakeResult || {},
|
||||
},
|
||||
]);
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: fakeResult || {},
|
||||
},
|
||||
],
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
describe('JSON API', () => {
|
||||
it('handles text output', async () => {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
exe: 'fake',
|
||||
fakeResult: {
|
||||
code: 0,
|
||||
stdout: [{text: 'Something from stdout'}],
|
||||
stderr: [{text: 'Something from stderr'}],
|
||||
asm: [{text: 'ASMASMASM'}],
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
],
|
||||
null,
|
||||
);
|
||||
const res = await request(app)
|
||||
.post('/fake-for-test/compile')
|
||||
.send({
|
||||
@@ -393,29 +408,32 @@ describe('Compiler tests', () => {
|
||||
|
||||
describe('Multi language', () => {
|
||||
async function setFakeCompilers() {
|
||||
await compileHandler.setCompilers([
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'a',
|
||||
lang: 'a',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG A'}]},
|
||||
},
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'b',
|
||||
lang: 'b',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG B'}]},
|
||||
},
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'a',
|
||||
lang: 'b',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG B but A'}]},
|
||||
},
|
||||
]);
|
||||
await compileHandler.setCompilers(
|
||||
[
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'a',
|
||||
lang: 'a',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG A'}]},
|
||||
},
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'b',
|
||||
lang: 'b',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG B'}]},
|
||||
},
|
||||
{
|
||||
compilerType: 'fake-for-test',
|
||||
id: 'a',
|
||||
lang: 'b',
|
||||
exe: 'fake',
|
||||
fakeResult: {code: 0, stdout: [], stderr: [], asm: [{text: 'LANG B but A'}]},
|
||||
},
|
||||
],
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
function makeFakeJson(compiler: string, lang: any) {
|
||||
|
||||
@@ -35,17 +35,17 @@ const languages = {
|
||||
'c++': {id: 'c++'},
|
||||
};
|
||||
|
||||
function mockAstOutput(astLines) {
|
||||
function mockAstOutput(astLines: string[]) {
|
||||
return {stdout: astLines.map(l => ({text: l}))};
|
||||
}
|
||||
|
||||
describe('llvm-ast', () => {
|
||||
let compilerProps;
|
||||
let astParser;
|
||||
let astDump;
|
||||
let astDump: string[];
|
||||
let compilerOutput;
|
||||
let astDumpWithCTime;
|
||||
let astDumpNestedDecl1346;
|
||||
let astDumpWithCTime: string[];
|
||||
let astDumpNestedDecl1346: string[];
|
||||
|
||||
beforeAll(() => {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
@@ -155,7 +155,7 @@ describe('llvm-ast bug-3849b', () => {
|
||||
describe('llvm-ast bug-5889', () => {
|
||||
let compilerProps;
|
||||
let astParser;
|
||||
let astDump;
|
||||
let astDump: string[];
|
||||
let compilerOutput;
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -33,7 +33,7 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('llvm-ir parseMetaNode', () => {
|
||||
let llvmIrParser;
|
||||
let llvmIrParser: LlvmIrParser;
|
||||
let compilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
@@ -102,7 +102,7 @@ describe('llvm-ir parseMetaNode', () => {
|
||||
});
|
||||
|
||||
describe('llvm-ir getSourceLineNumber', () => {
|
||||
let llvmIrParser;
|
||||
let llvmIrParser: LlvmIrParser;
|
||||
let compilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
@@ -113,13 +113,13 @@ describe('llvm-ir getSourceLineNumber', () => {
|
||||
});
|
||||
|
||||
const debugInfo = {
|
||||
'!10': {line: 10},
|
||||
'!20': {line: 20, scope: '!10'},
|
||||
'!11': {scope: '!10'},
|
||||
'!12': {line: 0, scope: '!10'},
|
||||
'!14': {},
|
||||
'!15': {scope: '!14'},
|
||||
'!16': {scope: '!42'},
|
||||
'!10': {line: 10, metaId: ''},
|
||||
'!20': {line: 20, scope: '!10', metaId: ''},
|
||||
'!11': {scope: '!10', metaId: ''},
|
||||
'!12': {line: 0, scope: '!10', metaId: ''},
|
||||
'!14': {metaId: ''},
|
||||
'!15': {scope: '!14', metaId: ''},
|
||||
'!16': {scope: '!42', metaId: ''},
|
||||
};
|
||||
|
||||
it('should return a line number', () => {
|
||||
@@ -143,7 +143,7 @@ describe('llvm-ir getSourceLineNumber', () => {
|
||||
});
|
||||
|
||||
describe('llvm-ir getSourceColumn', () => {
|
||||
let llvmIrParser;
|
||||
let llvmIrParser: LlvmIrParser;
|
||||
let compilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
@@ -154,13 +154,13 @@ describe('llvm-ir getSourceColumn', () => {
|
||||
});
|
||||
|
||||
const debugInfo = {
|
||||
'!10': {column: 10},
|
||||
'!20': {column: 20, scope: '!10'},
|
||||
'!11': {scope: '!10'},
|
||||
'!12': {column: 0, scope: '!10'},
|
||||
'!14': {},
|
||||
'!15': {scope: '!14'},
|
||||
'!16': {scope: '!42'},
|
||||
'!10': {column: 10, metaId: ''},
|
||||
'!20': {column: 20, scope: '!10', metaId: ''},
|
||||
'!11': {scope: '!10', metaId: ''},
|
||||
'!12': {column: 0, scope: '!10', metaId: ''},
|
||||
'!14': {metaId: ''},
|
||||
'!15': {scope: '!14', metaId: ''},
|
||||
'!16': {scope: '!42', metaId: ''},
|
||||
};
|
||||
|
||||
it('should return a column number', () => {
|
||||
@@ -185,7 +185,7 @@ describe('llvm-ir getSourceColumn', () => {
|
||||
});
|
||||
|
||||
describe('llvm-ir getFileName', () => {
|
||||
let llvmIrParser;
|
||||
let llvmIrParser: LlvmIrParser;
|
||||
let compilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
@@ -195,12 +195,12 @@ describe('llvm-ir getFileName', () => {
|
||||
llvmIrParser = new LlvmIrParser(compilerProps, undefined as unknown as LLVMIRDemangler);
|
||||
});
|
||||
const debugInfo = {
|
||||
'!10': {filename: '/test.cpp'},
|
||||
'!20': {filename: '/example.cpp'},
|
||||
'!11': {file: '!10'},
|
||||
'!21': {file: '!20'},
|
||||
'!12': {scope: '!11'},
|
||||
'!13': {scope: '!12'},
|
||||
'!10': {filename: '/test.cpp', metaId: ''},
|
||||
'!20': {filename: '/example.cpp', metaId: ''},
|
||||
'!11': {file: '!10', metaId: ''},
|
||||
'!21': {file: '!20', metaId: ''},
|
||||
'!12': {scope: '!11', metaId: ''},
|
||||
'!13': {scope: '!12', metaId: ''},
|
||||
};
|
||||
|
||||
it('should return a filename', () => {
|
||||
|
||||
@@ -26,17 +26,18 @@ import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {LlvmPassDumpParser} from '../lib/parsers/llvm-pass-dump-parser.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
import {ResultLine} from '../types/resultline/resultline.interfaces.js';
|
||||
|
||||
const languages = {
|
||||
'c++': {id: 'c++'},
|
||||
};
|
||||
|
||||
function deepCopy(obj) {
|
||||
function deepCopy(obj: ResultLine[]): ResultLine[] {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
describe('llvm-pass-dump-parser filter', () => {
|
||||
let llvmPassDumpParser;
|
||||
let llvmPassDumpParser: LlvmPassDumpParser;
|
||||
|
||||
beforeAll(() => {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
@@ -44,7 +45,7 @@ describe('llvm-pass-dump-parser filter', () => {
|
||||
llvmPassDumpParser = new LlvmPassDumpParser(compilerProps);
|
||||
});
|
||||
// biome-ignore format: keep as-is for readability
|
||||
const rawFuncIR = [
|
||||
const rawFuncIR: ResultLine[] = [
|
||||
{text: ' # Machine code for function f(S1&, S2 const&): NoPHIs, TracksLiveness, TiedOpsRewritten'},
|
||||
{text: 'define dso_local void @f(S1&, S2 const&)(%struct.S1* noundef nonnull align 8 dereferenceable(16) %s1, %struct.S2* noundef nonnull align 8 dereferenceable(16) %s2) #0 !dbg !7 {',},
|
||||
{text: 'entry:'},
|
||||
@@ -122,7 +123,7 @@ describe('llvm-pass-dump-parser filter', () => {
|
||||
});
|
||||
|
||||
describe('llvm-pass-dump-parser Old style IR Dump header', () => {
|
||||
let llvmPassDumpParser;
|
||||
let llvmPassDumpParser: LlvmPassDumpParser;
|
||||
|
||||
beforeAll(() => {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
@@ -144,9 +145,7 @@ describe('llvm-pass-dump-parser Old style IR Dump header', () => {
|
||||
];
|
||||
|
||||
it('should recognize dump', () => {
|
||||
const options = {filterDebugInfo: false};
|
||||
|
||||
const brokenDown = llvmPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(rawFuncIR), options);
|
||||
const brokenDown = llvmPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(rawFuncIR));
|
||||
|
||||
expect(brokenDown).toEqual([
|
||||
{
|
||||
@@ -170,7 +169,7 @@ describe('llvm-pass-dump-parser Old style IR Dump header', () => {
|
||||
});
|
||||
|
||||
describe('llvm-pass-dump-parser New style IR Dump header', () => {
|
||||
let llvmPassDumpParser;
|
||||
let llvmPassDumpParser: LlvmPassDumpParser;
|
||||
|
||||
beforeAll(() => {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
@@ -192,9 +191,7 @@ describe('llvm-pass-dump-parser New style IR Dump header', () => {
|
||||
];
|
||||
|
||||
it('should recognize dump', () => {
|
||||
const options = {filterDebugInfo: false};
|
||||
|
||||
const brokenDown = llvmPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(rawFuncIR), options);
|
||||
const brokenDown = llvmPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(rawFuncIR));
|
||||
|
||||
expect(brokenDown).toEqual([
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ import path from 'node:path';
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {unwrap} from '../lib/assert.js';
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {NimCompiler} from '../lib/compilers/nim.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
|
||||
@@ -37,7 +38,7 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('Nim', () => {
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
const info = {
|
||||
exe: '/dev/null',
|
||||
remote: {
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('Numba', () => {
|
||||
binaryObject: false,
|
||||
debugCalls: false,
|
||||
};
|
||||
const options = [];
|
||||
const options: string[] = [];
|
||||
|
||||
beforeAll(() => {
|
||||
ce = makeCompilationEnvironment({languages});
|
||||
|
||||
@@ -26,6 +26,7 @@ import fs from 'node:fs';
|
||||
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {OdinCompiler} from '../lib/compilers/odin.js';
|
||||
import {CompilerOutputOptions} from '../types/features/filters.interfaces.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
@@ -36,7 +37,7 @@ const languages = {
|
||||
odin: {id: 'odin' as LanguageKey},
|
||||
};
|
||||
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
const info = {
|
||||
exe: '/dev/null',
|
||||
remote: {
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('Options handler', () => {
|
||||
ceProps: properties.fakeProps({}),
|
||||
compilerProps: () => {},
|
||||
getCompilerPropsForLanguage: () => {
|
||||
return (prop, def) => def;
|
||||
return (prop: string, def: any) => def;
|
||||
},
|
||||
} as unknown as CompilationEnvironment;
|
||||
});
|
||||
@@ -496,7 +496,7 @@ describe('Options handler', () => {
|
||||
ceProps: properties.fakeProps({}),
|
||||
compilerProps: () => {},
|
||||
getCompilerPropsForLanguage: () => {
|
||||
return (prop, def) => def;
|
||||
return (prop: string, def: any) => def;
|
||||
},
|
||||
} as unknown as CompilationEnvironment;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import {Packager} from '../lib/packager.js';
|
||||
|
||||
import {newTempDir} from './utils.js';
|
||||
|
||||
async function writeTestFile(filepath) {
|
||||
async function writeTestFile(filepath: string) {
|
||||
return fs.writeFile(filepath, '#!/bin/sh\n\necho Hello, world!\n\n');
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import {PascalWinCompiler} from '../lib/compilers/pascal-win.js';
|
||||
import {PascalDemangler} from '../lib/demangler/index.js';
|
||||
import * as utils from '../lib/utils.js';
|
||||
|
||||
import {FiledataPair} from '../types/compilation/compilation.interfaces.js';
|
||||
import {makeCompilationEnvironment} from './utils.js';
|
||||
|
||||
const languages = {
|
||||
@@ -39,7 +40,7 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('Pascal', () => {
|
||||
let compiler;
|
||||
let compiler: FPCCompiler;
|
||||
|
||||
beforeAll(() => {
|
||||
const ce = makeCompilationEnvironment({languages});
|
||||
@@ -355,7 +356,7 @@ describe('Pascal', () => {
|
||||
|
||||
describe('Pascal ASM line number injection', () => {
|
||||
beforeAll(() => {
|
||||
compiler.demanglerClass = PascalDemangler;
|
||||
// compiler.demanglerClass = PascalDemangler;
|
||||
compiler.demangler = new PascalDemangler('demangler-exe', compiler);
|
||||
});
|
||||
|
||||
@@ -421,7 +422,7 @@ describe('Pascal', () => {
|
||||
});
|
||||
|
||||
describe('Multifile writing behaviour', () => {
|
||||
let compiler;
|
||||
let compiler: FPCCompiler;
|
||||
|
||||
beforeAll(() => {
|
||||
const ce = makeCompilationEnvironment({languages});
|
||||
@@ -436,11 +437,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Original behaviour (old unitname)', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('examples/pascal/default.pas', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'output.pas'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'output.pas'))).resolves.toBe(true);
|
||||
@@ -449,11 +449,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Original behaviour (just a unit file)', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('test/pascal/example.pas', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'example.pas'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(true);
|
||||
@@ -462,11 +461,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Writing program instead of a unit', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('test/pascal/prog.dpr', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'prog.dpr'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(false);
|
||||
@@ -475,7 +473,6 @@ describe('Pascal', () => {
|
||||
|
||||
it('Writing program with a unit', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [
|
||||
{
|
||||
filename: 'example.pas',
|
||||
@@ -484,7 +481,7 @@ describe('Pascal', () => {
|
||||
];
|
||||
const source = await fs.readFile('test/pascal/prog.dpr', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'prog.dpr'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(true);
|
||||
@@ -493,7 +490,7 @@ describe('Pascal', () => {
|
||||
});
|
||||
|
||||
describe('Multifile writing behaviour Pascal-WIN', () => {
|
||||
let compiler;
|
||||
let compiler: PascalWinCompiler;
|
||||
|
||||
beforeAll(() => {
|
||||
const ce = makeCompilationEnvironment({languages});
|
||||
@@ -508,11 +505,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Original behaviour (old unitname)', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('examples/pascal/default.pas', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'output.pas'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'output.pas'))).resolves.toBe(true);
|
||||
@@ -521,11 +517,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Original behaviour (just a unit file)', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('test/pascal/example.pas', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'example.pas'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(true);
|
||||
@@ -534,11 +529,10 @@ describe('Pascal', () => {
|
||||
|
||||
it('Writing program instead of a unit', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [];
|
||||
const files: FiledataPair[] = [];
|
||||
const source = await fs.readFile('test/pascal/prog.dpr', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'prog.dpr'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(false);
|
||||
@@ -547,7 +541,6 @@ describe('Pascal', () => {
|
||||
|
||||
it('Writing program with a unit', async () => {
|
||||
const dirPath = await compiler.newTempDir();
|
||||
const filters = {};
|
||||
const files = [
|
||||
{
|
||||
filename: 'example.pas',
|
||||
@@ -556,7 +549,7 @@ describe('Pascal', () => {
|
||||
];
|
||||
const source = await fs.readFile('test/pascal/prog.dpr', 'utf-8');
|
||||
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files, filters);
|
||||
const writeSummary = await compiler.writeAllFiles(dirPath, source, files);
|
||||
|
||||
expect(writeSummary.inputFilename).toEqual(path.join(dirPath, 'prog.dpr'));
|
||||
await expect(utils.fileExists(path.join(dirPath, 'example.pas'))).resolves.toBe(true);
|
||||
|
||||
@@ -29,7 +29,7 @@ import {PELabelReconstructor} from '../lib/pe32-support.js';
|
||||
|
||||
describe('Basic reconstructions', () => {
|
||||
it('No lines', () => {
|
||||
const lines = [];
|
||||
const lines: string[] = [];
|
||||
const reconstructor = new PELabelReconstructor(lines, false, new MapFileReader('unused'), false);
|
||||
expect(reconstructor.asmLines.length).toEqual(0);
|
||||
});
|
||||
|
||||
@@ -28,9 +28,15 @@ import {BaseCompiler} from '../lib/base-compiler.js';
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
|
||||
//const makeFakeCompilerInfo = (id: string, lang: string, group: string, semver: string, isSemver: boolean) => {
|
||||
const makeFakeCompilerInfo = (id, lang, group, semver, isSemver): Partial<CompilerInfo> => {
|
||||
const makeFakeCompilerInfo = (
|
||||
id: string,
|
||||
lang: LanguageKey,
|
||||
group: string,
|
||||
semver: string,
|
||||
isSemver: boolean,
|
||||
): Partial<CompilerInfo> => {
|
||||
return {
|
||||
id: id,
|
||||
exe: '/dev/null',
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {PPCICompiler} from '../lib/compilers/ppci.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
|
||||
@@ -34,7 +35,7 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('PPCI', () => {
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
const info = {
|
||||
exe: '/dev/null',
|
||||
remote: {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {PropertyGetter} from '../lib/properties.interfaces.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
|
||||
const languages = {
|
||||
@@ -31,8 +32,8 @@ const languages = {
|
||||
};
|
||||
|
||||
describe('Properties', () => {
|
||||
let casesProps;
|
||||
let overridingProps;
|
||||
let casesProps: PropertyGetter;
|
||||
let overridingProps: PropertyGetter;
|
||||
let compilerProps;
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -26,17 +26,18 @@ import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {RacketPassDumpParser} from '../lib/parsers/racket-pass-dump-parser.js';
|
||||
import * as properties from '../lib/properties.js';
|
||||
import {ResultLine} from '../types/resultline/resultline.interfaces.js';
|
||||
|
||||
const languages = {
|
||||
racket: {id: 'racket'},
|
||||
};
|
||||
|
||||
function deepCopy(obj) {
|
||||
function deepCopy(obj: ResultLine[]): ResultLine[] {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
describe('racket-pass-dump-parser', () => {
|
||||
let racketPassDumpParser;
|
||||
let racketPassDumpParser: RacketPassDumpParser;
|
||||
|
||||
beforeAll(() => {
|
||||
const fakeProps = new properties.CompilerProps(languages, properties.fakeProps({}));
|
||||
@@ -45,7 +46,7 @@ describe('racket-pass-dump-parser', () => {
|
||||
});
|
||||
|
||||
it('should recognize step', () => {
|
||||
const output = [
|
||||
const output: ResultLine[] = [
|
||||
{text: ';; compile-linklet: phase: 0'},
|
||||
{text: ';; compile-linklet: module: example'},
|
||||
{text: ';; compile-linklet: name: module'},
|
||||
@@ -58,7 +59,7 @@ describe('racket-pass-dump-parser', () => {
|
||||
{text: ' (void))'},
|
||||
];
|
||||
|
||||
const brokenDown = racketPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(output), {});
|
||||
const brokenDown = racketPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(output));
|
||||
|
||||
expect(brokenDown).toEqual([
|
||||
{
|
||||
@@ -71,7 +72,7 @@ describe('racket-pass-dump-parser', () => {
|
||||
});
|
||||
|
||||
it('should recognize pass', () => {
|
||||
const output = [
|
||||
const output: ResultLine[] = [
|
||||
{text: ';; compile-linklet: module: (phases configure-runtime)'},
|
||||
{text: ';; compile-linklet: name: decl'},
|
||||
{text: ';; compile-linklet: passes: all'},
|
||||
@@ -95,7 +96,7 @@ describe('racket-pass-dump-parser', () => {
|
||||
{text: " '#<void>)])])"},
|
||||
];
|
||||
|
||||
const brokenDown = racketPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(output), {});
|
||||
const brokenDown = racketPassDumpParser.breakdownOutputIntoPassDumps(deepCopy(output));
|
||||
|
||||
expect(brokenDown).toEqual([
|
||||
{
|
||||
|
||||
@@ -47,8 +47,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
const orderedArgs = tool.getOrderedArguments(compilationInfo, includeflags, [], args, sourcefile);
|
||||
@@ -68,8 +68,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
const orderedArgs = tool.getOrderedArguments(compilationInfo, includeflags, [], args, sourcefile);
|
||||
@@ -89,8 +89,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
const orderedArgs = tool.getOrderedArguments(compilationInfo, includeflags, [], args, sourcefile);
|
||||
@@ -111,8 +111,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
const orderedArgs = tool.getOrderedArguments(compilationInfo, includeflags, [], args, sourcefile);
|
||||
@@ -135,7 +135,7 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const includeflags: string[] = [];
|
||||
const args = ['/MD', '/STD:c++latest', '/Ox'];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
@@ -154,8 +154,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
|
||||
const orderedArgs = tool.getOrderedArguments(compilationInfo, includeflags, [], args, sourcefile);
|
||||
@@ -173,8 +173,8 @@ describe('CompilerDropInTool', () => {
|
||||
},
|
||||
options: [],
|
||||
};
|
||||
const includeflags = [];
|
||||
const args = [];
|
||||
const includeflags: string[] = [];
|
||||
const args: string[] = [];
|
||||
const sourcefile = 'example.cpp';
|
||||
const libOptions = ['-DMYLIBDEF', '-pthread'];
|
||||
|
||||
|
||||
@@ -596,7 +596,7 @@ describe('squashes horizontal whitespace', () => {
|
||||
});
|
||||
|
||||
describe('encodes in our version of base32', () => {
|
||||
function doTest(original, expected) {
|
||||
function doTest(original: string, expected: string) {
|
||||
expect(utils.base32Encode(Buffer.from(original))).toEqual(expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import child_process from 'node:child_process';
|
||||
|
||||
import {beforeAll, describe, expect, it} from 'vitest';
|
||||
|
||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||
import {WineVcCompiler} from '../lib/compilers/wine-vc.js';
|
||||
import {WslVcCompiler} from '../lib/compilers/wsl-vc.js';
|
||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||
@@ -48,7 +49,7 @@ const info = {
|
||||
};
|
||||
|
||||
describe('Paths', () => {
|
||||
let env;
|
||||
let env: CompilationEnvironment;
|
||||
|
||||
beforeAll(() => {
|
||||
env = makeCompilationEnvironment({languages});
|
||||
@@ -72,7 +73,7 @@ function testExecOutput(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
let ce;
|
||||
let ce: CompilationEnvironment;
|
||||
|
||||
function createCompiler(compiler) {
|
||||
if (ce === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user