-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Makefile enhanced to error out with instructions if invoked without a target. #541
Conversation
The first step after cloning any repo with (As for the default |
Oops! Sounds like I made some rookie mistakes (and didn't read the read-me re testing). Thanks for clarifying. That said, there are issues worth resolving:
A fundamental question is whether to continue to (incompletely) expose scripts through both
I'll happily amend this PR, if you tell me how you want to proceed. |
If you note I'd prefer to use I'd be more than happy to accept something that makes |
OK, I've made the following changes:
Regarding the multi-shell tests: they don't seem to do anything, because it is only Seems to me that you'd have to change |
@@ -1,26 +1,34 @@ | |||
URCHIN=`which urchin` | |||
URCHIN := $(shell PATH="$$(npm bin):$$PATH" which urchin) |
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 simply expanded variable (due to :=
rather than =
) - evaluated once, right away - receives the full path to the urchin
executable, while first looking for it among the local npm packages.
whoa - wrt the "In other words: irrespective of what shell urchin was invoked with, the test scripts are always run with sh." line, can you please file a separate issue for that? |
I filed #551 for the cross-shell test bug. |
The updated PR addresses your two requests ( |
Isn't |
I don't think In practice, it does not come preinstalled on recent versions of any of the following platforms: Ubuntu/Debian, Fedora, OSX. http://man.cx/replace suggests that it's an Oracle utility. |
Would it be better, then, to use |
It could be done in As an aside: I just made what was already there work. Who started using |
I believe @koenpunt was the original author of the Makefile. I wasn't aware that it wasn't part of posix at the time. That's a fair point that it's just a dev dependency, which we already have, and that it does make the substitution easier. |
Summary of the latest commit:
I hope I didn't change anything I shouldn't have. |
Once #551 is resolved, a small tweak to |
"test/fast": "urchin -f test/fast", | ||
"test/slow": "urchin -f test/slow", | ||
"test/installation": "urchin -f test/installation" | ||
"test": "make test-sh", |
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.
How hard would it be to make it so npm test
runs the tests in the current shell, whatever it is?
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.
@ljharb: I've added it to the latest PR.
Looks like the tests are failing - perhaps the cwd isn't being set properly? |
Oops! The problem is that I accidentally reset the I've just changed it to only unset if |
|
Thanks, but this would have to be done in the calling shell rather than in the makefile - the best that can be done inside the makefile is to undefine |
@ljharb: The tests pass now. |
# Ensures that the git workspace is clean. | ||
.PHONY: _ensure-clean | ||
_ensure-clean: | ||
@[ -z "$$(git status --porcelain || echo err)" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 1; } |
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 will error out when there are untracked files. Please change this to git status --porcelain --untracked-files=no
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.
Added to the latest update.
However, wouldn't it be safer to also check for untracked files? If you habitually end up with such files, perhaps they should be added to .gitignore
.
Also, shouldn't the tag be an annotated tag (git tag -a "v$(TAG)"
), so as to have metadata associated with it (who tagged, what time, ...)?
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.
Not necessarily - I often have untracked files like npm-debug.log
, or files that are for in-progress changes. The only concern here is "what will get committed", and untracked files won't.
I've never used tag with "-a", but I'm fine adding it - as long as the tag name points to the right SHA, it should work fine.
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 see your point re in-progess changes (npm-debug.log
is a candidate for .gitignore
).
I've added -a
to create annotated tags - it's what man git-tag
says should be used for releases. They're lightweight tags + metadata, notably who created the tag and when. A message must be recorded as well, so I'm simply defaulting that to the version number.
I think you'll need another rebase (sorry about that) |
No worries - done. |
"test/slow": "urchin -f test/slow", | ||
"test/installation": "urchin -f test/installation", | ||
"test/sourcing": "urchin -f test/sourcing" | ||
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell", |
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'd prefer not to add spaces for alignment :-) not a big deal tho, i can fix after merging too
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.
Hmm - $(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//')
on my terminal echoes "Terminal". What's this supposed to output? Should it just be using $SHELL
?
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 determines the grandparent process and therefore only returns the shell when run via npm test
or npm run
(parent process is npm
itself, and the grandparent is the shell that invoked npm
).
(When run directly from an interactive shell on OSX, the grandparent process is, as you've experienced, your terminal (parent is login
).)
Does it not work when you run npm run test/fast
, for instance?
I chose this approach because it truly targets the same shell that the npm
command was invoked from, as opposed to using $SHELL
, which always reports the user's default shell - the two may or may not be the same.
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.
gotcha, that makes sense. I'll play around with it some more.
This will need another rebase :-/ sorry that things are churning. I'd love to get this in but it's large and I need to test it thoroughly - if there's any smaller, less scary chunks that could go out in a separate PR (to shrink this one) that would be cool too. |
I've rebased it again. I hope that'll do. The changes are interrelated, so I don't think chopping this up is the way to go. |
…ns if invoked without target, release mechanism improved), package.json scripts now invoke the makefile. - Using `npm test` and `npm run …` scripts defined in package.json now invokes the makefile and runs the test with the same shell that npm was invoked from. - The makefile can now be invoked directly - supporting utilities from locally installed npm packages are automatically discovered. - Invoking the makefile without a target errors out with a hint. - Shell-specific test targets are now named 'test-<shell>'. - Both 'test-<shell>' targets and the all-shells 'test' target now run all test suites by default. - On `make TAG=<new-version> release` there must be no uncommitted changes. '<new-version>' can now also be one of the following increment specifiers: 'patch', 'minor', 'major'. - It is ensure that <new-version>, if not an increment specifier, is a valid semver version number that is higher than the previous release's. - The previous release tag is now located with a pattern so as to exclude tags that aren't version numbers. - Switched from lightweight to annotated tags for releases.
I've consolidated the PR into a single commit and made one last change: the makefile now determines the list of all test suites automatically by obtaining the names of all subfolders of That way, adding new tests in the future will automatically include them in Finally, I've added Let me know if that works. |
Tested this locally and seems to work great. Thanks so much for your persistence on this! |
Makefile enhanced to error out with instructions if invoked without a target.
Makefile
enhanced to install required test utilityurchin
on demand locally, vianpm install
. The shell command that locates the urchin executable was amended to also find a locally installed version, not just a global one as before.Note that invoking just
make
(without a goal) currently (still) only runs thesh
test (at least on my OS X 10.9.5 machine). Is that the intent?