Skip to content

Commit

Permalink
Merge pull request #18141 from PsiOmegaDelta/170807-KeepYourArtsyAmbi…
Browse files Browse the repository at this point in the history
…tionsAway

Adds a test to check icon state limits.
  • Loading branch information
mustafakalash authored Aug 12, 2017
2 parents e95e2ba + aa18640 commit 339ff09
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: generic
sudo: false
dist: trusty

env:
global:
Expand All @@ -26,6 +27,7 @@ addons:
- libc6-i386
- libgcc1:i386
- libstdc++6:i386
- oracle-java8-set-default

script:
- test/run-test.sh
Binary file removed icons/misc/radar.dmi
Binary file not shown.
Binary file modified icons/obj/pipes/large.dmi
Binary file not shown.
Binary file modified icons/obj/statue.dmi
Binary file not shown.
Binary file modified icons/obj/status_display.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function run_code_tests {
run_test "check changelog example unchanged" "md5sum -c - <<< '79e058ac02ed52aad99a489ab4c8f75b *html/changelogs/example.yml'"
run_test "check tags" "python tools/TagMatcher/tag-matcher.py ."
run_test "check punctuation" "python tools/PunctuationChecker/punctuation-checker.py ."
run_test "check icon state limit" "python tools/dmitool/check_icon_state_limit.py ."
run_test_ci "check changelog builds" "python tools/GenerateChangelog/ss13_genchangelog.py html/changelog.html html/changelogs"
}

Expand Down
29 changes: 29 additions & 0 deletions tools/dmitool/check_icon_state_limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import argparse, re, sys
from os import path, walk
import dmitool # This import is why this script is here. If someone can import this file cleanly from [repo root]/test/ instead, feel free

opt = argparse.ArgumentParser()
opt.add_argument('dir', help='The directory to scan for *.dmi files with an excess number of icon states.')
args = opt.parse_args()

if(not path.isdir(args.dir)):
print('Not a directory')
sys.exit(1)

bad_dmi_files = []

# This section parses all *.dmi files in the given directory, recursively.
for root, subdirs, files in walk(args.dir):
for filename in files:
if filename.endswith('.dmi'):
file_path = path.join(root, filename)
dmi_info = dmitool.info(file_path)
number_of_icon_states = len(dmi_info["states"])
print("{0} - {1}".format(file_path, number_of_icon_states))
if number_of_icon_states > 512:
bad_dmi_files.append((file_path, number_of_icon_states))

if len(bad_dmi_files) > 0:
for dmi_path, icon_states in bad_dmi_files:
print("{0} had too many icon states. {1}/512.".format(dmi_path, icon_states))
sys.exit(1)
2 changes: 1 addition & 1 deletion tools/dmitool/dmitool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from subprocess import Popen, PIPE

_JAVA_PATH = ["java"]
_DMITOOL_CMD = ["-jar", "dmitool.jar"]
_DMITOOL_CMD = ["-jar", os.path.dirname(os.path.realpath(__file__)) + "/dmitool.jar"]


def _dmitool_call(*dmitool_args, **popen_args):
Expand Down

0 comments on commit 339ff09

Please sign in to comment.