feat: Add showStackTrace CLI variable

This commit is contained in:
Joachim Van Herwegen
2021-06-07 13:36:52 +02:00
parent 57d77e941d
commit b604dd8331
13 changed files with 49 additions and 45 deletions

View File

@@ -38,6 +38,7 @@ describe.each(configs)('A dynamic pod server with template config %s', (template
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:rootFilePath': rootFilePath,
'urn:solid-server:default:variable:podConfigJson': podConfigJson,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:idpTemplateFolder': joinFilePath(__dirname, '../../templates/idp'),
};

View File

@@ -63,6 +63,7 @@ describe('A Solid server with IDP', (): void => {
getTestConfigPath('server-memory.json'),
{
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:idpTemplateFolder': joinFilePath(__dirname, '../../templates/idp'),
},
) as Record<string, any>;

View File

@@ -40,6 +40,7 @@ describe.each(stores)('An LDP handler with auth using %s', (name, { storeConfig,
beforeAll(async(): Promise<void> => {
const variables: Record<string, any> = {
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:rootFilePath': rootFilePath,
};

View File

@@ -34,6 +34,7 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
beforeAll(async(): Promise<void> => {
const variables: Record<string, any> = {
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:rootFilePath': rootFilePath,
};

View File

@@ -25,6 +25,7 @@ describe('An http server with middleware', (): void => {
{
'urn:solid-server:default:LdpHandler': new SimpleHttpHandler(),
'urn:solid-server:default:variable:baseUrl': 'https://example.pod/',
'urn:solid-server:default:variable:showStackTrace': true,
},
) as BaseHttpServerFactory;
server = factory.startServer(port);

View File

@@ -21,6 +21,7 @@ describeIf('docker', 'A server with a RedisResourceLocker as ResourceLocker', ()
getTestConfigPath('run-with-redlock.json'),
{
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
},
) as Record<string, any>;
({ factory, locker } = instances);

View File

@@ -22,6 +22,7 @@ describe('A Solid server', (): void => {
getTestConfigPath('server-memory.json'),
{
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:idpTemplateFolder': '',
},
) as Record<string, any>;

View File

@@ -18,6 +18,7 @@ describeIf('docker', 'A server with a SPARQL endpoint as storage', (): void => {
beforeAll(async(): Promise<void> => {
const variables: Record<string, any> = {
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:4000/sparql',
};

View File

@@ -37,6 +37,7 @@ describe.each(stores)('A subdomain server with %s', (name, { storeConfig, teardo
const variables: Record<string, any> = {
'urn:solid-server:default:variable:baseUrl': baseUrl,
'urn:solid-server:default:variable:rootFilePath': rootFilePath,
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:idpTemplateFolder': joinFilePath(__dirname, '../../templates/idp'),
};

View File

@@ -18,6 +18,7 @@ describe('A server with the Solid WebSockets API behind a proxy', (): void => {
getTestConfigPath('server-without-auth.json'),
{
'urn:solid-server:default:variable:baseUrl': 'https://example.pod/',
'urn:solid-server:default:variable:showStackTrace': true,
},
) as HttpServerFactory;
server = factory.startServer(port);

View File

@@ -44,6 +44,7 @@ describe('AppRunner', (): void => {
port: 3000,
loggingLevel: 'info',
rootFilePath: '/var/cwd/',
showStackTrace: false,
podConfigJson: '/var/cwd/pod-config.json',
},
);
@@ -67,6 +68,7 @@ describe('AppRunner', (): void => {
'urn:solid-server:default:variable:rootFilePath': '/var/cwd/',
'urn:solid-server:default:variable:sparqlEndpoint': undefined,
'urn:solid-server:default:variable:loggingLevel': 'info',
'urn:solid-server:default:variable:showStackTrace': false,
'urn:solid-server:default:variable:podConfigJson': '/var/cwd/pod-config.json',
'urn:solid-server:default:variable:idpTemplateFolder': joinFilePath(__dirname, '../../../templates/idp'),
},
@@ -107,6 +109,7 @@ describe('AppRunner', (): void => {
'urn:solid-server:default:variable:rootFilePath': '/var/cwd/',
'urn:solid-server:default:variable:sparqlEndpoint': undefined,
'urn:solid-server:default:variable:loggingLevel': 'info',
'urn:solid-server:default:variable:showStackTrace': false,
'urn:solid-server:default:variable:podConfigJson': '/var/cwd/pod-config.json',
'urn:solid-server:default:variable:idpTemplateFolder': joinFilePath(__dirname, '../../../templates/idp'),
},
@@ -127,6 +130,7 @@ describe('AppRunner', (): void => {
'-m', 'module/path',
'-p', '4000',
'-s', 'http://localhost:5000/sparql',
'-t',
'--podConfigJson', '/different-path.json',
'--idpTemplateFolder', 'templates/idp',
],
@@ -154,6 +158,7 @@ describe('AppRunner', (): void => {
'urn:solid-server:default:variable:port': 4000,
'urn:solid-server:default:variable:rootFilePath': '/root',
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:podConfigJson': '/different-path.json',
'urn:solid-server:default:variable:idpTemplateFolder': '/var/cwd/templates/idp',
},
@@ -172,6 +177,7 @@ describe('AppRunner', (): void => {
'--port', '4000',
'--rootFilePath', 'root',
'--sparqlEndpoint', 'http://localhost:5000/sparql',
'--showStackTrace',
'--podConfigJson', '/different-path.json',
'--idpTemplateFolder', 'templates/idp',
],
@@ -199,6 +205,7 @@ describe('AppRunner', (): void => {
'urn:solid-server:default:variable:port': 4000,
'urn:solid-server:default:variable:rootFilePath': '/var/cwd/root',
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:podConfigJson': '/different-path.json',
'urn:solid-server:default:variable:idpTemplateFolder': '/var/cwd/templates/idp',
},
@@ -217,6 +224,7 @@ describe('AppRunner', (): void => {
'-m', 'module/path',
'-p', '4000',
'-s', 'http://localhost:5000/sparql',
'-t',
'--podConfigJson', '/different-path.json',
'--idpTemplateFolder', 'templates/idp',
];
@@ -245,6 +253,7 @@ describe('AppRunner', (): void => {
'urn:solid-server:default:variable:port': 4000,
'urn:solid-server:default:variable:rootFilePath': '/root',
'urn:solid-server:default:variable:sparqlEndpoint': 'http://localhost:5000/sparql',
'urn:solid-server:default:variable:showStackTrace': true,
'urn:solid-server:default:variable:podConfigJson': '/different-path.json',
'urn:solid-server:default:variable:idpTemplateFolder': '/var/cwd/templates/idp',
},
@@ -293,9 +302,7 @@ describe('AppRunner', (): void => {
it('exits when unknown options are passed to the main executable.', async(): Promise<void> => {
new AppRunner().runCli({
argv: [
'node', 'script', '--foo',
],
argv: [ 'node', 'script', '--foo' ],
});
// Wait until initializer has been called, because we can't await AppRunner.run.
@@ -303,16 +310,14 @@ describe('AppRunner', (): void => {
setImmediate(resolve);
});
expect(error).toHaveBeenCalledWith('Unknown option: "foo"');
expect(error).toHaveBeenCalledWith('Unknown argument: foo');
expect(exit).toHaveBeenCalledTimes(1);
expect(exit).toHaveBeenCalledWith(1);
});
it('exits when no value is passed to the main executable for an argument.', async(): Promise<void> => {
new AppRunner().runCli({
argv: [
'node', 'script', '-s',
],
argv: [ 'node', 'script', '-s' ],
});
// Wait until initializer has been called, because we can't await AppRunner.run.
@@ -320,16 +325,14 @@ describe('AppRunner', (): void => {
setImmediate(resolve);
});
expect(error).toHaveBeenCalledWith('Missing value for argument "s"');
expect(error).toHaveBeenCalledWith('Not enough arguments following: s');
expect(exit).toHaveBeenCalledTimes(1);
expect(exit).toHaveBeenCalledWith(1);
});
it('exits when unknown parameters are passed to the main executable.', async(): Promise<void> => {
new AppRunner().runCli({
argv: [
'node', 'script', 'foo', 'bar', 'foo.txt', 'bar.txt',
],
argv: [ 'node', 'script', 'foo', 'bar', 'foo.txt', 'bar.txt' ],
});
// Wait until initializer has been called, because we can't await AppRunner.run.
@@ -337,17 +340,14 @@ describe('AppRunner', (): void => {
setImmediate(resolve);
});
// There seems to be an issue with yargs where the first and last `"` are missing.
expect(error).toHaveBeenCalledWith('Unsupported arguments: foo", "bar", "foo.txt", "bar.txt');
expect(error).toHaveBeenCalledWith('Unsupported positional arguments: "foo", "bar", "foo.txt", "bar.txt"');
expect(exit).toHaveBeenCalledTimes(1);
expect(exit).toHaveBeenCalledWith(1);
});
it('exits when multiple values for a parameter are passed.', async(): Promise<void> => {
new AppRunner().runCli({
argv: [
'node', 'script', '-ll',
],
argv: [ 'node', 'script', '-l', 'info', '-l', 'debug' ],
});
// Wait until initializer has been called, because we can't await AppRunner.run.
@@ -355,7 +355,7 @@ describe('AppRunner', (): void => {
setImmediate(resolve);
});
expect(error).toHaveBeenCalledWith('Multiple values were provided for: "l", [info,info]');
expect(error).toHaveBeenCalledWith('Multiple values were provided for: "l": "info", "debug"');
expect(exit).toHaveBeenCalledTimes(1);
expect(exit).toHaveBeenCalledWith(1);
});