Skip to content
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

Feature/add support for multiple makefiles #70

Merged
Merged
Prev Previous commit
Next Next commit
Implement FileName struct member for TimestampExpanded rule + tests
  • Loading branch information
trinitronx committed Apr 28, 2022
commit f67af3d7bcc1151203ef4576ca20cfa327d65ffd
1 change: 1 addition & 0 deletions rules/timestampexpanded/timestampexpanded.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (r *Timestampexpanded) Run(makefile parser.Makefile, config rules.RuleConfi
ret = append(ret, rules.RuleViolation{
Rule: "timestampexpanded",
Violation: fmt.Sprintf(vT, variable.Name),
FileName: makefile.FileName,
LineNumber: variable.LineNumber,
})
}
Expand Down
5 changes: 5 additions & 0 deletions rules/timestampexpanded/timestampexpanded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func TestVersionIsNotSimplyExpanded(t *testing.T) {

makefile := parser.Makefile{
FileName: "timestamp-expanded.mk",
Variables: []parser.Variable{parser.Variable{
Name: "BUILDTIME",
Assignment: "$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")",
Expand All @@ -24,11 +25,15 @@ func TestVersionIsNotSimplyExpanded(t *testing.T) {
assert.Equal(t, 1, len(ret))
assert.Equal(t, "timestamp variables should be simply expanded",
rule.Description())
for i := range ret {
assert.Equal(t, "timestamp-expanded.mk", ret[i].FileName)
}
}

func TestVersionIsSimplyExpanded(t *testing.T) {

makefile := parser.Makefile{
FileName: "timestamp-simply-expanded.mk",
Variables: []parser.Variable{parser.Variable{
Name: "BUILDTIME",
Assignment: "$(shell date -u +\"%Y-%m-%dT%H:%M:%SZ\")",
Expand Down