drewdeponte / alt

Command line tool to find alternate files
MIT License
138 stars 12 forks source link

Support for x.test.x #21

Open bugeats opened 6 years ago

bugeats commented 6 years ago

I'm surprised to see that this doesn't work:

alt ./crypto-helpers.test.js

I would expect discovery of:

./crypto-helpers.js

... and vise-versa.

drewdeponte commented 5 years ago

This has been merged in and included in the v3.1.0 release in our Homebrew tap and on GitHub.

ashb commented 5 years ago

Along a similar vein our in-house stlye is to have .unit.test.js (and .integration.test.js) too. I could add this one case, but it's probably a bit specific to our naming scheme only.

Should I open a PR to add support for \.(?:[^.]+\.)?.test.js?

drewdeponte commented 5 years ago

Yeah, I was thinking about adding .test.js as well.

drewdeponte commented 5 years ago

@bugeats @ashb I dug into the issues in more details. It is a side effect of the test classification regex not being correct and no fallback based on the scoring without test classification happening. So, I spun up a branch called add_fallback. It would be great if you could pull down the branch, build it and test it and let me know if this helps.

ashb commented 5 years ago

From commit 771de9e

$ /Users/ash/code/tmp/alt/target/release/alt src/lib/directives/auth/index.unit.test.js; echo
src/lib/jwt/index.unit.test.js

So it now returns something rather than nothing, but not even close to the right value for me - it's picked a totally different directory.

src/lib/directives/auth/index.unit.test.js <-> src/lib/directives/auth/index.js is the pairing I would expect here.

drewdeponte commented 5 years ago

@ashb grab the latest add_fallback branch and try it agin. Should be commit 78a82b4 and let me know.

drewdeponte commented 2 years ago

@ashb did you ever verify this?

ashb commented 2 years ago

@drewdeponte Sorry, no I somehow missed the notification.

Still no dice on commit 78a82b4, and the minimal repro of just those files doesn't exhibit this behaviour, so something else is about this (private, sorry can't share it) is causing the issue.

Non-repro:

$ mkdir -p src/lib/directives/auth/ src/lib/jwt/
$ touch {src/lib/jwt/,src/lib/directives/auth/}index{.unit.test,}.js
ashb commented 2 years ago

Ah, add in ./src/lib/directives/index.js and it fails.

Repro steps @drewdeponte:

mkdir -p src/lib/directives/auth/ src/lib/jwt/
touch {src/lib/jwt/,src/lib/directives/auth/}index{.unit.test,}.js
touch ./src/lib/directives/index.js

Which then gives this behaviour:

$ ../target/release/alt src/lib/directives/auth/index.unit.test.js
src/lib/jwt/index.unit.test.js
drewdeponte commented 1 year ago

I just released a new major release of this, v4.0.0 which should resolve these issues I believe.