Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show stack trace info in the cargo test output #24

Merged
merged 2 commits into from
Mar 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/cargo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export const config = {
type: 'boolean',
default: false,
order: 3
},
showBacktrace: {
title: 'Show backtrace information in tests',
description: 'Set environment variable RUST_BACKTRACE=1',
type: 'boolean',
default: false,
order: 4
}
};

Expand All @@ -46,6 +53,11 @@ export function provideBuilder() {
const docArgs = [ 'doc' ];
atom.config.get('build-cargo.openDocs') && docArgs.push('--open');

const env = {};
if (atom.config.get('build-cargo.showBacktrace')) {
env['RUST_BACKTRACE'] = '1'
}

const matchRelaxed = '(?<file>.+.rs):(?<line>\\d+):(?<col>\\d+):(?: \\d+:\\d+ )?(error):';
const matchStrict = '(?<file>.+.rs):(?<line>\\d+):(?<col>\\d+):(?: \\d+:\\d+ )?';
const matchThreadPanic = 'thread \'[^\\\']+\' panicked at \'[^\\\']+\', (?<file>[^\\/][^\\:]+):(?<line>\\d+)';
Expand All @@ -55,72 +67,79 @@ export function provideBuilder() {
{
name: 'Cargo: build (debug)',
exec: cargoPath,
env: env,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be set for all commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was a good idea, but I can see arguments either way.

args: [ 'build' ].concat(args),
sh: false,
errorMatch: [ matchRelaxed, matchThreadPanic ]
},
{
name: 'Cargo: build (release)',
exec: cargoPath,
env: env,
args: [ 'build', '--release' ].concat(args),
sh: false,
errorMatch: [ matchStrict, matchThreadPanic ]
},
{
name: 'Cargo: bench',
exec: cargoPath,
env: env,
args: [ 'bench' ].concat(args),
sh: false,
errorMatch: [ matchRelaxed, matchThreadPanic ]
},
{
name: 'Cargo: clean',
exec: cargoPath,
env: env,
args: [ 'clean' ].concat(args),
sh: false,
errorMatch: []
},
{
name: 'Cargo: doc',
exec: cargoPath,
env: env,
args: docArgs.concat(args),
sh: false,
errorMatch: []
},
{
name: 'Cargo: run',
exec: cargoPath,
env: { RUST_BACKTRACE: '1' },
env: env,
args: [ 'run' ].concat(args),
sh: false,
errorMatch: [ matchStrict, matchThreadPanic, matchBacktrace ]
},
{
name: 'Cargo: test',
exec: cargoPath,
env: { RUST_BACKTRACE: '1' },
env: env,
args: [ 'test' ].concat(args),
sh: false,
errorMatch: [ matchStrict, matchThreadPanic, matchBacktrace ]
},
{
name: 'Cargo: update',
exec: cargoPath,
env: env,
args: [ 'update' ].concat(args),
sh: false,
errorMatch: []
},
{
name: `Cargo: build example`,
exec: cargoPath,
env: env,
args: [ 'build', '--example', '{FILE_ACTIVE_NAME_BASE}' ].concat(args),
sh: false,
errorMatch: [ matchRelaxed, matchThreadPanic ]
},
{
name: `Cargo: run example`,
exec: cargoPath,
env: { RUST_BACKTRACE: '1' },
env: env,
args: [ 'run', '--example', '{FILE_ACTIVE_NAME_BASE}' ].concat(args),
sh: false,
errorMatch: [ matchStrict, matchThreadPanic, matchBacktrace ]
Expand Down