mae-methodcall.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. sys.path.append("..")
  11. sys.path.append("../..")
  12. from clr import *
  13. import testfuncs
  14. def verifyOptionCosts(thefile, compilerPath, silent):
  15. j, ok = testfuncs.buildAndGetJson(thefile, compilerPath, silent, ["--options"])
  16. if ok:
  17. predicates = []
  18. # check all references of func()
  19. predicates.append(lambda: j["ShaderOptions"][0]["name"] == "o")
  20. predicates.append(lambda: j["ShaderOptions"][0]["costImpact"] == 54)
  21. if not silent: print (fg.CYAN+ style.BRIGHT+ "option expected cost check..."+ style.RESET_ALL)
  22. ok = testfuncs.verifyAllPredicates(predicates, j)
  23. return ok
  24. result = 0 # to define for sub-tests
  25. resultFailed = 0
  26. def doTests(compiler, silent, azdxcpath):
  27. global result
  28. global resultFailed
  29. # Working directory should have been set to this script's directory by the calling parent
  30. # You can get it once doTests() is called, but not during initialization of the module,
  31. # because at that time it will still be set to the working directory of the calling script
  32. workDir = os.getcwd()
  33. if verifyOptionCosts(os.path.join(workDir, "mae-methodcall.azsl"), compiler, silent): result += 1
  34. else: resultFailed += 1
  35. if __name__ == "__main__":
  36. print ("please call from testapp.py")