mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Update tests to use node fs (#7446)
Also don't re-export fs and path through utils
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||||
@@ -30,7 +32,7 @@ import * as utils from '../lib/utils.js';
|
|||||||
import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
||||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||||
|
|
||||||
import {fs, makeCompilationEnvironment} from './utils.js';
|
import {makeCompilationEnvironment} from './utils.js';
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
androidJava: {id: 'android-java'},
|
androidJava: {id: 'android-java'},
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {BaseCompiler} from '../lib/base-compiler.js';
|
import {BaseCompiler} from '../lib/base-compiler.js';
|
||||||
@@ -37,8 +40,6 @@ import {CompilerOverrideType, ConfiguredOverrides} from '../types/compilation/co
|
|||||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
fs,
|
|
||||||
path,
|
|
||||||
makeCompilationEnvironment,
|
makeCompilationEnvironment,
|
||||||
makeFakeCompilerInfo,
|
makeFakeCompilerInfo,
|
||||||
makeFakeParseFiltersAndOutputOptions,
|
makeFakeParseFiltersAndOutputOptions,
|
||||||
@@ -86,6 +87,7 @@ describe('Basic compiler invariants', () => {
|
|||||||
function testIncludeG(text: string) {
|
function testIncludeG(text: string) {
|
||||||
expect(compiler.checkSource(text)).toBeNull();
|
expect(compiler.checkSource(text)).toBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
testIncludeG('#include <iostream>');
|
testIncludeG('#include <iostream>');
|
||||||
testIncludeG('#include <iostream> // <..>');
|
testIncludeG('#include <iostream> // <..>');
|
||||||
testIncludeG('#include <type_traits> // for std::is_same_v<...>');
|
testIncludeG('#include <type_traits> // for std::is_same_v<...>');
|
||||||
@@ -96,6 +98,7 @@ describe('Basic compiler invariants', () => {
|
|||||||
function testIncludeNotG(text: string) {
|
function testIncludeNotG(text: string) {
|
||||||
expect(compiler.checkSource(text)).toEqual('<stdin>:1:1: no absolute or relative includes please');
|
expect(compiler.checkSource(text)).toEqual('<stdin>:1:1: no absolute or relative includes please');
|
||||||
}
|
}
|
||||||
|
|
||||||
testIncludeNotG('#include <./.bashrc>');
|
testIncludeNotG('#include <./.bashrc>');
|
||||||
testIncludeNotG('#include </dev/null> // <..>');
|
testIncludeNotG('#include </dev/null> // <..>');
|
||||||
testIncludeNotG('#include <../fish.config> // for std::is_same_v<...>');
|
testIncludeNotG('#include <../fish.config> // for std::is_same_v<...>');
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
import {Readable} from 'node:stream';
|
import {Readable} from 'node:stream';
|
||||||
|
|
||||||
import {GetObjectCommand, NoSuchKey, PutObjectCommand, S3} from '@aws-sdk/client-s3';
|
import {GetObjectCommand, NoSuchKey, PutObjectCommand, S3} from '@aws-sdk/client-s3';
|
||||||
@@ -37,7 +39,7 @@ import {NullCache} from '../lib/cache/null.js';
|
|||||||
import {OnDiskCache} from '../lib/cache/on-disk.js';
|
import {OnDiskCache} from '../lib/cache/on-disk.js';
|
||||||
import {S3Cache} from '../lib/cache/s3.js';
|
import {S3Cache} from '../lib/cache/s3.js';
|
||||||
|
|
||||||
import {fs, path, newTempDir} from './utils.js';
|
import {newTempDir} from './utils.js';
|
||||||
|
|
||||||
function basicTests(factory: () => BaseCache) {
|
function basicTests(factory: () => BaseCache) {
|
||||||
it('should start empty', async () => {
|
it('should start empty', async () => {
|
||||||
|
|||||||
@@ -22,14 +22,18 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import * as fsSync from 'node:fs';
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import * as cfg from '../lib/cfg/cfg.js';
|
import * as cfg from '../lib/cfg/cfg.js';
|
||||||
|
|
||||||
import {fs, path, makeFakeCompilerInfo, resolvePathFromTestRoot} from './utils.js';
|
import {makeFakeCompilerInfo, resolvePathFromTestRoot} from './utils.js';
|
||||||
|
|
||||||
async function DoCfgTest(cfgArg, filename, isLlvmIr = false) {
|
async function DoCfgTest(cfgArg, filename, isLlvmIr = false) {
|
||||||
const contents = await fs.readJson(filename, 'utf8');
|
const contents = JSON.parse(await fs.readFile(filename, 'utf8'));
|
||||||
const structure = cfg.generateStructure(
|
const structure = cfg.generateStructure(
|
||||||
makeFakeCompilerInfo({
|
makeFakeCompilerInfo({
|
||||||
compilerType: '',
|
compilerType: '',
|
||||||
@@ -47,7 +51,7 @@ describe('Cfg test cases', () => {
|
|||||||
// For backwards compatability reasons, we have a sync readdir here. For details, see
|
// For backwards compatability reasons, we have a sync readdir here. For details, see
|
||||||
// the git blame of this file.
|
// the git blame of this file.
|
||||||
// TODO: Consider replacing with https://github.com/vitest-dev/vitest/issues/703
|
// TODO: Consider replacing with https://github.com/vitest-dev/vitest/issues/703
|
||||||
const files = fs.readdirSync(testcasespath);
|
const files = fsSync.readdirSync(testcasespath);
|
||||||
|
|
||||||
describe('gcc', () => {
|
describe('gcc', () => {
|
||||||
for (const filename of files.filter(x => x.includes('gcc'))) {
|
for (const filename of files.filter(x => x.includes('gcc'))) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
import _ from 'underscore';
|
import _ from 'underscore';
|
||||||
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
@@ -29,8 +30,6 @@ import {unwrap} from '../lib/assert.js';
|
|||||||
import {languages} from '../lib/languages.js';
|
import {languages} from '../lib/languages.js';
|
||||||
import * as properties from '../lib/properties.js';
|
import * as properties from '../lib/properties.js';
|
||||||
|
|
||||||
import {fs} from './utils.js';
|
|
||||||
|
|
||||||
describe('Live site checks', () => {
|
describe('Live site checks', () => {
|
||||||
let ceProps;
|
let ceProps;
|
||||||
let compilerProps;
|
let compilerProps;
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import * as fsSync from 'node:fs';
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {unwrap} from '../lib/assert.js';
|
import {unwrap} from '../lib/assert.js';
|
||||||
@@ -35,7 +39,7 @@ import * as properties from '../lib/properties.js';
|
|||||||
import {SymbolStore} from '../lib/symbol-store.js';
|
import {SymbolStore} from '../lib/symbol-store.js';
|
||||||
import * as utils from '../lib/utils.js';
|
import * as utils from '../lib/utils.js';
|
||||||
|
|
||||||
import {fs, path, makeFakeCompilerInfo, resolvePathFromTestRoot} from './utils.js';
|
import {makeFakeCompilerInfo, resolvePathFromTestRoot} from './utils.js';
|
||||||
|
|
||||||
const cppfiltpath = 'c++filt';
|
const cppfiltpath = 'c++filt';
|
||||||
|
|
||||||
@@ -305,8 +309,7 @@ describe('Basic demangling', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function readResultFile(filename: string) {
|
async function readResultFile(filename: string) {
|
||||||
const data = await fs.readFile(filename);
|
const asm = utils.splitLines(await fs.readFile(filename, 'utf-8')).map(line => {
|
||||||
const asm = utils.splitLines(data.toString()).map(line => {
|
|
||||||
return {text: line};
|
return {text: line};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -329,7 +332,7 @@ if (process.platform === 'linux') {
|
|||||||
// For backwards compatability reasons, we have a sync readdir here. For details, see
|
// For backwards compatability reasons, we have a sync readdir here. For details, see
|
||||||
// the git blame of this file.
|
// the git blame of this file.
|
||||||
// TODO: Consider replacing with https://github.com/vitest-dev/vitest/issues/703
|
// TODO: Consider replacing with https://github.com/vitest-dev/vitest/issues/703
|
||||||
const files = fs.readdirSync(testcasespath);
|
const files = fsSync.readdirSync(testcasespath);
|
||||||
|
|
||||||
for (const filename of files) {
|
for (const filename of files) {
|
||||||
if (filename.endsWith('.asm')) {
|
if (filename.endsWith('.asm')) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
@@ -34,7 +35,7 @@ import {AsmParser} from '../lib/parsers/asm-parser.js';
|
|||||||
import {fakeProps} from '../lib/properties.js';
|
import {fakeProps} from '../lib/properties.js';
|
||||||
import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js';
|
import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js';
|
||||||
|
|
||||||
import {fs, resolvePathFromTestRoot} from './utils.js';
|
import {resolvePathFromTestRoot} from './utils.js';
|
||||||
|
|
||||||
function processAsm(filename: string, filters: ParseFiltersAndOutputOptions) {
|
function processAsm(filename: string, filters: ParseFiltersAndOutputOptions) {
|
||||||
const file = fs.readFileSync(filename, 'utf8');
|
const file = fs.readFileSync(filename, 'utf8');
|
||||||
|
|||||||
@@ -22,13 +22,15 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {GolangCompiler} from '../lib/compilers/golang.js';
|
import {GolangCompiler} from '../lib/compilers/golang.js';
|
||||||
import * as utils from '../lib/utils.js';
|
import * as utils from '../lib/utils.js';
|
||||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||||
|
|
||||||
import {fs, makeCompilationEnvironment, makeFakeCompilerInfo} from './utils.js';
|
import {makeCompilationEnvironment, makeFakeCompilerInfo} from './utils.js';
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
go: {id: 'go' as LanguageKey},
|
go: {id: 'go' as LanguageKey},
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
import {CompilationEnvironment} from '../lib/compilation-env.js';
|
||||||
@@ -30,7 +32,7 @@ import * as utils from '../lib/utils.js';
|
|||||||
import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
|
||||||
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
import {CompilerInfo} from '../types/compiler.interfaces.js';
|
||||||
|
|
||||||
import {fs, makeCompilationEnvironment} from './utils.js';
|
import {makeCompilationEnvironment} from './utils.js';
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
java: {id: 'java'},
|
java: {id: 'java'},
|
||||||
|
|||||||
@@ -22,12 +22,13 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {languages} from '../lib/languages.js';
|
import {languages} from '../lib/languages.js';
|
||||||
|
|
||||||
import {fs, path} from './utils.js';
|
|
||||||
|
|
||||||
describe('Language definitions tests', () => {
|
describe('Language definitions tests', () => {
|
||||||
it('Has id equal to object key', () => {
|
it('Has id equal to object key', () => {
|
||||||
for (const languageKey of Object.keys(languages)) expect(languages[languageKey].id).toEqual(languageKey);
|
for (const languageKey of Object.keys(languages)) expect(languages[languageKey].id).toEqual(languageKey);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'node:fs/promises';
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {BaseCompiler} from '../lib/base-compiler.js';
|
import {BaseCompiler} from '../lib/base-compiler.js';
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import cloneDeep from 'lodash.clonedeep';
|
import cloneDeep from 'lodash.clonedeep';
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
@@ -29,8 +31,6 @@ import {LlvmAstParser} from '../lib/llvm-ast.js';
|
|||||||
import * as properties from '../lib/properties.js';
|
import * as properties from '../lib/properties.js';
|
||||||
import * as utils from '../lib/utils.js';
|
import * as utils from '../lib/utils.js';
|
||||||
|
|
||||||
import {fs} from './utils.js';
|
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
'c++': {id: 'c++'},
|
'c++': {id: 'c++'},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,13 +22,15 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {OdinCompiler} from '../lib/compilers/odin.js';
|
import {OdinCompiler} from '../lib/compilers/odin.js';
|
||||||
import {CompilerOutputOptions} from '../types/features/filters.interfaces.js';
|
import {CompilerOutputOptions} from '../types/features/filters.interfaces.js';
|
||||||
import {LanguageKey} from '../types/languages.interfaces.js';
|
import {LanguageKey} from '../types/languages.interfaces.js';
|
||||||
|
|
||||||
import {fs, makeCompilationEnvironment, makeFakeCompilerInfo} from './utils.js';
|
import {makeCompilationEnvironment, makeFakeCompilerInfo} from './utils.js';
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
odin: {id: 'odin' as LanguageKey},
|
odin: {id: 'odin' as LanguageKey},
|
||||||
|
|||||||
@@ -22,13 +22,16 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {Packager} from '../lib/packager.js';
|
import {Packager} from '../lib/packager.js';
|
||||||
|
|
||||||
import {fs, path, newTempDir} from './utils.js';
|
import {newTempDir} from './utils.js';
|
||||||
|
|
||||||
function writeTestFile(filepath) {
|
async function writeTestFile(filepath) {
|
||||||
return fs.writeFile(filepath, '#!/bin/sh\n\necho Hello, world!\n\n');
|
return fs.writeFile(filepath, '#!/bin/sh\n\necho Hello, world!\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +47,7 @@ describe('Packager', () => {
|
|||||||
const targzPath = path.join(dirPath, 'package.tgz');
|
const targzPath = path.join(dirPath, 'package.tgz');
|
||||||
await pack.package(dirPath, targzPath);
|
await pack.package(dirPath, targzPath);
|
||||||
|
|
||||||
await expect(fs.exists(targzPath)).resolves.toBe(true);
|
await expect(fs.stat(targzPath)).resolves.toBeDefined();
|
||||||
},
|
},
|
||||||
{timeout: 5000},
|
{timeout: 5000},
|
||||||
);
|
);
|
||||||
@@ -65,7 +68,7 @@ describe('Packager', () => {
|
|||||||
await pack2.unpack(targzPath, unpackPath);
|
await pack2.unpack(targzPath, unpackPath);
|
||||||
|
|
||||||
const unpackedFilepath = path.join(unpackPath, 'hello.txt');
|
const unpackedFilepath = path.join(unpackPath, 'hello.txt');
|
||||||
await expect(fs.exists(unpackedFilepath)).resolves.toBe(true);
|
await expect(fs.stat(unpackedFilepath)).resolves.toBeDefined;
|
||||||
},
|
},
|
||||||
{timeout: 5000},
|
{timeout: 5000},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
@@ -32,7 +33,7 @@ import {FPCCompiler} from '../lib/compilers/pascal.js';
|
|||||||
import {PascalDemangler} from '../lib/demangler/index.js';
|
import {PascalDemangler} from '../lib/demangler/index.js';
|
||||||
import * as utils from '../lib/utils.js';
|
import * as utils from '../lib/utils.js';
|
||||||
|
|
||||||
import {fs, makeCompilationEnvironment} from './utils.js';
|
import {makeCompilationEnvironment} from './utils.js';
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
pascal: {id: 'pascal'},
|
pascal: {id: 'pascal'},
|
||||||
@@ -360,7 +361,7 @@ describe('Pascal', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should have line numbering', async () => {
|
it('Should have line numbering', async () => {
|
||||||
const asmLines = utils.splitLines((await fs.readFile('test/pascal/asm-example.s')).toString());
|
const asmLines = utils.splitLines(await fs.readFile('test/pascal/asm-example.s', 'utf-8'));
|
||||||
compiler.preProcessLines(asmLines);
|
compiler.preProcessLines(asmLines);
|
||||||
expect(asmLines).toContain('# [output.pas]');
|
expect(asmLines).toContain('# [output.pas]');
|
||||||
expect(asmLines).toContain(' .file 1 "output.pas"');
|
expect(asmLines).toContain(' .file 1 "output.pas"');
|
||||||
@@ -405,10 +406,10 @@ describe('Pascal', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Pascal filetype detection', () => {
|
describe('Pascal filetype detection', async () => {
|
||||||
const pasUtils = new PascalUtils();
|
const pasUtils = new PascalUtils();
|
||||||
const progSource = fs.readFileSync('test/pascal/prog.dpr').toString('utf8');
|
const progSource = await fs.readFile('test/pascal/prog.dpr', 'utf-8');
|
||||||
const unitSource = fs.readFileSync('test/pascal/example.pas').toString('utf8');
|
const unitSource = await fs.readFile('test/pascal/example.pas', 'utf-8');
|
||||||
|
|
||||||
it('Should detect simple program', () => {
|
it('Should detect simple program', () => {
|
||||||
expect(pasUtils.isProgram(progSource)).toEqual(true);
|
expect(pasUtils.isProgram(progSource)).toEqual(true);
|
||||||
@@ -439,7 +440,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('examples/pascal/default.pas').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -452,7 +453,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('test/pascal/example.pas').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -465,7 +466,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('test/pascal/prog.dpr').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -483,7 +484,7 @@ describe('Pascal', () => {
|
|||||||
contents: '{ hello\n world }',
|
contents: '{ hello\n world }',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const source = fs.readFileSync('test/pascal/prog.dpr').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -511,7 +512,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('examples/pascal/default.pas').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -524,7 +525,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('test/pascal/example.pas').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -537,7 +538,7 @@ describe('Pascal', () => {
|
|||||||
const dirPath = await compiler.newTempDir();
|
const dirPath = await compiler.newTempDir();
|
||||||
const filters = {};
|
const filters = {};
|
||||||
const files = [];
|
const files = [];
|
||||||
const source = fs.readFileSync('test/pascal/prog.dpr').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
@@ -555,7 +556,7 @@ describe('Pascal', () => {
|
|||||||
contents: '{ hello\n world }',
|
contents: '{ hello\n world }',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const source = fs.readFileSync('test/pascal/prog.dpr').toString('utf8');
|
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, filters);
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,13 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {ClientStateGoldenifier, ClientStateNormalizer} from '../lib/clientstate-normalizer.js';
|
import {ClientStateGoldenifier, ClientStateNormalizer} from '../lib/clientstate-normalizer.js';
|
||||||
import {ClientState} from '../lib/clientstate.js';
|
import {ClientState} from '../lib/clientstate.js';
|
||||||
|
|
||||||
import {fs} from './utils.js';
|
|
||||||
|
|
||||||
describe('Normalizing clientstate', () => {
|
describe('Normalizing clientstate', () => {
|
||||||
it('Should translate 2 compilers GL layout to clientstate', () => {
|
it('Should translate 2 compilers GL layout to clientstate', () => {
|
||||||
const normalizer = new ClientStateNormalizer();
|
const normalizer = new ClientStateNormalizer();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import path from 'node:path';
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -35,8 +36,6 @@ import {ToolEnv} from '../lib/tooling/base-tool.interface.js';
|
|||||||
import {CompilerDropinTool} from '../lib/tooling/compiler-dropin-tool.js';
|
import {CompilerDropinTool} from '../lib/tooling/compiler-dropin-tool.js';
|
||||||
import {ToolInfo} from '../types/tool.interfaces.js';
|
import {ToolInfo} from '../types/tool.interfaces.js';
|
||||||
|
|
||||||
import {path} from './utils.js';
|
|
||||||
|
|
||||||
describe('CompilerDropInTool', () => {
|
describe('CompilerDropInTool', () => {
|
||||||
it('Should support llvm based compilers', () => {
|
it('Should support llvm based compilers', () => {
|
||||||
const tool = new CompilerDropinTool({} as ToolInfo, {} as ToolEnv);
|
const tool = new CompilerDropinTool({} as ToolInfo, {} as ToolEnv);
|
||||||
|
|||||||
@@ -22,13 +22,13 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import {beforeAll, describe, expect, it} from 'vitest';
|
import {beforeAll, describe, expect, it} from 'vitest';
|
||||||
|
|
||||||
import {RouteAPI} from '../lib/handlers/route-api.js';
|
import {RouteAPI} from '../lib/handlers/route-api.js';
|
||||||
|
|
||||||
import {fs} from './utils.js';
|
|
||||||
|
|
||||||
describe('Basic unfurls', () => {
|
describe('Basic unfurls', () => {
|
||||||
const router = null as any as express.Router;
|
const router = null as any as express.Router;
|
||||||
let config;
|
let config;
|
||||||
@@ -44,7 +44,7 @@ describe('Basic unfurls', () => {
|
|||||||
},
|
},
|
||||||
storageHandler: {
|
storageHandler: {
|
||||||
expandId: async id => {
|
expandId: async id => {
|
||||||
const json = await fs.readFile('test/state/' + id + '.json');
|
const json = await fs.readFile('test/state/' + id + '.json', 'utf-8');
|
||||||
return {
|
return {
|
||||||
config: json,
|
config: json,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import fs from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import {fileURLToPath} from 'node:url';
|
import {fileURLToPath} from 'node:url';
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
@@ -31,8 +33,6 @@ import winston from 'winston';
|
|||||||
import {makeLogStream} from '../lib/logger.js';
|
import {makeLogStream} from '../lib/logger.js';
|
||||||
import * as utils from '../lib/utils.js';
|
import * as utils from '../lib/utils.js';
|
||||||
|
|
||||||
import {fs} from './utils.js';
|
|
||||||
|
|
||||||
describe('Splits lines', () => {
|
describe('Splits lines', () => {
|
||||||
it('handles empty input', () => {
|
it('handles empty input', () => {
|
||||||
expect(utils.splitLines('')).toEqual([]);
|
expect(utils.splitLines('')).toEqual([]);
|
||||||
@@ -550,7 +550,7 @@ describe('Hash interface', () => {
|
|||||||
|
|
||||||
describe('GoldenLayout utils', () => {
|
describe('GoldenLayout utils', () => {
|
||||||
it('finds every editor & compiler', async () => {
|
it('finds every editor & compiler', async () => {
|
||||||
const state = await fs.readJson('test/example-states/default-state.json');
|
const state = JSON.parse(await fs.readFile('test/example-states/default-state.json', 'utf-8'));
|
||||||
const contents = utils.glGetMainContents(state.content);
|
const contents = utils.glGetMainContents(state.content);
|
||||||
expect(contents).toEqual({
|
expect(contents).toEqual({
|
||||||
editors: [
|
editors: [
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import os from 'node:os';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import {fileURLToPath} from 'node:url';
|
import {fileURLToPath} from 'node:url';
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
|
||||||
import temp from 'temp';
|
import temp from 'temp';
|
||||||
import {expect} from 'vitest';
|
import {expect} from 'vitest';
|
||||||
|
|
||||||
@@ -88,5 +87,3 @@ export function newTempDir() {
|
|||||||
temp.track(true);
|
temp.track(true);
|
||||||
return temp.mkdirSync({prefix: 'compiler-explorer-tests', dir: os.tmpdir()});
|
return temp.mkdirSync({prefix: 'compiler-explorer-tests', dir: os.tmpdir()});
|
||||||
}
|
}
|
||||||
|
|
||||||
export {path, fs};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user