Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add benchmark debuging codelens
Browse files Browse the repository at this point in the history
  • Loading branch information
harkal committed Mar 8, 2018
1 parent 64104a1 commit 3e7965d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/goRunTestCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,28 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider {
};

codelens.push(new CodeLens(func.location.range, runBenchmarkCmd));
});

const args = [
'-test.bench', func.name,
'-test.run', 'a^' // Don't match any test
];
const program = path.dirname(document.fileName);
const env = Object.assign({}, this.debugConfig.env, vsConfig['testEnvVars']);
const envFile = vsConfig['testEnvFile'];
let buildFlags = getTestFlags(vsConfig, null);
if (vsConfig['buildTags'] && buildFlags.indexOf('-tags') === -1) {
buildFlags.push('-tags');
buildFlags.push(`${vsConfig['buildTags']}`);
}
let config = Object.assign({}, this.debugConfig, { args, program, env, envFile, buildFlags: buildFlags.map(x => `'${x}'`).join(' ') });
let debugTestCmd = {
title: 'debug benchmark',
command: 'go.debug.startSession',
arguments: [config]
};
codelens.push(new CodeLens(func.location.range, debugTestCmd));
});

});

return Promise.all([testPromise, benchmarkPromise]).then(() => codelens);
Expand Down

0 comments on commit 3e7965d

Please sign in to comment.