LinkRunDir 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #Assembles, links and run tests of FreePascal
  2. #Param 1, the directory with the tests to perform.
  3. #Note versions can be either 2 or 3 fields, e g 1.1 1.0.10
  4. Export nrOfSucceded
  5. Export nrOfFailed
  6. #Iterate through tests
  7. Set Exit 0 # To handle the case, in the for stmt, when there is no match
  8. For sourceWithExt In {1}tÅ.log #only test files, which begins with a 't'
  9. Set Exit 1 #Revert error handling
  10. (Evaluate "{sourceWithExt}" =~ /(([Â.])*)¨1Å/) > Dev:Null
  11. Set apppath {¨1}
  12. (Evaluate {apppath} =~ /Å:([Â:]*)¨1/) > Dev:Null
  13. Set appname {¨1}
  14. If `Exists {apppath}.elg`
  15. Continue
  16. End
  17. Set testdirectives ""
  18. Set testdirectives "`StreamEdit {apppath}.pp ¶
  19. -d -e "/¶{[ ¶t]*(%Å*)¨1[ ¶t]*¶}/ Print ¨1"`" > Dev:Null
  20. Echo "============================================================="
  21. If {debugverbose}
  22. Echo {testdirectives}
  23. End
  24. If `Evaluate "{testdirectives}" =~ /Å%CPU=([,_0-9A-Za-z]*)¨1Å/`
  25. If `Evaluate "{¨1}" !~ /ÅpowerpcÅ/`
  26. Echo Skipped {apppath}. Test only for CPU: "{¨1}"
  27. Continue
  28. End
  29. End
  30. If `Evaluate "{testdirectives}" =~ /Å%SKIPCPU=([,_0-9A-Za-z]*)¨1Å/`
  31. If `Evaluate "{¨1}" =~ /ÅpowerpcÅ/`
  32. Echo Skipped {apppath}. Test not for CPU: {¨1}
  33. Continue
  34. End
  35. End
  36. If `Evaluate "{testdirectives}" =~ /Å%TARGET=([,_0-9A-Za-z]*)¨1Å/`
  37. If `Evaluate "{¨1}" !~ /ÅmacosÅ/`
  38. Echo Skipped {apppath}. Test only for target: {¨1}
  39. Continue
  40. End
  41. End
  42. If `Evaluate "{testdirectives}" =~ /Å%SKIPTARGET=([,_0-9A-Za-z]*)¨1Å/`
  43. If `Evaluate "{¨1}" =~ /ÅmacosÅ/`
  44. Echo Skipped {apppath}. Test not for target: {¨1}
  45. Continue
  46. End
  47. End
  48. If `Evaluate "{testdirectives}" =~ /Å%VERSION=([0-9.]*)¨1Å/`
  49. Set minver {¨1}
  50. If `Evaluate "{minver}" !~ /([0-9]*)¨1.([0-9]*)¨2.([0-9]*)¨3/`
  51. If `Evaluate "{minver}" !~ /([0-9]*)¨1.([0-9]*)¨2/`
  52. Echo Skipped {apppath}. Error in version no: {minver}
  53. Continue
  54. Else
  55. Set ¨3 0
  56. End
  57. End
  58. If Â(({cv1}> {¨1}) || (({cv1}=={¨1}) && ¶
  59. (({cv2}> {¨2}) || (({cv2}=={¨2}) && ¶
  60. ({cv3}>={¨3})))))
  61. Echo Skipped {apppath}. Compiler too old, test requires at least: {minver}
  62. Continue
  63. End
  64. End
  65. If `Evaluate "{testdirectives}" =~ /Å%MAXVERSION=([0-9.]*)¨1Å/`
  66. Set maxver {¨1}
  67. If `Evaluate "{maxver}" !~ /([0-9]*)¨1.([0-9]*)¨2.([0-9]*)¨3/`
  68. If `Evaluate "{maxver}" !~ /([0-9]*)¨1.([0-9]*)¨2/`
  69. Echo Skipped {apppath}. Error in version no: {maxver}
  70. Continue
  71. Else
  72. Set ¨3 0
  73. End
  74. End
  75. If Â(({cv1}< {¨1}) || (({cv1}=={¨1}) && ¶
  76. (({cv2}< {¨2}) || (({cv2}=={¨2}) && ¶
  77. ({cv3}<={¨3})))))
  78. Echo Skipped {apppath}. Compiler too new, test requires no more than: {maxver}
  79. Continue
  80. End
  81. End
  82. If `Evaluate "{testdirectives}" =~ /Å%NOTE=([Â%]*)¨1Å/`
  83. Echo Note: {¨1}
  84. End
  85. # Start compiling
  86. Echo Start compiling "{apppath}"
  87. Set Exit 0
  88. SetFile -c 'MPS ' -t 'TEXT' {appname}_ppas
  89. If {debugverbose}
  90. Execute {appname}_ppas | Tee {apppath}.log
  91. Else
  92. Execute {appname}_ppas > {apppath}.log
  93. End
  94. If "{Status}" != 0
  95. Set Exit 1
  96. Echo Compiling of "{apppath}" failed
  97. Set -e nrOfFailed `Evaluate {nrOfFailed}+1`
  98. If {debugverbose}
  99. StreamEdit {apppath}.pp -d -e "1,15 Print"
  100. End
  101. Continue
  102. Else
  103. Set Exit 1
  104. Echo Compiling of "{apppath}" succeded
  105. End
  106. If `Evaluate "{testdirectives}" =~ /Å%NORUNÅ/`
  107. Echo Skipped running of {apppath} due to option NORUN
  108. Continue
  109. End
  110. If `Evaluate "{testdirectives}" =~ /Å%INTERACTIVEÅ/`
  111. Echo Skipped running of {apppath} due to option INTERACTIVE
  112. Continue
  113. End
  114. If Not `Exists {apppath}`
  115. # Should this be counted as a failed test ?
  116. # Or perhaps files is to be checked for if they are units ?
  117. Echo Skipped running du to non existing executable
  118. Continue
  119. End
  120. If 1
  121. If `Evaluate "{testdirectives}" =~ /Å%RESULT=([0-9]*)¨1Å/`
  122. Set expectedresult {¨1}
  123. Else
  124. Set expectedresult 0
  125. End
  126. #Execute test program
  127. Echo "Xxx" > "{apppath}.elg" #Needed, to continue if test app crashes
  128. Set Exit 0
  129. If {debugverbose}
  130. {apppath} | Tee {apppath}.elg
  131. Else
  132. {apppath} > {apppath}.elg
  133. End
  134. Set actualresult {Status}
  135. Set Exit 1
  136. If {actualresult} != 0
  137. Echo Running of "{apppath}" failed
  138. Else
  139. Echo Running of "{apppath}" succeded
  140. End
  141. Echo "Exit code was {actualresult}, expected {expectedresult}"
  142. If "{actualresult}" != "{expectedresult}"
  143. Echo -n "Failed to run {apppath}¶r" >> log #¶r gives a linefeed
  144. Echo Failed test "{apppath}"
  145. Set -e nrOfFailed `Evaluate {nrOfFailed}+1`
  146. If {debugverbose}
  147. StreamEdit {apppath}.pp -d -e "1,15 Print"
  148. End
  149. Else
  150. Echo -n "Successfully run {apppath}¶r" >> log #¶r gives a linefeed
  151. Echo Succeded test "{apppath}"
  152. Set -e nrOfSucceded `Evaluate {nrOfSucceded}+1`
  153. End
  154. End
  155. Set Exit 0 # To handle the case, in the for stmt, when there is no match
  156. End
  157. Set Exit 1 #Revert error handling