-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add a simple test. #98
base: master
Are you sure you want to change the base?
Conversation
I like the direction of this! Thank you for having a crack. A few points of feedback :) What you're doing would make more sense to me as an integration test of kondo_lib. So it would go in I'd also suggest test utilities to create the test projects as opposed to having them hardcoded in the repo, like you've done in Avoid referencing a absolute path that is based on your home directory. |
Thanks, I use tests to help understand what's going on, and it grew from main, so I ended up testing from the wrong place. I'm really trying to isolate parts, so I'll stick to the unit test model, but relocate to the right module. I'll iterate and ping you next time. |
ebce728
to
b7b4452
Compare
ok... done with changes for a few hours @tbillington. Thoughts? |
This is looking good so far, appreciate you iterating on it. Adding tests for the first time is always a bit painful :) There's really only a few blockers for me
I'd also suggest you enable clippy in your editor of choice if possible, it's a great rust learning tool! If you're using vscode you just need to add If you have any questions don't hesitate to ask |
Hey @tbillington, Thanks for the feedback. I'm still really new to rust, so I haven't used clippy. I'll look into it. Thanks. re: Specify test in kondo-lib re linting, I'll refresh today (I'm US east coast, so we're dominating the 24 hour clock). re changing public api. I'll look closer at kondo-lib today and see if what you say sinks in. Will make another iteration and see your feedback tomorrow. |
199d18d
to
92564ad
Compare
Ok... think I'm following on where I was testing from kondo into the lib for clean(). I moved that kondo-lib, but still seeing need for the discover() test to remain in kondo. Peek at this revision and let me know. |
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.
Apologies, I'd written comments but forgot to "submit" the review !
It's a bit late here atm so I'll check back later :)
kondo/src/main.rs
Outdated
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.
The diff of this file is a bit unfortunate, wish git would understand what's happening better :/
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.
+1 the gist is I'm slicing it into exe and lib parts. I think I got it right, but check the real files, cause the diff is gross :)
kondo/tests/test.rs
Outdated
} | ||
|
||
// Given a name, create a new simulated python project in a safe to delete directry | ||
fn create_fake_python_project(name: String) -> tempfile::TempDir { |
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 much prefer this method of constructing test directories.
kondo currently supports 16 project types, and if we want to have multiple variations per type to test different cases.. this repo will grow quite a bit :). It also couples strings (paths) in test code with folder structure unnecessarily.
I don't expect you to add support for any more than you're already doing, just thinking ahead.
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'm torn.. think that's why I came at it both ways.
I like creating the test dir programmatically for unit tests, but see some value in a user dropping you a tarball containing a project that doesn't work, and us including a distillation of that as a test scenario. Think regression testing.
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 wouldn't be too hard to quickly re-create that via a code method, especially with some helper functions.
Another option which I previously hadn't considered was specifying them in something like json files, haven't thought much on it though.
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've kept both for now.
lib unit tests: create_fake_python_project . I'm not sure how to share this code across the two modules' unit tests, so it's currently duplicated here. I don't like this :) what do you recommend?
integ tests: with_temp_dir_from directory based scenarios
Review what's here at your leisure once more and I'll make another pass before rebasing again. A part I'd like to change. but I'm not sure if I'll get to today... is to move the programmatically created project into the unit test, and the file-based test out to the integ/cli test. Including your wrapper syntax around temp dirs. |
I think I got to almost all your feedback. I like the wrapper idea and played with it. Ready for feedback. |
Sorry I haven't gotten to this yet, been a bit busy. You mentioned being open to chat, just curious which timezone you're in? I'm in GMT+10 |
Re-formatting, I have this in my settings.json "[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
}, |
I'm GMT-4. My night/your morning to midday are the best opportunities. I'm also a bit tied up, but I'll get to this this week. |
This should pass the ci, at least :) Open questions I have:
|
Sorry for the slow reply on this Tom, had a few things on my plate but it's on my list to get around to this hopefully this week. |
Not a problem. PRs can wait, take care of what you need. |
4ee9a24
to
9af9cf3
Compare
* top level test_data dir has sub dirs for scenarios, two have been created (single cargo, two python) * restructure kondo/main into kondo/main and lib so integ test can run * unit test: kondo/discover and kondo-lib/clean * integration test: cli run of "kondo -- --version" command * infrastructure for creating a test project to run kondo in destructivly
9af9cf3
to
a03a78e
Compare
adding a few tests around path_canonicalize(). Seems like there is a bug there when |
Adding this to open discussion around the issue #7 , and to lay framework for fixing #97