#############################################################################
##
#W  testinst.g          GAP 4 package `atlasrep'                Thomas Breuer
##
#H  @(#)$Id: testinst.g,v 1.7 2003/09/25 07:44:35 gap Exp $
##
#Y  Copyright (C)  2002,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
##
##  This file contains those tests for the AtlasRep package that are
##  recommended for being executed after the package has been installed.
##  Currently just a few file transfers are tried in the case that
##  `AtlasOfGroupRepresentationsInfo.remote' is `true',
##  and `AtlasOfGroupRepresentationsTestTableOfContentsRemoteUpdates' is
##  called.
#1
##  For checking the installation of the package, you should start {\GAP},
##  load the package (see~"Loading the AtlasRep Package"), and then call
##  \begintt
##  gap> ReadPackage( "atlasrep", "tst/testinst.g" );
##  \endtt
##  If the installation is o.k.~then the {\GAP} prompt appears without
##  anything else being printed;
##  otherwise the output lines tell you what should be changed.
##
##  More testfiles are available in the `tst' directory of the package
##  (see~"Sanity Checks for the Atlas of Group Representations" for details).
##

if AtlasOfGroupRepresentationsInfo.remote = true then

  wget:= Filename( DirectoriesSystemPrograms(), "wget" );
  wget:= ( wget <> fail and IsExecutableFile( wget ) );
  perl:= Filename( DirectoriesSystemPrograms(), "perl" );
  perl:= ( perl <> fail and IsExecutableFile( perl ) );

  if   not ( wget or perl ) then
    # None of the alternatives will work.
    Print( "#I  Package `atlasrep':  ",
           "The system programs `wget' and `perl' are not available,\n",
           "#I  `AtlasOfGroupRepresentationsInfo.remote' ",
           "should be set to `false'.\n" );
  elif   ( not wget )
     and IsBound( AtlasOfGroupRepresentationsInfo.wget )
     and AtlasOfGroupRepresentationsInfo.wget = true then
    # `wget' would be preferable but is not available.
    Print( "#I  Package `atlasrep':  ",
           "The system program `wget' is not available,\n",
           "#I  `AtlasOfGroupRepresentationsInfo.wget' ",
           "should not be set to `true'.\n" );
  elif   ( not perl )
     and (    not IsBound( AtlasOfGroupRepresentationsInfo.wget )
           or AtlasOfGroupRepresentationsInfo.wget <> true ) then
    # `perl' would be preferable but is not available.
    Print( "#I  Package `atlasrep':  ",
           "The system program `perl' is not available,\n",
           "#I  try to set `AtlasOfGroupRepresentationsInfo.wget' ",
           "to `true'.\n" );
  else
    # The preferable program is available.

    # Test whether the data directories are writable.
    dir:= DirectoriesPackageLibrary( "atlasrep", "dataword" );
    if not IsWritableFile( Filename( dir, "" ) ) then
      Print( "#I  Package `atlasrep':  ",
             "The package directory `dataword' is not writable.\n" );
    fi;
    dir:= DirectoriesPackageLibrary( "atlasrep", "datagens" );
    if not IsWritableFile( Filename( dir, "" ) ) then
      Print( "#I  Package `atlasrep':  ",
             "The package directory `datagens' is not writable.\n" );
    fi;

    # Test transferring group generators in {\MeatAxe} format.
    # (Remove some files if necessary and access them again.)
    id1:= OneAtlasGeneratingSet( "A5", Characteristic, 2 );
    if id1 <> fail then
      id1:= id1.identifier;
      for file in List( id1[2], name -> Filename( dir, name ) ) do
        RemoveFile( file );
      od;
    fi;
    id2:= OneAtlasGeneratingSet( "A5", Characteristic, 0 );
    if id2 <> fail then
      id2:= id2.identifier;
      RemoveFile( FilenameAtlas( "datagens", "A5", id2[2] ) );
    fi;
    if    id1 <> AtlasGenerators( id1 ).identifier
       or id2 <> AtlasGenerators( id2 ).identifier then
      Print( "#I  Package `atlasrep':  ",
             "Transferring data files does not work.\n",
             "#I  Perhaps `AtlasOfGroupRepresentationsInfo.remote' ",
             "should be set to `false'.\n" );
    fi;

    # Print information about data files to be removed/updated.
    # (This is for those who had installed an earlier `atlasrep' version.)
    AtlasOfGroupRepresentationsTestTableOfContentsRemoteUpdates();
  fi;

fi;


#############################################################################
##
#E

