Ticket #12249: 12249_test_sage_run.patch

File 12249_test_sage_run.patch, 3.7 KB (added by jdemeyer, 8 years ago)
  • sage/tests/cmdline.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1325586347 -3600
    # Node ID 3b86f642a312bdc7deae4212fc816eb60003fc0b
    # Parent  b72663c760492cc8c360d328a6d370c8f88d2069
    Test sage-run
    
    diff --git a/sage/tests/cmdline.py b/sage/tests/cmdline.py
    a b  
    33do something.
    44
    55We test the following command line options:
     6
     7test.py
     8/path/to/test.py
     9test.sage
     10/path/to/test.sage
    611--advanced
    712--branch
    813-c
     
    8186        ...
    8287        RuntimeError: timeout in test_executable()
    8388
    84     TESTS::
     89    TESTS:
     90
     91    Run Sage itself with various options::
    8592   
    8693        sage: (out, err, ret) = test_executable(["sage"])
    8794        sage: out.find(version()) >= 0
     
    112119        0
    113120   
    114121        sage: (out, err, ret) = test_executable(["sage", "-c", "print 3^33"])
    115         sage: out.find("5559060566555523\n") >= 0
    116         True
     122        sage: print out
     123        5559060566555523
    117124        sage: err
    118125        ''
    119126        sage: ret
    120127        0
    121128   
    122129        sage: (out, err, ret) = test_executable(["sage", "--min", "-c", "print 3^33"])
    123         sage: out.find("5559060566555523\n") >= 0
     130        sage: print out
     131        5559060566555523
     132        sage: err
     133        ''
     134        sage: ret
     135        0
     136
     137        sage: (out, err, ret) = test_executable(["sage", "--startuptime"])
     138        sage: out.find("sage.all: ") >= 0
    124139        True
    125140        sage: err
    126141        ''
    127142        sage: ret
    128143        0
     144
     145    Test help::
    129146   
    130147        sage: (out, err, ret) = test_executable(["sage", "-h"])
    131148        sage: out.find("Optional arguments:") >= 0
     
    151168        sage: ret
    152169        0
    153170   
     171    Basic information about the Sage installation::
     172   
    154173        sage: (out, err, ret) = test_executable(["sage", "-v"])
    155174        sage: out.find(version()) >= 0
    156175        True
     
    175194        sage: ret
    176195        0
    177196   
    178         sage: (out, err, ret) = test_executable(["sage", "--startuptime"])
    179         sage: out.find("sage.all: ") >= 0
    180         True
     197    Test ``sage-run`` on a Python file, both with an absolute and with a relative path::
     198
     199        sage: import tempfile
     200        sage: F = tempfile.NamedTemporaryFile(suffix=".py")
     201        sage: F.write("print 3^33\n")
     202        sage: F.flush()
     203        sage: (out, err, ret) = test_executable(["sage", F.name])
     204        sage: print out
     205        34
    181206        sage: err
    182207        ''
    183208        sage: ret
    184209        0
    185    
     210        sage: (dir,filename) = os.path.split(F.name)
     211        sage: os.chdir(dir)
     212        sage: (out, err, ret) = test_executable(["sage", filename])
     213        sage: print out
     214        34
     215        sage: err
     216        ''
     217        sage: ret
     218        0
     219        sage: del F   # Close and delete the file
     220
     221    The same as above, but now with a ``.sage`` file.  This indirectly
     222    also tests the preparser::
     223
     224        sage: import tempfile
     225        sage: F = tempfile.NamedTemporaryFile(suffix=".sage")
     226        sage: py_file = F.name[:-5] + ".py"  # Will be created by the preparser
     227        sage: F.write("k.<a> = GF(5^3); print a^124\n")
     228        sage: F.flush()
     229        sage: (out, err, ret) = test_executable(["sage", F.name])
     230        sage: os.unlink(py_file)
     231        sage: print out
     232        1
     233        sage: err
     234        ''
     235        sage: ret
     236        0
     237        sage: (dir,filename) = os.path.split(F.name)
     238        sage: os.chdir(dir)
     239        sage: (out, err, ret) = test_executable(["sage", filename])
     240        sage: os.unlink(py_file)
     241        sage: print out
     242        1
     243        sage: err
     244        ''
     245        sage: ret
     246        0
     247        sage: del F   # Close and delete the file
     248
    186249    Test external programs being called by Sage::
    187250   
    188251        sage: (out, err, ret) = test_executable(["sage", "--sh"], "echo Hello World\nexit 42\n")