testfail.pp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {
  2. $Id$
  3. This file is part of the Free Pascal test suite.
  4. Copyright (c) 1999-2002 by the Free Pascal development team.
  5. Check if redir can use COMSPEC environment variable.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program dotest;
  13. uses
  14. dos,
  15. redir;
  16. Const
  17. FailName = 'fail';
  18. {$ifdef UNIX}
  19. ExeExt='';
  20. {$else UNIX}
  21. ExeExt='exe';
  22. {$endif UNIX}
  23. function ForceExtension(Const HStr,ext:String):String;
  24. {
  25. Return a filename which certainly has the extension ext
  26. }
  27. var
  28. j : longint;
  29. begin
  30. j:=length(Hstr);
  31. while (j>0) and (Hstr[j]<>'.') do
  32. dec(j);
  33. if j=0 then
  34. j:=255;
  35. if Ext<>'' then
  36. ForceExtension:=Copy(Hstr,1,j-1)+'.'+Ext
  37. else
  38. ForceExtension:=Copy(Hstr,1,j-1);
  39. end;
  40. procedure RunFail;
  41. var
  42. outname,
  43. TestExe : string;
  44. begin
  45. TestExe:=ForceExtension(FailName,ExeExt);
  46. TestExe:=FExpand(TestExe);
  47. ExecuteRedir(TestExe,'','','','');
  48. if (DosError<>0) or (ExecuteResult<>1) then
  49. writeln('exit code not returned correctly');
  50. end;
  51. begin
  52. if (paramcount>0) and (paramstr(1)='-x') then
  53. UseComSpec:=false
  54. else
  55. UseComSpec:=true;
  56. RunFail;
  57. end.
  58. {
  59. $Log$
  60. Revision 1.2 2003-04-29 21:12:17 pierre
  61. * win32 specific unit added
  62. Revision 1.1 2002/12/05 16:04:26 pierre
  63. * new files for checking if ComSpec returns error
  64. }