test_keywords.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --
  2. -- tests/test_keywords.lua
  3. -- Automated test suite for configuration block keyword filtering.
  4. -- Copyright (c) 2008, 2009 Jason Perkins and the Premake project
  5. --
  6. T.keywords = { }
  7. local suite = T.keywords
  8. --
  9. -- Keyword escaping tests
  10. --
  11. function suite.escapes_special_chars()
  12. test.isequal("%.%-", path.wildcards(".-"))
  13. end
  14. function suite.escapes_star()
  15. test.isequal("vs[^/]*", path.wildcards("vs*"))
  16. end
  17. function suite.escapes_star_star()
  18. test.isequal("Images/.*%.bmp", path.wildcards("Images/**.bmp"))
  19. end
  20. --
  21. -- Keyword matching tests
  22. --
  23. function T.keywords.matches_simple_strings()
  24. test.istrue(premake.iskeywordmatch("debug", { "debug", "windows", "vs2005" }))
  25. end
  26. function T.keywords.match_files_with_simple_strings()
  27. test.isfalse(premake.iskeywordmatch("release", { "debug", "windows", "vs2005" }))
  28. end
  29. function T.keywords.matches_with_patterns()
  30. test.istrue(premake.iskeywordmatch("vs20.*", { "debug", "windows", "vs2005" }))
  31. end
  32. function T.keywords.match_fails_with_not_term()
  33. test.isfalse(premake.iskeywordmatch("not windows", { "debug", "windows", "vs2005" }))
  34. end
  35. function T.keywords.match_ok_with_not_term()
  36. test.istrue(premake.iskeywordmatch("not linux", { "debug", "windows", "vs2005" }))
  37. end
  38. function T.keywords.match_ok_with_first_or()
  39. test.istrue(premake.iskeywordmatch("windows or linux", { "debug", "windows", "vs2005" }))
  40. end
  41. function T.keywords.match_ok_with_first_or()
  42. test.istrue(premake.iskeywordmatch("windows or linux", { "debug", "linux", "vs2005" }))
  43. end
  44. function T.keywords.match_ok_with_not_and_or()
  45. test.istrue(premake.iskeywordmatch("not macosx or linux", { "debug", "windows", "vs2005" }))
  46. end
  47. function T.keywords.match_fail_with_not_and_or()
  48. test.isfalse(premake.iskeywordmatch("not macosx or windows", { "debug", "windows", "vs2005" }))
  49. end
  50. function T.keywords.match_ok_required_term()
  51. test.istrue(premake.iskeywordsmatch({ "debug", "hello.c" }, { "debug", "windows", "vs2005", required="hello.c" }))
  52. end
  53. function T.keywords.match_fail_required_term()
  54. test.isfalse(premake.iskeywordsmatch({ "debug" }, { "debug", "windows", "vs2005", required="hello.c" }))
  55. end