emission-full.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 re
  11. import testfuncs
  12. result = 0 # to define for sub-tests
  13. resultFailed = 0 # to define for sub-tests
  14. # delete artefacts from previous compilations
  15. def cleanArtefacts(workDir):
  16. if os.path.exists("simple-surface.hlsl"): os.remove("simple-surface.hlsl")
  17. if os.path.exists("simple-surface.ia.json"): os.remove("simple-surface.ia.json")
  18. if os.path.exists("simple-surface.om.json"): os.remove("simple-surface.om.json")
  19. if os.path.exists("simple-surface.srg.json"): os.remove("simple-surface.srg.json")
  20. if os.path.exists("simple-surface.options.json"): os.remove("simple-surface.options.json")
  21. if os.path.exists("simple-surface.bindingdep.json"): os.remove("simple-surface.bindingdep.json")
  22. def doTests(compiler, silent, az3rdParty):
  23. global result
  24. global resultFailed
  25. # Working directory should have been set to this script's directory by the calling parent
  26. # You can get it once doTests() is called, but not during initialization of the module,
  27. # because at that time it will still be set to the working directory of the calling script
  28. workDir = os.getcwd()
  29. cleanArtefacts(workDir)
  30. if testfuncs.buildAndGet("simple-surface.azsl", compiler, silent, ["-o", "simple-surface.hlsl", "--full"]) : result += 1
  31. else: resultFailed += 1
  32. # check existence of HLSL output file
  33. if os.stat("simple-surface.hlsl").st_size != 0 : result += 1
  34. else: resultFailed += 1
  35. # check existence of JSON output files
  36. if os.stat("simple-surface.ia.json").st_size != 0 : result += 1
  37. else: resultFailed += 1
  38. if os.stat("simple-surface.om.json").st_size != 0 : result += 1
  39. else: resultFailed += 1
  40. if os.stat("simple-surface.srg.json").st_size != 0 : result += 1
  41. else: resultFailed += 1
  42. if os.stat("simple-surface.options.json").st_size != 0 : result += 1
  43. else: resultFailed += 1
  44. if os.stat("simple-surface.bindingdep.json").st_size != 0 : result += 1
  45. else: resultFailed += 1
  46. cleanArtefacts(workDir)
  47. if __name__ == "__main__":
  48. print ("please call from testapp.py")