mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Libraries were being fetched from wrong URL (on startup); `Fetching remote libraries from https://godbolt.org:443/api/libraries/c++` Ended up refactoring a bunch of things to get some unittesting going on I did not test actual startup and compilation with CE, I might have broken something. (but @mattgodbolt tested and it looked great)
104 lines
3.7 KiB
TypeScript
104 lines
3.7 KiB
TypeScript
// Copyright (c) 2018, Filipe Cabecinhas
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without
|
|
// modification, are permitted provided that the following conditions are met:
|
|
//
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
// this list of conditions and the following disclaimer.
|
|
// * Redistributions in binary form must reproduce the above copyright
|
|
// notice, this list of conditions and the following disclaimer in the
|
|
// documentation and/or other materials provided with the distribution.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
import {beforeAll, describe, expect, it} from 'vitest';
|
|
|
|
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
|
import {AnalysisTool, LLVMmcaTool} from '../lib/compilers/index.js';
|
|
|
|
import {
|
|
makeCompilationEnvironment,
|
|
makeFakeCompilerInfo,
|
|
makeFakeParseFiltersAndOutputOptions,
|
|
shouldExist,
|
|
} from './utils.js';
|
|
|
|
const languages = {
|
|
analysis: {id: 'analysis'},
|
|
} as const;
|
|
|
|
describe('LLVM-mca tool definition', () => {
|
|
let ce: CompilationEnvironment;
|
|
let a: LLVMmcaTool;
|
|
|
|
beforeAll(() => {
|
|
ce = makeCompilationEnvironment({languages});
|
|
const info = makeFakeCompilerInfo({
|
|
remote: {
|
|
target: 'foo',
|
|
path: 'bar',
|
|
cmakePath: 'cmake',
|
|
basePath: '/',
|
|
},
|
|
lang: languages.analysis.id,
|
|
});
|
|
a = new LLVMmcaTool(info, ce);
|
|
});
|
|
|
|
it('should have most filters disabled', () => {
|
|
if (shouldExist(a)) {
|
|
expect(a.getInfo().disabledFilters).toEqual(['labels', 'directives', 'commentOnly', 'trim', 'debugCalls']);
|
|
}
|
|
});
|
|
|
|
it('should default to most filters off', () => {
|
|
const filters = a.getDefaultFilters();
|
|
expect(filters.intel).toBe(true);
|
|
expect(filters.commentOnly).toBe(false);
|
|
expect(filters.directives).toBe(false);
|
|
expect(filters.labels).toBe(false);
|
|
expect(filters.optOutput).toBe(false);
|
|
expect(filters.debugCalls).toBe(false);
|
|
});
|
|
|
|
it('should not support objdump', () => {
|
|
expect(a.supportsObjdump()).toBe(false);
|
|
});
|
|
|
|
it('should support "-o output-file" by default', () => {
|
|
const opts = a.optionsForFilter(
|
|
makeFakeParseFiltersAndOutputOptions({
|
|
commentOnly: false,
|
|
labels: true,
|
|
}),
|
|
'output.txt',
|
|
);
|
|
expect(opts).toEqual(['-o', 'output.txt']);
|
|
});
|
|
|
|
it('should split if disabledFilters is a string', () => {
|
|
const info = makeFakeCompilerInfo({
|
|
remote: {
|
|
target: 'foo',
|
|
path: 'bar',
|
|
cmakePath: 'cmake',
|
|
basePath: '/',
|
|
},
|
|
lang: 'analysis',
|
|
disabledFilters: 'labels,directives,debugCalls' as any,
|
|
});
|
|
expect(new AnalysisTool(info, ce).getInfo().disabledFilters).toEqual(['labels', 'directives', 'debugCalls']);
|
|
});
|
|
});
|