-
Notifications
You must be signed in to change notification settings - Fork 273
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
feat: Detect circular dependencies. #95
Conversation
test/src/algo.ts
Outdated
const circularProjectRoot = join(__dirname, "..", "data", "test-project-circular-deps") | ||
const nonCircularProjectRoot = join(__dirname, "..", "data", "test-project-b") | ||
|
||
describe("Algo", () => { |
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.
Algo is not a good name for this :) I dunno, maybe we should rename util.ts
to util/index.ts
and add another file under util/
with a more descriptive name.
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.
Haha. Agreed. I'll do that, and rename this file to util/detectCycles.ts
.
test/src/algo.ts
Outdated
it("should throw an exception when circular dependencies are present", async () => { | ||
const garden = await makeTestGarden(circularProjectRoot) | ||
await expectError( | ||
async () => await garden.scanModules(), |
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.
I think it's better to put these tests under the Garden.scanModules
tests, and in turn write a couple of basic unit tests for the detectCycles
function.
test/helpers.ts
Outdated
@@ -201,6 +201,15 @@ export async function expectError(fn: Function, typeOrCallback: string | ((err: | |||
} | |||
} | |||
|
|||
export async function expectNoError(fn: Function) { |
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.
Isn't this redundant? Also, can't see it used anywhere.
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.
It is indeed, forgot to delete this one.
A handful of small comments, otherwise looks good! |
Looks like I accidentally avoided the commit formatter for the latter commit (since I wrote it while squashing). Should I replace the commit or just leave it? |
I'd let it slide, but it also has a typo in it and it tickles my OCD :) so yeah, best replace it |
Or, actually, you can just squash the whole thing. No reason to have a commit and then a fix for that commit in succession (I personally use |
d98fda5
to
9c83c1b
Compare
'Tis been squashed. |
test/src/util.ts
Outdated
const circularProjectRoot = join(__dirname, "..", "data", "test-project-circular-deps") | ||
const garden = await makeTestGarden(circularProjectRoot) | ||
await expectError( | ||
async () => await garden.scanModules(), |
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.
This test seems to be in the wrong place - it's not directly testing this function, nor does that function have any knowledge of Module specs.
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.
Good point - these two probably belong under describe("util") -> describe("detectCircularDependencies")
in this file. Or did you have another placement in mind?
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.
Since this actually tests the scanModules
method on Garden
, it should be with those tests in tests/src/garden.ts
(along with the other scanModules
tests)
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.
Fixed here: 0eadd2c
22c5a66
to
0eadd2c
Compare
Added a check for circular build or service dependencies to the scanModules method of the Garden class.
0eadd2c
to
4a35276
Compare
Added a check for circular build or service dependencies to the
scanModules method of the Garden class.