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:
@@ -32,7 +32,7 @@ import {parseAllDocuments} from 'yaml';
|
||||
import {splitArguments, unique} from '../shared/common-utils.js';
|
||||
import {OptRemark} from '../static/panes/opt-view.interfaces.js';
|
||||
import {PPOptions} from '../static/panes/pp-view.interfaces.js';
|
||||
import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
||||
import {ParsedAsmResult, ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
||||
import {ClangirBackendOptions} from '../types/compilation/clangir.interfaces.js';
|
||||
import {
|
||||
ActiveTool,
|
||||
@@ -1897,12 +1897,7 @@ export class BaseCompiler {
|
||||
return Promise.all(filesToWrite);
|
||||
}
|
||||
|
||||
protected async writeAllFiles(
|
||||
dirPath: string,
|
||||
source: string,
|
||||
files: FiledataPair[],
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
protected async writeAllFiles(dirPath: string, source: string, files: FiledataPair[]) {
|
||||
if (!source) throw new Error(`File ${this.compileFilename} has no content or file is missing`);
|
||||
|
||||
const inputFilename = path.join(dirPath, this.compileFilename);
|
||||
@@ -1938,7 +1933,7 @@ export class BaseCompiler {
|
||||
}
|
||||
|
||||
async buildExecutableInFolder(key: CacheKey, dirPath: string): Promise<BuildResult> {
|
||||
const writeSummary = await this.writeAllFiles(dirPath, key.source, key.files, key.filters);
|
||||
const writeSummary = await this.writeAllFiles(dirPath, key.source, key.files);
|
||||
const downloads = await this.setupBuildEnvironment(key, dirPath, true);
|
||||
|
||||
const inputFilename = writeSummary.inputFilename;
|
||||
@@ -3057,7 +3052,7 @@ export class BaseCompiler {
|
||||
|
||||
let writeSummary;
|
||||
try {
|
||||
writeSummary = await this.writeAllFiles(dirPath, source, files, filters);
|
||||
writeSummary = await this.writeAllFiles(dirPath, source, files);
|
||||
} catch (e) {
|
||||
return this.handleUserError(e, dirPath);
|
||||
}
|
||||
@@ -3281,7 +3276,7 @@ export class BaseCompiler {
|
||||
return this.asm.process(result.asm, filters);
|
||||
}
|
||||
|
||||
async postProcessAsm(result, filters?: ParseFiltersAndOutputOptions) {
|
||||
async postProcessAsm(result, filters?: ParseFiltersAndOutputOptions): Promise<ParsedAsmResult> {
|
||||
if (!result.okToCache || !this.demanglerClass || !result.asm) return result;
|
||||
const demangler = new this.demanglerClass(this.compiler.demangler, this, this.optionsForDemangler(filters));
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ export class AssemblyCompiler extends BaseCompiler {
|
||||
override async buildExecutableInFolder(key: CacheKey, dirPath: string): Promise<BuildResult> {
|
||||
const buildEnvironment = this.setupBuildEnvironment(key, dirPath, true);
|
||||
|
||||
const writeSummary = await this.writeAllFiles(dirPath, key.source, key.files, key.filters);
|
||||
const writeSummary = await this.writeAllFiles(dirPath, key.source, key.files);
|
||||
const inputFilename = writeSummary.inputFilename;
|
||||
|
||||
const outputFilename = this.getExecutableFilename(dirPath);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {ExecutionOptionsWithEnv, FiledataPair} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import {UnprocessedExecResult} from '../../types/execution/execution.interfaces.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
@@ -60,7 +60,7 @@ export class DosboxCompiler extends BaseCompiler {
|
||||
return Promise.all(filesToWrite);
|
||||
}
|
||||
|
||||
protected override async writeAllFiles(dirPath: string, source: string, files: any[], filters: object) {
|
||||
protected override async writeAllFiles(dirPath: string, source: string, files: FiledataPair[]) {
|
||||
if (!source) throw new Error(`File ${this.compileFilename} has no content or file is missing`);
|
||||
|
||||
const inputFilename = path.join(dirPath, this.compileFilename);
|
||||
|
||||
@@ -44,7 +44,7 @@ export class NumbaCompiler extends BaseCompiler {
|
||||
this.compilerProps('compilerWrapper', '') || resolvePathFromAppRoot('etc', 'scripts', 'numba_wrapper.py');
|
||||
}
|
||||
|
||||
override async processAsm(result, filters, options) {
|
||||
override async processAsm(result, filters, options: string[]) {
|
||||
const processed = await super.processAsm(result, filters, options);
|
||||
// Numba's function-end labels survive standard filtering.
|
||||
if (filters.labels) {
|
||||
|
||||
@@ -25,7 +25,11 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import type {ExecutionOptions, ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {
|
||||
ExecutionOptions,
|
||||
ExecutionOptionsWithEnv,
|
||||
FiledataPair,
|
||||
} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {unwrap} from '../assert.js';
|
||||
@@ -120,7 +124,7 @@ export class PascalWinCompiler extends BaseCompiler {
|
||||
);
|
||||
}
|
||||
|
||||
override async writeAllFiles(dirPath: string, source: string, files: any[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async writeAllFiles(dirPath: string, source: string, files: FiledataPair[]) {
|
||||
let inputFilename: string;
|
||||
if (pascalUtils.isProgram(source)) {
|
||||
inputFilename = path.join(dirPath, this.dprFilename);
|
||||
|
||||
@@ -30,6 +30,7 @@ import type {
|
||||
CacheKey,
|
||||
CompilationCacheKey,
|
||||
ExecutionOptionsWithEnv,
|
||||
FiledataPair,
|
||||
} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
@@ -230,7 +231,7 @@ export class FPCCompiler extends BaseCompiler {
|
||||
return inputFilename;
|
||||
}
|
||||
|
||||
override async writeAllFiles(dirPath: string, source: string, files: any[], filters: ParseFiltersAndOutputOptions) {
|
||||
override async writeAllFiles(dirPath: string, source: string, files: FiledataPair[]) {
|
||||
const inputFilename = path.join(dirPath, this.getMainSourceFilename(source));
|
||||
|
||||
if (source !== '' || !files) {
|
||||
|
||||
@@ -76,7 +76,7 @@ export class WslVcCompiler extends Win32VcCompiler {
|
||||
compiler: string,
|
||||
options: string[],
|
||||
inputFilename: string,
|
||||
execOptions: ExecutionOptionsWithEnv,
|
||||
execOptions?: ExecutionOptionsWithEnv,
|
||||
) {
|
||||
if (!execOptions) {
|
||||
execOptions = this.getDefaultExecOptions();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
export const data = {
|
||||
export const data: Record<string, string[]> = {
|
||||
'default-src': ["'self'", 'https://*.godbolt.org', 'localhost:*', 'https://*.compiler-explorer.com'],
|
||||
'style-src': [
|
||||
"'self'",
|
||||
|
||||
@@ -219,7 +219,7 @@ export class BaseDemangler extends AsmRegex {
|
||||
return this.compiler.exec(this.demanglerExe, this.demanglerArguments, options);
|
||||
}
|
||||
|
||||
public async process(result: ParsedAsmResult, execOptions?: ExecutionOptions) {
|
||||
public async process(result: ParsedAsmResult, execOptions?: ExecutionOptions): Promise<ParsedAsmResult> {
|
||||
const options = execOptions || {};
|
||||
this.result = result;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import * as utils from './utils.js';
|
||||
type MetaNode = {
|
||||
[key: string]: string | number | undefined;
|
||||
metaId: string;
|
||||
metaType: string;
|
||||
metaType?: string;
|
||||
file?: string;
|
||||
filename?: string;
|
||||
line?: number;
|
||||
|
||||
56
package-lock.json
generated
56
package-lock.json
generated
@@ -89,6 +89,7 @@
|
||||
"@types/node-targz": "^0.2.4",
|
||||
"@types/request": "^2.48.13",
|
||||
"@types/response-time": "^2.3.9",
|
||||
"@types/supertest": "^6.0.3",
|
||||
"@types/temp": "^0.9.4",
|
||||
"@types/underscore": "^1.13.0",
|
||||
"@types/webpack-env": "^1.18.8",
|
||||
@@ -5186,6 +5187,13 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cookiejar": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz",
|
||||
"integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/deep-eql": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
|
||||
@@ -5318,6 +5326,13 @@
|
||||
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/methods": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/methods/-/methods-1.1.4.tgz",
|
||||
"integrity": "sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mime": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
|
||||
@@ -5470,6 +5485,47 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/superagent": {
|
||||
"version": "8.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-8.1.9.tgz",
|
||||
"integrity": "sha512-pTVjI73witn+9ILmoJdajHGW2jkSaOzhiFYF1Rd3EQ94kymLqB9PjD9ISg7WaALC7+dCHT0FGe9T2LktLq/3GQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/cookiejar": "^2.1.5",
|
||||
"@types/methods": "^1.1.4",
|
||||
"@types/node": "*",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/superagent/node_modules/form-data": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/supertest": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-6.0.3.tgz",
|
||||
"integrity": "sha512-8WzXq62EXFhJ7QsH3Ocb/iKQ/Ty9ZVWnVzoTKc9tyyFRRF3a74Tk2+TLFgaFFw364Ere+npzHKEJ6ga2LzIL7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/methods": "^1.1.4",
|
||||
"@types/superagent": "^8.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/tar-fs": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/tar-fs/-/tar-fs-2.0.4.tgz",
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
"@types/node-targz": "^0.2.4",
|
||||
"@types/request": "^2.48.13",
|
||||
"@types/response-time": "^2.3.9",
|
||||
"@types/supertest": "^6.0.3",
|
||||
"@types/temp": "^0.9.4",
|
||||
"@types/underscore": "^1.13.0",
|
||||
"@types/webpack-env": "^1.18.8",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -302,7 +302,7 @@ export type SingleFileCacheKey = {
|
||||
filters?: any;
|
||||
tools: any[];
|
||||
libraries: SelectedLibraryVersion[];
|
||||
files: any[];
|
||||
files: FiledataPair[];
|
||||
};
|
||||
|
||||
export type CmakeCacheKey = Omit<SingleFileCacheKey, 'tools'> & {
|
||||
|
||||
@@ -43,10 +43,10 @@ export type OptPipelineOutput = {
|
||||
};
|
||||
|
||||
export type OptPipelineBackendOptions = {
|
||||
filterDebugInfo: boolean;
|
||||
filterIRMetadata: boolean;
|
||||
fullModule: boolean;
|
||||
noDiscardValueNames: boolean;
|
||||
demangle: boolean;
|
||||
libraryFunctions: boolean;
|
||||
filterDebugInfo?: boolean;
|
||||
filterIRMetadata?: boolean;
|
||||
fullModule?: boolean;
|
||||
noDiscardValueNames?: boolean;
|
||||
demangle?: boolean;
|
||||
libraryFunctions?: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user