!******************************************************************************!
! Contains interactive test cases for ensuring NMSTART
! accepts and utilizes various OS-level environment variables correctly.
! The first test ensures proper usage of NMHISTORY_DIR for overriding
! location of NMSF files.
!
! Note: An invalid NMHISTORY_DIR should force NMSTART to default to the user's
! home directory for NMSF files.
!
! @bug      1368 Need ability to override NMSF file location
! @author:  Chris Simons
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

  if interAct then

    pipe init
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "Test MACRO"
      gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft
      gcontrol label panellabel "Instructions"
      gcontrol panel apanel "Instructions" 650 650

      shellgui/attach/bg/win=apanel

      say ""
      say "To test NMHISTORY_DIR:"
      say " (1) Open a new OS shell terminal."
      say " (2) Navigate to $NMROOT (or have $NMROOT in your CLASSPATH)"
      say " (3) Apply the following use cases (4, 5, and 6):
      say " (4) Test: -- Do not set NMHISTORY_DIR --"
      say " (4a) Run NMSTART and then NM."
      say " (4b) res env.msf and ensure physical NMSF file is saved to directory."
      say " (4c) The env.msf path should include the user's home directory."
      say " (4d) Run NMEND to clear session."
      say " (5) Test: -- Set an invalid NMHISTORY_DIR --"
      say " (5a) Unix:    setenv NMHISTORY_DIR /dirdoesnotexist
      say " (5a) Bash:    set NMHISTORY_DIR /dirdoesnotexist
      say " (5a) Windows: set NMHISTORY_DIR=C:\dirdoesnotexist
      say " (5b) Run NMSTART.  Should see a warning about NMHISTORY_DIR.
      say " (5c) Run NM."
      say " (5d) res env.msf and ensure physical NMSF file is saved to directory."
      say " (5e) The env.msf path should include the user's home directory."
      say " (5f) Run NMEND to clear session."
      say " (6) Test: -- Set a valid NMHISTORY_DIR --"
      say " (6a) Unix:    setenv NMHISTORY_DIR /midas/data1
      say " (6a) Bash:    set NMHISTORY_DIR /midas/data1
      say " (6a) Windows: set NMHISTORY_DIR=C:\midas\data1
      say " (6b) Run NMSTART.  Should see a message about setting NMHISTORY_DIR.
      say " (6c) Run NM."
      say " (6d) res env.msf and ensure physical NMSF file is saved to directory."
      say " (6e) The env.msf path should include the new/valid NMHISTORY_DIR."
      say " (6f) Run NMEND to clear session."
      say " (7) Close the window and click 'Pass' or 'Fail' on this macro."
      say ""
  pipe off

  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return