-
Notifications
You must be signed in to change notification settings - Fork 620
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
Unit test input files are verified during make verify-units-inputs
#1909
Closed
ahakanbaba
wants to merge
16
commits into
universal-ctags:master
from
ahakanbaba:puppetManifest-verify-test-input-at-make-check
Closed
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
01bf87a
Attempt to incorporate unit test input file checking to `make check`
ahakanbaba 68aa5e8
Verify input file only expected.tags exists.
ahakanbaba a5eb81e
Fixing puppet syntax and semantic errors in input.pp files
ahakanbaba ac54a3f
After fixing puppet files, fix the expected.tags files.
ahakanbaba 46276ca
Use an empty target instead of a phony target
ahakanbaba 26a3a48
Do not use metaprogramming in Makefile if using bmake
ahakanbaba 7619745
Disable metaprogramming with autoconf/make variable
ahakanbaba 1652bf4
Install puppet to centos tests.
ahakanbaba 0553dc2
Enable verify-units-inputs check in centos tests.
ahakanbaba b31ca7f
Set the path env var at the right place
ahakanbaba e339223
First working attempt of further parametirization of verify-test-inputs.
ahakanbaba f7132f7
Minor improvements to the makefile metaprogramming
ahakanbaba 8b383e7
In verify-units-inputs also parameterize the command
ahakanbaba 234540f
Further metaprogramming improvements.
ahakanbaba ba44ae3
Force rm in the clean target
ahakanbaba 8181d5c
Install epel release first jq later.
ahakanbaba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
www1.example.com input.pp /^node 'www1.example.com' {$/;" node line:2 language:PuppetManifest | ||
www2.example.com input.pp /^node 'www2.example.com', 'www3.example.com' {$/;" node line:12 language:PuppetManifest | ||
www3.example.com input.pp /^node 'www2.example.com', 'www3.example.com' {$/;" node line:12 language:PuppetManifest | ||
default input.pp /^node 'default' {}$/;" node line:2 language:PuppetManifest | ||
www1.example.com input.pp /^node 'www1.example.com' {$/;" node line:3 language:PuppetManifest | ||
www2.example.com input.pp /^node 'www2.example.com', 'www3.example.com' {$/;" node line:13 language:PuppetManifest | ||
www3.example.com input.pp /^node 'www2.example.com', 'www3.example.com' {$/;" node line:13 language:PuppetManifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
var input.pp /^$var=['\/tmp\/file1','\/tmp\/file2']$/;" variable line:1 language:PuppetManifest | ||
arraytest input.pp /^class arraytest {$/;" class line:3 language:PuppetManifest end:9 | ||
var input.pp /^ $var = $var + ['\/tmp\/file3', '\/tmp\/file4']$/;" variable line:4 language:PuppetManifest scope:class:arraytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Units/parser-puppetManifest.r/puppet-collection_within_virtual_definitions.d/expected.tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--sort=no | ||
--fields=+KZlne |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
if true { | ||
# still nothing | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,3 @@ | |
# nothing here | ||
} | ||
|
||
if true { | ||
# still nothing | ||
} |
4 changes: 2 additions & 2 deletions
4
Units/parser-puppetManifest.r/puppet-multipleclass.d/expected.tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
one input.pp /^class one {$/;" class line:1 language:PuppetManifest end:3 | ||
/tmp/multipleclassone input.pp /^ file { "\/tmp\/multipleclassone": content => "one" }$/;" resource line:2 language:PuppetManifest scope:class:one end:2 | ||
one input.pp /^class one {$/;" class line:5 language:PuppetManifest end:7 | ||
/tmp/multipleclasstwo input.pp /^ file { "\/tmp\/multipleclasstwo": content => "two" }$/;" resource line:6 language:PuppetManifest scope:class:one end:6 | ||
two input.pp /^class two {$/;" class line:5 language:PuppetManifest end:7 | ||
/tmp/multipleclasstwo input.pp /^ file { "\/tmp\/multipleclasstwo": content => "two" }$/;" resource line:6 language:PuppetManifest scope:class:two end:6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Units/parser-puppetManifest.r/puppet-scopetest.d/expected.tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mode input.pp /^$mode = 640$/;" variable line:2 language:PuppetManifest | ||
mode input.pp /^$mode = "640"$/;" variable line:2 language:PuppetManifest | ||
thing input.pp /^define thing {$/;" definition line:4 language:PuppetManifest end:6 | ||
/tmp/$name input.pp /^ file { "\/tmp\/$name": ensure => file, mode => $mode }$/;" resource line:5 language:PuppetManifest scope:definition:thing end:5 | ||
testing input.pp /^class testing {$/;" class line:8 language:PuppetManifest end:11 | ||
mode input.pp /^ $mode = 755$/;" variable line:9 language:PuppetManifest scope:class:testing | ||
mode input.pp /^ $mode = "755"$/;" variable line:9 language:PuppetManifest scope:class:testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/tmp/x input.pp /^ file { "\/tmp\/x": }$/;" resource line:2 language:PuppetManifest end:2 | ||
array input.pp /^$array = [ 3, 5, 7 ]$/;" variable line:1 language:PuppetManifest | ||
/tmp/x input.pp /^ file { "\/tmp\/x": }$/;" resource line:3 language:PuppetManifest end:3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
$array = [ 3, 5, 7 ] | ||
unless $array[0] > 5 { | ||
file { "/tmp/x": } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- makefile -*- | ||
.PHONY: check units fuzz noise tmain tinst clean-units clean-tmain clean-gcov run-gcov codecheck cppcheck dicts cspell | ||
.PHONY: check units fuzz noise tmain tinst clean-units clean-tmain clean-gcov run-gcov codecheck cppcheck dicts cspell verify-units-inputs | ||
|
||
check: tmain units | ||
|
||
|
@@ -88,6 +88,31 @@ slap: $(CTAGS_TEST) | |
--with-timeout=$(TIMEOUT)"; \ | ||
$(SHELL) $${c} $(srcdir)/Units | ||
|
||
# TODO: Possibly the bmake does not support the metaprogramming similar to gnu make. | ||
if !USING_BMAKE | ||
# Find the test directories where ctags is expected to succeed. Only tests with | ||
# an expected.tags file present are required to have valid input. | ||
PUPPET_TEST_DIRS = $(foreach path, \ | ||
$(shell find $(srcdir)/Units/parser-puppetManifest.r -name expected.tags), \ | ||
$(shell dirname $(path))) | ||
VERIFY_PUPPET_TEST_DIRS_TARGETS := $(PUPPET_TEST_DIRS:%=%/.input.pp.verified) | ||
|
||
#TODO: We shuold make this an empty target rather than a phony target | ||
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. This comment is not applicable anymore. Should be deleted |
||
define VERIFY_ONE_PUPPET_TEST_DIR | ||
$(1)/.input.pp.verified: $(1)/input.pp | ||
puppet apply --noop $$< && \ | ||
touch $$@ | ||
endef | ||
|
||
$(foreach puppet_test_dir,$(PUPPET_TEST_DIRS),$(eval $(call VERIFY_ONE_PUPPET_TEST_DIR,$(puppet_test_dir)))) | ||
|
||
# | ||
# verify-units-inputs Target | ||
# | ||
verify-units-inputs: $(VERIFY_PUPPET_TEST_DIRS_TARGETS) | ||
|
||
endif # if !USING_BMAKE | ||
|
||
# | ||
# UNITS Target | ||
# | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 rather avoid using non-portable Make stuff if possible, assuming the rest of our makefiles work with BSD make. Here it seems fairly easy to simply make it the content of the target itself, it doesn't seem very important to build target, nor even only build once -- rebuilding seems unlikely and innocent enough.
So, I guess I'd just do something like this (not tested at all, just for the argument):
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 couple of more problems with this approach in the comment.
-j
) forverify-units-inputs
. Allinput.XX
file verification has to be done serially.input.xx
file. Hence, for fast test and development time both (1) and (2) are important.verify-untis-inputs-<language_name>
target is not easy to maintain. Compared to that, the conditional ofif !USING_BMAKE
could be acceptable.These three are important drawbacks.
With using metaprogramming, we gain on all 3 of them. (See my next push to this PR) . What we lose is missing
verify-units-inputs
target in BSD builds. That will not prevent BSD platforms from building and using ctags. Developers on BSD only won't be able to executemake verify-units-intput
locally, if they are submitting PRs from BSD platforms.I have not done development on BSD before. But that does not seem like a big blocker either https://unix.stackexchange.com/a/127955/212862
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.
Fair enough, and you're right that this is probably not a critical enough part of the build system that it can't have its own requirements. Also, we can remember that GNU make is fairly portable by itself, and although not everybody likes it, it is usually possible to get it on most systems; AFAIK it's available on all BSDs under
gmake
, yet probably not in a stock installation.Anyway, given your arguments I only have one concern now: we should check for GNU make, not against BSD make. There are many Make implementations that aren't compatible with GNU make, and most Make implementations don't have those metaprogramming features. So unless somebody feels like tesing every single Make implementation around and see what exact subset it supports, I strongly suggests we have a whitelist instead of a blacklist, and only have GNU make in it at first.
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.
PS: moreover, most Make implementations are installed as
make
, not as other aliases likebmake
,gmake
,pmake
or whatnot. Checking for the name of$MAKE
is not a solid way of cheking which Make implementation is in use.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.
Thanks for the input. I agree on both aspects. The whitelist-blacklist and checking the name of $MAKE. I will hold off on the implementation, though. @masatake mentioned that he will implement this in /misc/units script. If anything changes, I am more than willing to address your comments in this PR.