Skip to content

feat(amazonq): inline unit test generation #1406

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

Merged
merged 42 commits into from
Jun 6, 2025
Merged

Conversation

Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua commented May 21, 2025

Problem

UTG is not implemented in Flare and also science team proposed improvement based on the existing UTG living in VSCode/Jetbrains.

Solution

unitTestIntentDetection.ts is the logic to check provided file and its content is a test file or src file.
focalFileResolution.ts is the logic to resolve the focal file (i.e. src file of the provided test file)

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Will-ShaoHua Will-ShaoHua mentioned this pull request May 21, 2025
@Will-ShaoHua
Copy link
Contributor Author

Will-ShaoHua commented May 21, 2025

5/21
unitTestIntentDetection is complete
focalFileIdentity is WIP

@Will-ShaoHua Will-ShaoHua changed the title feat(amazonq): enhanced utg feat(amazonq): inline unit test generation May 28, 2025
supplementalContextValue = await waitUntil(
async function () {
const focalFile = await utgFocalFileResolver.inferFocalFile(document, workspace)
if (focalFile) {

Choose a reason for hiding this comment

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

When isUtg is true but inferFocalFile fails to identify a focal file, should we fall back to using BM25 to retrieve supplemental context? Currently, the logic seems to return an empty result in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will follow up

@Will-ShaoHua
Copy link
Contributor Author

Will-ShaoHua commented Jun 5, 2025

doesnt work in windows

 765 passing (6s)
  8 pending
  1 failing

  1) focalFileResolver
       extractImportedPaths
         python
           case1:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

1 !== 5

      + expected - actual

      -1
      +5
      
      at Context.<anonymous> (src\shared\supplementalContextUtil\focalFileResolution.test.ts:120:24)
      at processImmediate (node:internal/timers:476:21)

@Will-ShaoHua
Copy link
Contributor Author

also not work in windows

   1 failing

  1) focalFileResolver
       extractImportedPaths
         ts
           case1:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

1 !== 3

      + expected - actual

      -1
      +3
      
      at Context.<anonymous> (src\shared\supplementalContextUtil\focalFileResolution.test.ts:147:24)
      at processImmediate (node:internal/timers:476:21)

@Will-ShaoHua Will-ShaoHua marked this pull request as ready for review June 5, 2025 16:47
@Will-ShaoHua Will-ShaoHua requested a review from a team as a code owner June 5, 2025 16:47
const lastMatch = matches[matches.length - 1]
const lastMatchPos = lastMatch.index! + lastMatch[0].length
const tailFromLastTest = content.slice(lastMatchPos)
const lines = tailFromLastTest.split('\n')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should use either \r?\n or os.EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nm these are not used at this point. Will consider removing them when we're sure they are 100% not needed anymore

@Will-ShaoHua
Copy link
Contributor Author

Will-ShaoHua commented Jun 5, 2025

test failure are fixed 8a33f2c

@Will-ShaoHua
Copy link
Contributor Author

Will-ShaoHua commented Jun 5, 2025

will take below as followups

@Will-ShaoHua Will-ShaoHua requested a review from leigaol June 5, 2025 20:30
@Will-ShaoHua Will-ShaoHua merged commit b01610c into aws:main Jun 6, 2025
6 checks passed
@Will-ShaoHua Will-ShaoHua deleted the utg-2 branch June 6, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants