Skip to content

Commit

Permalink
test(inline-suggestion): crossFileContextUtil.test using real clock a…
Browse files Browse the repository at this point in the history
…nd test timeouts #6258

## Problem
ref #6252
Test is using real system clock, it's likely to timeout
due to heavy computation in an undeterministic way.

## Solution
Use fake clock.
  • Loading branch information
Will-ShaoHua authored Dec 17, 2024
1 parent 4a0187d commit 7084800
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
*/

import assert from 'assert'
import * as FakeTimers from '@sinonjs/fake-timers'
import * as vscode from 'vscode'
import * as sinon from 'sinon'
import * as crossFile from 'aws-core-vscode/codewhisperer'
import { aStringWithLineCount, createMockTextEditor } from 'aws-core-vscode/test'
import { aStringWithLineCount, createMockTextEditor, installFakeClock } from 'aws-core-vscode/test'
import { FeatureConfigProvider, crossFileContextConfig } from 'aws-core-vscode/codewhisperer'
import {
assertTabCount,
Expand All @@ -30,6 +31,15 @@ describe('crossFileContextUtil', function () {
}

let mockEditor: vscode.TextEditor
let clock: FakeTimers.InstalledClock

before(function () {
clock = installFakeClock()
})

after(function () {
clock.uninstall()
})

afterEach(function () {
sinon.restore()
Expand Down Expand Up @@ -312,9 +322,7 @@ describe('crossFileContextUtil', function () {
})

describe('full support', function () {
// TODO: fix it
// const fileExtLists = ['java', 'js', 'ts', 'py', 'tsx', 'jsx']
const fileExtLists = ['java']
const fileExtLists = ['java', 'js', 'ts', 'py', 'tsx', 'jsx']

before(async function () {
this.timeout(60000)
Expand Down

0 comments on commit 7084800

Please sign in to comment.