Skip to content
Snippets Groups Projects
Commit 84561610 authored by Arkerthan's avatar Arkerthan
Browse files

remove python sanity check

parent d1cb4b19
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,4 @@ bin/:
sanity:
./sanityCheck.sh
jsanity:
./sanityCheck.sh java
.PHONY: all sanity jsanity git
.PHONY: all sanity git
......@@ -11,8 +11,7 @@ Options:
-d, --dry Do not compile
-g, --git Add hash of HEAD to filename
-h, --help Show this help text
-j, --java Run sanityCheck based on java (recommended)
-p, --python Run sanityCheck based on python
-s, --sanity Run sanityCheck
-q, --quiet Suppress terminal output
HelpText
}
......@@ -111,11 +110,8 @@ else
displayHelp
exit 0
;;
-j|--java)
java="true"
;;
-p|--python)
python="true"
-s|--sanity)
sanity="true"
;;
-q|--quiet)
output=/dev/null
......@@ -130,8 +126,7 @@ else
fi
# Run sanity check.
[ -n "$java" ] && ./sanityCheck.sh java
[ -n "$python" ] && ./sanityCheck.sh
[ -n "$sanity" ] && ./sanityCheck.sh
if ! [[ -d .git ]]; then
echoMessage "No git repository. Git specfific actions disabled."
......
......@@ -21,7 +21,7 @@ for %%k in (HKCU HKLM) do (
:FOUND
if %GITFOUND% == yes (
set "PATH=%GIT%bin;%PATH%"
bash --login -c "./sanityCheck.sh java"
bash --login -c "./sanityCheck.sh"
)
:: Compile the game
......
@echo off
:: Free Cities Basic Compiler - Windows
:: Set working directory
pushd %~dp0
:: See if we can find a git installation
setlocal enabledelayedexpansion
for %%k in (HKCU HKLM) do (
for %%w in (\ \Wow6432Node\) do (
for /f "skip=2 delims=: tokens=1*" %%a in ('reg query "%%k\SOFTWARE%%wMicrosoft\Windows\CurrentVersion\Uninstall\Git_is1" /v InstallLocation 2^> nul') do (
for /f "tokens=3" %%z in ("%%a") do (
set GIT=%%z:%%b
set GITFOUND=yes
goto FOUND
)
)
)
)
:FOUND
if %GITFOUND% == yes (
set "PATH=%GIT%bin;%PATH%"
bash --login -c ./sanityCheck.sh
)
:: Compile the game
call "%~dp0compile.bat"
if %GITFOUND% == yes (
:: Make the output prettier, replacing \t with a tab and \n with a newline
bash -c "sed -i -e '/^.*<div id=\"store-area\".*$/s/\\\t/\t/g' -e '/^.*<div id=\"store-area\".*$/s/\\\n/\n/g' bin/FC_pregmod.html"
:: Revert ./src/init/storyInit.tw for next compilation
git checkout -- ./src/init/storyInit.tw
)
popd
PAUSE
#!/usr/bin/env python3
import fileinput
import re
import sys
WARNING = '\033[93m'
ENDC = '\033[0m'
def myprint(*args):
print(WARNING, fileinput.filename() + ":", ENDC,*args)
def yield_line_and_islastline(f):
global filename
global linenumber
try:
prevline = next(f)
filename = fileinput.filename()
linenumber = fileinput.filelineno()
except StopIteration:
return
for line in f:
yield (prevline, f.isfirstline())
filename = fileinput.filename()
linenumber = fileinput.filelineno()
prevline = line
yield prevline, True
pattern = re.compile(r'(<<(\/?) *(if|for|else|switch|case|replace|link)[^<>]*)')
tagfound = []
try:
for line, isLastLine in yield_line_and_islastline(fileinput.input()):
for (whole,end,tag) in re.findall(pattern,line):
if tag == "else" or tag == 'case':
if len(tagfound) == 0:
myprint("Found", tag, "but with no opening tag:")
myprint(" ", linenumber,":", whole)
fileinput.nextfile()
lasttag = tagfound[-1]
if (tag == "else" and lasttag["tag"] != "if") or (tag == "case" and lasttag["tag"] != "switch"):
myprint("Mismatched else: Opening tag was:")
myprint(" ",lasttag["linenumber"],":", lasttag["whole"])
myprint("But this tag was:")
myprint(" ",linenumber,":", whole)
fileinput.nextfile()
break
elif end != '/':
tagfound.append({"whole": whole, "linenumber":linenumber,"tag":tag})
else:
if len(tagfound) == 0:
myprint("Found closing tag but with no opening tag:")
myprint(" ", linenumber,":", whole)
fileinput.nextfile()
break
lasttag = tagfound.pop()
if lasttag["tag"] != tag:
myprint("Mismatched tag: Opening tag was:")
myprint(" ",lasttag["linenumber"],":", lasttag["whole"])
myprint("Closing tag was:")
myprint(" ",linenumber,":", whole)
fileinput.nextfile()
break
if isLastLine:
if len(tagfound) != 0:
myprint("End of file found but", len(tagfound), ("tag hasn't" if len(tagfound)==1 else "tags haven't"), "been closed:")
for tag in tagfound:
myprint(" ", tag["linenumber"],":", tag["whole"])
tagfound = []
except UnicodeDecodeError as e:
myprint(e)
print(" Hint: In Linux, you can get more details about Unicode errors by running:")
print(" isutf8", fileinput.filename())
print(" :Note it might be caused by ", filename)
......@@ -14,22 +14,8 @@ myprint() {
done
}
#check if java version should be run
if [[ "$1" == "java" ]]; then
java="true"
fi
#for everyone that wants to add new checks; just add them outside the java checks.
GREP="git grep -n --color"
if [[ ! "$java" ]]; then
# Check for missing right angle bracket: <</if>
$GREP "<</[^>]*>[^>]" -- 'src/*' | myprint "MissingClosingAngleBracket"
$GREP "<<[^>()]*>[^()<>"$'\r]*\r'"\?$" -- 'src/*' | myprint "MissingClosingAngleBracket"
# Check for missing left angle bracket: </if>>
$GREP "\([^<]\|^\)</\?\(if\|else\|case\|set\|print\|elseif\)" -- 'src/*' | myprint "MissingOpeningAngleBracket2"
fi
# Check for accidental assignment. e.g.: <<if $foo = "hello">>
$GREP "<<[ ]*if[^>=]*[^><\!=]=[^=][^>]*>>" -- 'src/*' | myprint "AccidentalAssignmentInIf"
# Check for accidental assignment. e.g.: <<elseif $foo = "hello">>
......@@ -51,29 +37,14 @@ $GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*)[^()]*)[^()<>]*>>" -- "src/*" | myprint
# Check for one closing bracket but two opening brackets. e.g.: <<if ((foo)>>
$GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*([^()]*)[^()<>]*>>" -- "src/*" | myprint "MissingClosingBracket2"
$GREP -e "<<.*[(][^<>)]*[(][^<>)]*)\?[^<>)]*>>" -- "src/*" | myprint "MissingClosingBracket3"
if [[ ! "$java" ]]; then
# Check for missing >>. e.g.: <<if $foo
$GREP "<<[^<>]*[^,\"\[{"$'\r]\r'"\?$" -- 'src/*' | myprint "MissingClosingAngleBrackets"
# Check for too many <<<. e.g.: <<</if>>
$GREP "<<<[^<>]*[<>]\?[^<>]*>>" -- "src/*.tw" | myprint "TooManyAngleBrackets"
fi
# Check for too many >>>. e.g.: <</if>>>
$GREP "<<[^<>]*[<>]\?[^<>]*>>>" -- "src/*.tw" | myprint "TooManyAngleBrackets"
# Check for wrong capitalization on 'activeslave' and other common typos
$GREP -e "\$act" --and --not -e "\$\(activeSlave\|activeChild\|activeArcology\|activeStandard\|activeOrgan\|activeLimbs\|activeUnits\|activeCanine\|activeHooved\|activeFeline\|activeLurcher\)" -- "src/*" | myprint "WrongCapitilization"
if [[ ! "$java" ]]; then
$GREP "\(csae\|[a-z] She \|attepmts\|youreslf\|advnaces\|canAcheive\|setBellySize\|SetbellySize\|setbellySize\|bellypreg\|pregBelly\|bellyimplant\|bellyfluid\|pronounCaps\|carress\|hormonebalance\|fetishknown\)" -- 'src/*' | myprint "SpellCheck"
$GREP "\(recieve\|recieves\)" -- 'src/*' | myprint "PregmodderCannotSpellReceive"
$GREP "\$slave\[" -- 'src/*' | myprint "ShouldBeSlaves"
fi
# Check for strange spaces e.g. $slaves[$i]. lips
$GREP "\$slaves\[\$i\]\. " -- 'src/*' | myprint "MissingPropertyAfterSlaves"
# Check using refreshmentType instead of refreshment
$GREP "\$PC.refreshmentType[^ =]" -- 'src/*' | grep -v src/events/intro/introSummary.tw | myprint "ShouldBeRefreshment"
if [[ ! "$java" ]]; then
# Check, e.g., <<//if>>
$GREP "<</[a-zA-Z]*[^a-zA-Z<>]\+[a-zA-Z]*>>" -- 'src/*' | myprint "DoubleSlash"
fi
# Check, e.g. <<else $foo==4
$GREP "<<else >\?[^>]" -- 'src/*' | myprint "ShouldBeElseIf"
# Check, e.g., =to
......@@ -140,22 +111,9 @@ $GREP -i "non.lethal" -- 'src/*' | myprint "ShouldBeNonlethal"
(
cd src/
if [[ ! "$java" ]]; then
# Check that we do not have any variables that we use only once. e.g. $onlyUsedOnce
# Ignore *Nationalities
cat $(find . -name "*.tw" ) | tr -c '$a-zA-Z' '\n' | sed -n '/^[$]/p' | grep -v "Nationalities" | sort | uniq -u | sed 's/^[$]/-e[$]/' | sed 's/$/\\\\W/' | xargs -r git grep -n --color | myprint "OnlyUsedOnce"
cat $(find . -name "*.tw" ) | tr -c '.$a-zA-Z[]_' '\n' | sed 's/SugarCube\.State\.variables\./$/g' | sed -n -e 's/^[$]\(PC\|activeSlave\|\(slaves\|tanks\)\[[^]]*\]*\)[.]\([a-zA-Z]\+\).*$/[.]\3/p' | sort | uniq -u |sed 's/^\(.*\)$/-e\1\\\\\b/' | xargs -r git grep -n --color | myprint "SlaveAttributeUsedOnce"
fi
$GREP "\$\(PC\|activeSlave\|slaves\|tanks\)[.][^a-zA-Z]" | myprint "UnexpectedCharAfterDot"
$GREP "\$\(PC\|activeSlave\|slaves\|tanks\)[.][^a-zA-Z]" | myprint "UnexpectedCharAfterDot"
)
# Check that all the tags are properly opened and closed
if [[ "$java" ]]; then
java -jar devTools/javaSanityCheck/SanityCheck.jar # and all the excluded stuff
else
git ls-files "src/*.tw" | xargs -d '\n' ./devTools/check.py
fi
# Check that all the tags are properly opened and closed & a lot of other stuff
java -jar devTools/javaSanityCheck/SanityCheck.jar
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment