typeof-vardecl-udt.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. from clr import *
  11. sys.path.append("..")
  12. import testfuncs
  13. def test(thefile, compilerPath, silent):
  14. '''return number of successes'''
  15. symbols, ok = testfuncs.buildAndGetSymbols(thefile, compilerPath, silent)
  16. if ok:
  17. try:
  18. ok = symbols["Symbol '/g_s'"]['kind'] == 'Variable'
  19. ok = ok and symbols["Symbol '/g_s'"]['type']['core']['name'] == '/S'
  20. if not silent:
  21. if not ok:
  22. print (fg.RED+ "ERR: g_s type could not be validated"+ style.RESET_ALL)
  23. else:
  24. print (style.BRIGHT+ "OK! "+ style.RESET_ALL)
  25. except Exception as e:
  26. print (fg.RED+ "Err: Parsed --dumpsym may lack some expected keys"+ style.RESET_ALL, e)
  27. return ok
  28. result = 0 # to define for sub-tests
  29. resultFailed = 0
  30. def doTests(compiler, silent, azdxcpath):
  31. global result
  32. global resultFailed
  33. # Working directory should have been set to this script's directory by the calling parent
  34. # You can get it once doTests() is called, but not during initialization of the module,
  35. # because at that time it will still be set to the working directory of the calling script
  36. workDir = os.getcwd()
  37. if test(os.path.join(workDir, "../Semantic/combined-vardecl-udt.azsl"), compiler, silent): result += 1
  38. else: resultFailed += 1
  39. if __name__ == "__main__":
  40. print ("please call from testapp.py")