inheritance-lookup-seenats.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 execTest(thefile, compilerPath, silent):
  14. '''return number of successes'''
  15. symbols, ok = testfuncs.buildAndGetSymbols(thefile, compilerPath, silent)
  16. # check the specific stuff we want to verify with this test
  17. if ok:
  18. try:
  19. ok = symbols["Symbol '/A/A'"]['kind'] == 'Class'
  20. ok2 = symbols["Symbol '/A/A'"]["references"] == None # no references for A::A
  21. ok3 = len(symbols["Symbol '/A'"]["references"]) == 1
  22. ok4 = symbols["Symbol '/A'"]["references"][0]["line"] == 11 # /A has one ref in the baselist of B line 11
  23. if not silent:
  24. if not ok:
  25. print (fg.RED+ "Couldn't verify symbol /A/A is a Class"+ style.RESET_ALL)
  26. if not ok2:
  27. print (fg.RED+ "Couldn't verify symbol /A/A is ot referenced"+ style.RESET_ALL)
  28. if not ok3:
  29. print (fg.RED+ "Couldn't verify /A has 1 reference"+ style.RESET_ALL)
  30. if not ok4:
  31. print (fg.RED+ "Couldn't verify /A's seenat is at line 11"+ style.RESET_ALL)
  32. ok = ok and ok2 and ok3 and ok4
  33. except Exception as e:
  34. print (fg.RED+ "Err: dumpsym didn't match expectations"+ style.RESET_ALL, e)
  35. ok = False
  36. return ok
  37. result = 0 # to define for sub-tests
  38. resultFailed = 0
  39. def doTests(compiler, silent, azdxcpath):
  40. global result
  41. global resultFailed
  42. # Working directory should have been set to this script's directory by the calling parent
  43. # You can get it once doTests() is called, but not during initialization of the module,
  44. # because at that time it will still be set to the working directory of the calling script
  45. workDir = os.getcwd()
  46. if execTest(os.path.join(workDir, "inheritance-lookup-seenats.azsl"), compiler, silent): result += 1
  47. else: resultFailed += 1
  48. if __name__ == "__main__":
  49. print ("please call from testapp.py")