MCPcopy Create free account
hub / github.com/checkmake/checkmake / TestParse_VariableVsRuleMisclassification

Function TestParse_VariableVsRuleMisclassification

parser/parser_test.go:88–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestParse_VariableVsRuleMisclassification(t *testing.T) {
89 t.Parallel()
90 makefile := `
91ifeq ($(OS), Windows_NT)
92MKDIR := $(shell which mkdir.exe)
93else
94MKDIR := mkdir
95endif
96`
97 tmp := writeTempMakefile(t, makefile)
98 defer os.Remove(tmp)
99
100 ret, err := Parse(tmp)
101 require.NoError(t, err)
102
103 varNames := make([]string, len(ret.Variables))
104 for i, v := range ret.Variables {
105 varNames[i] = v.Name
106 }
107
108 assert.Contains(t, varNames, "MKDIR", "MKDIR should be parsed as a variable, not a rule")
109 assert.Empty(t, ret.Rules, "no rules should be parsed in this makefile")
110}
111
112func TestParse_BuildRuleRecognized(t *testing.T) {
113 t.Parallel()

Callers

nothing calls this directly

Calls 2

writeTempMakefileFunction · 0.85
ParseFunction · 0.85

Tested by

no test coverage detected