emission-tester.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Copyright (c) Contributors to the Open 3D Engine Project.
  5. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. SPDX-License-Identifier: Apache-2.0 OR MIT
  7. """
  8. import sys
  9. import os
  10. import platform
  11. sys.path.append("..")
  12. from clr import *
  13. import os.path
  14. from os.path import join, normpath, basename
  15. import testhelper
  16. result = 0 # to define for sub-tests
  17. resultFailed = 0
  18. def doTests(compiler, silent, azdxcpath):
  19. global result
  20. global resultFailed
  21. # Working directory should have been set to this script's directory by the calling parent
  22. # You can get it once doTests() is called, but not during initialization of the module,
  23. # because at that time it will still be set to the working directory of the calling script
  24. workDir = os.getcwd().replace('\\', '/')
  25. for base, dirs, files in os.walk(os.path.join(workDir, "../Emission/")):
  26. for f in files:
  27. if f.endswith(".azsl"):
  28. subdirName = os.path.basename(base)
  29. completePath = os.path.join(base, f)
  30. if subdirName != "AsError":
  31. success = testhelper.verifyEmissionPatterns(completePath, compiler, silent, []) > 0
  32. else:
  33. success = testhelper.compileAndExpectError(completePath, compiler, silent, []) > 0
  34. if success:
  35. result += 1
  36. else:
  37. resultFailed += 1
  38. if not silent: print(fg.RED + style.BRIGHT + "failed " + style.NORMAL + f + fg.RESET)
  39. testhelper.printFailedTestList(silent)
  40. if __name__ == "__main__":
  41. print ("please call from testapp.py")