-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Try to stabilize tests in CI #1128
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| /// <reference types="jest" /> | ||
|
||
|
|
||
| import { applyContextMatching, applyDMP, applyGitFallback } from "../edit-strategies" | ||
| import { Hunk } from "../types" | ||
|
|
||
|
|
@@ -275,7 +277,7 @@ describe("applyGitFallback", () => { | |
| expect(result.result.join("\n")).toEqual("line1\nnew line2\nline3") | ||
| expect(result.confidence).toBe(1) | ||
| expect(result.strategy).toBe("git-fallback") | ||
| }) | ||
| }, 10_000) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this implies that whatever we’re doing with git in the experimental diff algo is taking between 5 and 10 seconds?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I encountered this timeout while debugging, and increasing it seemed to suddenly make the problems go away. Undoing this change seemed to make the problem reliably come back. One theory I had was that it impacted the order or sequencing of the tests such that the failure stopped happening. I added the --randomize flag to jest to test that theory but we get a bunch of other failures since some of our tests do seem to rely on being run in a particular order (which we should fix). |
||
|
|
||
| it("should return original content with 0 confidence when changes cannot be applied", async () => { | ||
| const hunk = { | ||
|
|
@@ -291,5 +293,5 @@ describe("applyGitFallback", () => { | |
| expect(result.result).toEqual(content) | ||
| expect(result.confidence).toBe(0) | ||
| expect(result.strategy).toBe("git-fallback") | ||
| }) | ||
| }, 10_000) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ import { simpleGit, SimpleGit } from "simple-git" | |
| import { CheckpointServiceFactory } from "../CheckpointServiceFactory" | ||
| import { LocalCheckpointService } from "../LocalCheckpointService" | ||
|
|
||
| const tmpDir = path.join(os.tmpdir(), "test-LocalCheckpointService") | ||
|
|
||
| describe("LocalCheckpointService", () => { | ||
| const taskId = "test-task" | ||
|
|
||
|
|
@@ -29,7 +31,7 @@ describe("LocalCheckpointService", () => { | |
| textFileContent?: string | ||
| }) => { | ||
| // Create a temporary directory for testing. | ||
| await fs.mkdir(workspaceDir) | ||
| await fs.mkdir(workspaceDir, { recursive: true }) | ||
|
|
||
| // Initialize git repo. | ||
| const git = simpleGit(workspaceDir) | ||
|
|
@@ -49,7 +51,7 @@ describe("LocalCheckpointService", () => { | |
| } | ||
|
|
||
| beforeEach(async () => { | ||
| const workspaceDir = path.join(os.tmpdir(), `checkpoint-service-test-${Date.now()}`) | ||
| const workspaceDir = path.join(tmpDir, `checkpoint-service-test-${Date.now()}`) | ||
| const repo = await initRepo({ workspaceDir }) | ||
|
|
||
| testFile = repo.testFile | ||
|
|
@@ -60,10 +62,13 @@ describe("LocalCheckpointService", () => { | |
| }) | ||
|
|
||
| afterEach(async () => { | ||
| await fs.rm(service.workspaceDir, { recursive: true, force: true }) | ||
| jest.restoreAllMocks() | ||
| }) | ||
|
|
||
| afterAll(async () => { | ||
| await fs.rm(tmpDir, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| describe("getDiff", () => { | ||
| it("returns the correct diff between commits", async () => { | ||
| await fs.writeFile(testFile, "Ahoy, world!") | ||
|
|
@@ -316,7 +321,7 @@ describe("LocalCheckpointService", () => { | |
|
|
||
| describe("create", () => { | ||
| it("initializes a git repository if one does not already exist", async () => { | ||
| const workspaceDir = path.join(os.tmpdir(), `checkpoint-service-test2-${Date.now()}`) | ||
| const workspaceDir = path.join(tmpDir, `checkpoint-service-test2-${Date.now()}`) | ||
| await fs.mkdir(workspaceDir) | ||
| const newTestFile = path.join(workspaceDir, "test.txt") | ||
| await fs.writeFile(newTestFile, "Hello, world!") | ||
|
|
@@ -364,7 +369,7 @@ describe("LocalCheckpointService", () => { | |
| }) | ||
|
|
||
| it("respects existing git user configuration", async () => { | ||
| const workspaceDir = path.join(os.tmpdir(), `checkpoint-service-test-config2-${Date.now()}`) | ||
| const workspaceDir = path.join(tmpDir, `checkpoint-service-test-config2-${Date.now()}`) | ||
| const userName = "Custom User" | ||
| const userEmail = "[email protected]" | ||
| await initRepo({ workspaceDir, userName, userEmail }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| { | ||
| "extends": "react-app" | ||
| "extends": "react-app", | ||
| "ignorePatterns": ["!.storybook"] | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a branch rule dictating that "unit-test" must pass in order for the PR to be merged, hence this composite job.