Skip to content

Commit

Permalink
Move common launch arguments to utils
Browse files Browse the repository at this point in the history
Up until this change we have had to update every test individually
to add a new option to the test matrix. This change adds a new
way to create the various launch arguments so that only
one place needs to be updated in the future.

The test argument to fillDefaults is to simplify some future
improvements to the logging coming in subsequent commits.
  • Loading branch information
jonahgraham committed Sep 17, 2022
1 parent 9245b81 commit c8015bc
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 229 deletions.
17 changes: 8 additions & 9 deletions src/integration-tests/attachRemote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ import {
TargetAttachArguments,
} from '../GDBTargetDebugSession';
import { CdtDebugClient } from './debugClient';
import { standardBeforeEach, testProgramsDir, gdbServerPath } from './utils';
import { gdbPath, openGdbConsole, gdbAsync, gdbNonStop } from './utils';
import {
standardBeforeEach,
testProgramsDir,
gdbServerPath,
fillDefaults,
} from './utils';

describe('attach remote', function () {
let dc: CdtDebugClient;
Expand Down Expand Up @@ -61,18 +65,13 @@ describe('attach remote', function () {

it('can attach remote and hit a breakpoint', async function () {
await dc.hitBreakpoint(
{
verbose: true,
gdb: gdbPath,
fillDefaults(this.test, {
program: emptyProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
target: {
type: 'remote',
parameters: [`localhost:${port}`],
} as TargetAttachArguments,
} as TargetAttachRequestArguments,
} as TargetAttachRequestArguments),
{
path: emptySrc,
line: 3,
Expand Down
25 changes: 8 additions & 17 deletions src/integration-tests/breakpoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@

import * as path from 'path';
import { expect } from 'chai';
import { LaunchRequestArguments } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import {
standardBeforeEach,
gdbPath,
testProgramsDir,
openGdbConsole,
gdbAsync,
gdbNonStop,
getScopes,
verifyVariable,
gdbVersionAtLeast,
fillDefaults,
} from './utils';
import { DebugProtocol } from '@vscode/debugprotocol';

describe('breakpoints', async () => {
describe('breakpoints', async function () {
let dc: CdtDebugClient;

beforeEach(async () => {
beforeEach(async function () {
dc = await standardBeforeEach();

await dc.launchRequest({
verbose: true,
gdb: gdbPath,
program: path.join(testProgramsDir, 'count'),
openGdbConsole,
gdbAsync,
gdbNonStop,
logFile: '/tmp/log',
} as LaunchRequestArguments);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: path.join(testProgramsDir, 'count'),
})
);
});

afterEach(async () => {
Expand Down
18 changes: 3 additions & 15 deletions src/integration-tests/diassemble.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
import { expect } from 'chai';
import * as path from 'path';
import { DebugProtocol } from '@vscode/debugprotocol/lib/debugProtocol';
import { LaunchRequestArguments } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import {
gdbPath,
openGdbConsole,
gdbAsync,
gdbNonStop,
standardBeforeEach,
testProgramsDir,
} from './utils';
import { fillDefaults, standardBeforeEach, testProgramsDir } from './utils';

describe('Disassembly Test Suite', function () {
let dc: CdtDebugClient;
Expand All @@ -32,13 +24,9 @@ describe('Disassembly Test Suite', function () {
dc = await standardBeforeEach();

await dc.hitBreakpoint(
{
gdb: gdbPath,
fillDefaults(this.currentTest, {
program: disProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments,
}),
{
path: disSrc,
line: 2,
Expand Down
14 changes: 3 additions & 11 deletions src/integration-tests/evaluate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ import * as path from 'path';
import { CdtDebugClient } from './debugClient';
import {
expectRejection,
gdbPath,
fillDefaults,
getScopes,
openGdbConsole,
gdbAsync,
gdbNonStop,
Scope,
standardBeforeEach,
testProgramsDir,
Expand All @@ -37,14 +34,9 @@ describe('evaluate request', function () {
}
dc = await standardBeforeEach();
await dc.hitBreakpoint(
{
verbose: true,
gdb: gdbPath,
fillDefaults(this.currentTest, {
program: evaluateProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
},
}),
{
path: evaluateSrc,
line: 2,
Expand Down
23 changes: 8 additions & 15 deletions src/integration-tests/functionBreakpoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,24 @@ import * as path from 'path';
import { expect } from 'chai';
import { join } from 'path';
import { CdtDebugClient } from './debugClient';
import { LaunchRequestArguments } from '../GDBDebugSession';
import {
standardBeforeEach,
gdbPath,
testProgramsDir,
openGdbConsole,
gdbAsync,
gdbNonStop,
getScopes,
fillDefaults,
} from './utils';

describe('function breakpoints', async () => {
describe('function breakpoints', async function () {
let dc: CdtDebugClient;

beforeEach(async () => {
beforeEach(async function () {
dc = await standardBeforeEach();

await dc.launchRequest({
verbose: true,
gdb: gdbPath,
program: join(testProgramsDir, 'functions'),
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: join(testProgramsDir, 'functions'),
})
);
});

afterEach(async () => {
Expand Down
34 changes: 10 additions & 24 deletions src/integration-tests/launch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { expect } from 'chai';
import * as path from 'path';
import { LaunchRequestArguments } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import { standardBeforeEach, testProgramsDir } from './utils';
import { gdbPath, openGdbConsole, gdbAsync, gdbNonStop } from './utils';
import { fillDefaults, standardBeforeEach, testProgramsDir } from './utils';

describe('launch', function () {
let dc: CdtDebugClient;
Expand All @@ -37,14 +36,9 @@ describe('launch', function () {

it('can launch and hit a breakpoint', async function () {
await dc.hitBreakpoint(
{
verbose: true,
gdb: gdbPath,
fillDefaults(this.test, {
program: emptyProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments,
} as LaunchRequestArguments),
{
path: emptySrc,
line: 3,
Expand All @@ -54,14 +48,11 @@ describe('launch', function () {

it('reports an error when specifying a non-existent binary', async function () {
const errorMessage = await new Promise<Error>((resolve, reject) => {
dc.launchRequest({
verbose: true,
gdb: gdbPath,
program: '/does/not/exist',
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments)
dc.launchRequest(
fillDefaults(this.test, {
program: '/does/not/exist',
} as LaunchRequestArguments)
)
.then(reject)
.catch(resolve);
});
Expand All @@ -79,14 +70,9 @@ describe('launch', function () {

it('works with a space in file names', async function () {
await dc.hitBreakpoint(
{
verbose: true,
gdb: gdbPath,
fillDefaults(this.test, {
program: emptySpaceProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments,
} as LaunchRequestArguments),
{
path: emptySpaceSrc,
line: 3,
Expand Down
12 changes: 3 additions & 9 deletions src/integration-tests/launchRemote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
TargetLaunchArguments,
} from '../GDBTargetDebugSession';
import { CdtDebugClient } from './debugClient';
import { standardBeforeEach, testProgramsDir } from './utils';
import { gdbPath, openGdbConsole, gdbAsync, gdbNonStop } from './utils';
import { fillDefaults, standardBeforeEach, testProgramsDir } from './utils';

describe('launch remote', function () {
let dc: CdtDebugClient;
Expand All @@ -37,17 +36,12 @@ describe('launch remote', function () {

it('can launch remote and hit a breakpoint', async function () {
await dc.hitBreakpoint(
{
verbose: true,
gdb: gdbPath,
fillDefaults(this.test, {
program: emptyProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
target: {
type: 'remote',
} as TargetLaunchArguments,
} as TargetLaunchRequestArguments,
} as TargetLaunchRequestArguments),
{
path: emptySrc,
line: 3,
Expand Down
25 changes: 7 additions & 18 deletions src/integration-tests/logpoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,19 @@
import { join } from 'path';
import { expect } from 'chai';
import { CdtDebugClient } from './debugClient';
import { LaunchRequestArguments } from '../GDBDebugSession';
import {
standardBeforeEach,
gdbPath,
testProgramsDir,
openGdbConsole,
gdbAsync,
gdbNonStop,
} from './utils';
import { fillDefaults, standardBeforeEach, testProgramsDir } from './utils';

describe('logpoints', async () => {
let dc: CdtDebugClient;

beforeEach(async () => {
beforeEach(async function () {
dc = await standardBeforeEach();

await dc.launchRequest({
verbose: true,
gdb: gdbPath,
program: join(testProgramsDir, 'count'),
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments);
await dc.launchRequest(
fillDefaults(this.currentTest, {
program: join(testProgramsDir, 'count'),
})
);
});

afterEach(async () => {
Expand Down
15 changes: 4 additions & 11 deletions src/integration-tests/mem-cdt-custom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
import { expect } from 'chai';
import * as path from 'path';
import { DebugProtocol } from '@vscode/debugprotocol/lib/debugProtocol';
import { LaunchRequestArguments, MemoryResponse } from '../GDBDebugSession';
import { MemoryResponse } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import {
expectRejection,
gdbPath,
openGdbConsole,
gdbAsync,
gdbNonStop,
fillDefaults,
standardBeforeEach,
testProgramsDir,
} from './utils';
Expand All @@ -33,13 +30,9 @@ describe('Memory Test Suite for cdt-gdb-adapter/Memory custom request', function
dc = await standardBeforeEach();

await dc.hitBreakpoint(
{
gdb: gdbPath,
fillDefaults(this.currentTest, {
program: memProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments,
}),
{
path: memSrc,
line: 12,
Expand Down
19 changes: 4 additions & 15 deletions src/integration-tests/mem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,11 @@
import { expect } from 'chai';
import * as path from 'path';
import { DebugProtocol } from '@vscode/debugprotocol/lib/debugProtocol';
import {
base64ToHex,
hexToBase64,
LaunchRequestArguments,
} from '../GDBDebugSession';
import { base64ToHex, hexToBase64 } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import {
expectRejection,
gdbPath,
openGdbConsole,
gdbAsync,
gdbNonStop,
fillDefaults,
standardBeforeEach,
testProgramsDir,
} from './utils';
Expand All @@ -37,13 +30,9 @@ describe('Memory Test Suite', function () {
dc = await standardBeforeEach();

await dc.hitBreakpoint(
{
gdb: gdbPath,
fillDefaults(this.currentTest, {
program: memProgram,
openGdbConsole,
gdbAsync,
gdbNonStop,
} as LaunchRequestArguments,
}),
{
path: memSrc,
line: 12,
Expand Down
Loading

0 comments on commit c8015bc

Please sign in to comment.