Skip to content

Commit

Permalink
Automatically check Makesurefile samples correctness in README #144
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Sep 24, 2023
1 parent fd436ff commit df04795
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion check_samples_in_README.awk
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ function fixLine() {
sub(/\[ goal_name \]/,"goal_name")
sub(/\[ lib_name \]/,"lib_name")
sub("<glob pattern>","'*.*'")
sub("<condition>","true")
sub(/\[ goal2 \[ goal3.+]/,"goal2 goal3\n")
}

function checkSample( tmp,out) {
# print "\n-------- checking: " Sample
if (isMakesureSample()) {
fixSample()
# print "\n------- Makesurefile: " Sample
print Sample > (tmp = "/tmp/makesuresample1.txt")
close(tmp)
Expand All @@ -39,8 +42,22 @@ function checkSample( tmp,out) {
}
}
}
function fixSample() {
if (Sample ~ /@reached_if/) {
Sample = "@goal g\n" Sample
} else if (Sample ~ /@depends_on goal_name @args/) {
Sample = "@goal goal_name @params A B C\n" Sample
} else if (Sample ~ /@depends_on goal1 goal2 goal3/) {
Sample = "@goal goal1\n@goal goal2\n@goal goal3\n@goal goal\n" Sample
}
}

function isMakesureSample() {
return Sample ~ /(^|\n)@[a-z]+/
}

END { print "\nTotal errors: " ErrorsCnt }
BEGIN { system("touch '/tmp/file with spaces1.txt'") }
END {
print "\nTotal errors: " ErrorsCnt
exit ErrorsCnt > 0
}

0 comments on commit df04795

Please sign in to comment.