test_linkinfo.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. --
  2. -- tests/config/test_linkinfo.lua
  3. -- Test the config object's link target accessor.
  4. -- Copyright (c) 2012-2013 Jason Perkins and the Premake project
  5. --
  6. local p = premake
  7. local suite = test.declare("config_linkinfo")
  8. local config = p.config
  9. --
  10. -- Setup and teardown
  11. --
  12. local wks, prj
  13. function suite.setup()
  14. p.action.set("test")
  15. wks, prj = test.createWorkspace()
  16. kind "StaticLib"
  17. system "Windows"
  18. end
  19. local function prepare()
  20. local cfg = test.getconfig(prj, "Debug")
  21. return config.getlinkinfo(cfg)
  22. end
  23. --
  24. -- Directory should use targetdir() value if present.
  25. --
  26. function suite.directoryIsTargetDir_onTargetDir()
  27. targetdir "../bin"
  28. i = prepare()
  29. test.isequal("../bin", path.getrelative(os.getcwd(), i.directory))
  30. end
  31. --
  32. -- Shared library should use implibdir() if present.
  33. --
  34. function suite.directoryIsImpLibDir_onImpLibAndTargetDir()
  35. kind "SharedLib"
  36. targetdir "../bin"
  37. implibdir "../lib"
  38. i = prepare()
  39. test.isequal("../lib", path.getrelative(os.getcwd(), i.directory))
  40. end
  41. --
  42. -- Base name should use the project name by default.
  43. --
  44. function suite.basenameIsProjectName_onNoTargetName()
  45. i = prepare()
  46. test.isequal("MyProject", i.basename)
  47. end
  48. --
  49. -- Base name should use targetname() if present.
  50. --
  51. function suite.basenameIsTargetName_onTargetName()
  52. targetname "MyTarget"
  53. i = prepare()
  54. test.isequal("MyTarget", i.basename)
  55. end
  56. --
  57. -- Shared library should use implibname() if present.
  58. --
  59. function suite.basenameIsImplibName_onTargetName()
  60. kind "SharedLib"
  61. targetname "MyTarget"
  62. implibname "MyTargetImports"
  63. i = prepare()
  64. test.isequal("MyTargetImports", i.basename)
  65. end
  66. --
  67. -- Test library name formatting.
  68. --
  69. function suite.nameFormatting_onWindows()
  70. system "Windows"
  71. i = prepare()
  72. test.isequal("MyProject.lib", i.name)
  73. end
  74. function suite.nameFormatting_onLinux()
  75. system "Linux"
  76. i = prepare()
  77. test.isequal("libMyProject.a", i.name)
  78. end
  79. --
  80. -- The import library extension should not change if the a
  81. -- custom target extension is set.
  82. --
  83. function suite.impLibExtensionUnmodified_OnCustomTargetExt()
  84. system "windows"
  85. kind "SharedLib"
  86. targetextension ".mil"
  87. i = prepare()
  88. test.isequal("MyProject.lib", i.name)
  89. end