Opened 10 years ago

Closed 10 years ago

#10300 closed enhancement (fixed)

Test some command line options

Reported by: jdemeyer Owned by: mvngu
Priority: major Milestone: sage-4.6.1
Component: doctest coverage Keywords: command line tests
Cc: aapitzsch Merged in: sage-4.6.1.alpha3
Authors: Jeroen Demeyer Reviewers: André Apitzsch
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

There should be a new test, say sage/tests/cmdline.py which tests that some command line options to ./sage actually work. In particular ./sage -startuptime should be tested to prevent #10293 from happening again.

With the current patch, we test

--advanced
--branch
-c
--ecl
--experimental
--gap
--gp
-h
--help
--ipython
--kash
--lisp
--min
--mwrank
--optional
--python
-q
--root
--sh
--singular
--standard
--startuptime
-v
--zzfoobar (illegal option)

Dependencies: #10302, #10306

Attachments (3)

10300_cmdline_test.2.patch (5.0 KB) - added by jdemeyer 10 years ago.
10300_cmdline_test.patch (9.4 KB) - added by jdemeyer 10 years ago.
10300_ipython_fix.patch (741 bytes) - added by jdemeyer 10 years ago.
Apply on top of previous patch

Download all attachments as: .zip

Change History (26)

Changed 10 years ago by jdemeyer

comment:1 Changed 10 years ago by jdemeyer

  • Description modified (diff)
  • Status changed from new to needs_work

comment:2 Changed 10 years ago by jdemeyer

  • Description modified (diff)

comment:3 Changed 10 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Status changed from needs_work to needs_review

comment:4 Changed 10 years ago by jdemeyer

  • Description modified (diff)

comment:5 Changed 10 years ago by aapitzsch

Two tests failed with 4.6.1 alpha3. Are there other dependencies except for #10302 and #10306?

File "/scratch/sage-4.6.1a3/devel/sage-20101123/sage/tests/cmdline.py", line 177:
    sage: err
Expected:
    'Hello World\n'
Got:
    ''
**********************************************************************
File "/scratch/sage-4.6.1a3/devel/sage-20101123/sage/tests/cmdline.py", line 183:
    sage: err
Expected:
    'Hello World\n'
Got:
    ''

comment:6 Changed 10 years ago by jdemeyer

  • Cc aapitzsch added
  • Status changed from needs_review to needs_info

No, it should work. Which system is that?

Please do the following in a shell and post the output:

sage -sh -c 'echo $0; echo $BASH'
sage -sh -c "echo >&2 Hello World"
sage -sh -c "echo >&2 Hello World" >/dev/null
sage -sh -c "echo >&2 Hello World" 2>/dev/null
bash -c "echo >&2 Hello World"
bash -c "echo >&2 Hello World" >/dev/null
bash -c "echo >&2 Hello World" 2>/dev/null

comment:7 Changed 10 years ago by aapitzsch

Fedora 12 (64bit) kernel 2.6.32.23-170.fc12.x86_64

$ ./sage -sh -c 'echo $0; echo $BASH'

Starting subshell with Sage environment variables set.
Be sure to exit when you are done and do not do anything
with other copies of Sage!

Bypassing shell configuration files ...

tcsh
BASH: Undefined variable.
Exited Sage subshell.
$ ./sage -sh -c "echo >&2 Hello World"

Starting subshell with Sage environment variables set.
Be sure to exit when you are done and do not do anything
with other copies of Sage!

Bypassing shell configuration files ...

Exited Sage subshell.
$ ./sage -sh -c "echo >&2 Hello World" > /dev/null

(no output)

$ ./sage -sh -c "echo >&2 Hello World" 2>/dev/null

(no output)

$ bash -c "echo >&2 Hello World"
Hello World
$ bash -c "echo >&2 Hello World" >/dev/null
Hello World
$ bash -c "echo >&2 Hello World" 2>/dev/null
Hello World

comment:8 Changed 10 years ago by jdemeyer

Well, I don't know what to make of that output. You're using a different shell (tcsh) but still...

comment:9 follow-up: Changed 10 years ago by wjp

Output redirection in tcsh has different syntax. echo >&2 Hello World will redirect both stdout and stderr to a file named 2.

comment:10 in reply to: ↑ 9 Changed 10 years ago by jdemeyer

  • Status changed from needs_info to needs_work

Replying to wjp:

Output redirection in tcsh has different syntax. echo >&2 Hello World will redirect both stdout and stderr to a file named 2.

Really? That's annoying. I will rewrite the test without any redirections, the test in meant to test whether sage -sh actually does something.

comment:11 follow-up: Changed 10 years ago by drkirkby

I've not got chance to look at this now, but here are a few comments.

The csh is considered to be a pretty poor shell - see for example this article about it.

http://www.ooblick.com/text/CshProgrammingConsideredHarmful.html

tcsh is based on csh.

The first 150 or so lines of that article covers the issues of output redirection, which is the issue here.

The newsgroup {{{comp.unix.shell}} or the autoconf mailing list are good sources of information.

Also

http://www.gnu.org/software/hello/manual/autoconf/Limitations-of-Builtins.html

is worth a look.

Although this particular test may be re-written without any redirections, the probability of something similar breaking elsewhere mush be high.

I guess we should create an account using /bin/tcsh as the shell and test the whole of Sage.

Dave

comment:12 in reply to: ↑ 11 Changed 10 years ago by jdemeyer

Replying to drkirkby:

I guess we should create an account using /bin/tcsh as the shell and test the whole of Sage.

I've just installed tcsh}} on sage.math and I'm doing a build now with the environment variable {{{SHELL set to /usr/bin/tcsh.

Let's see what happens...

comment:13 Changed 10 years ago by jhpalmieri

This is not a big deal, but I would suggest changing the tests from -advanced to --advanced, etc.: use double hyphens for the long command-line options. Every now and then there is discussion of forcing this sort of behavior, for example at #21, and it wouldn't hurt to be ready for it.

comment:14 Changed 10 years ago by jdemeyer

  • Description modified (diff)
  • Status changed from needs_work to needs_review

comment:15 Changed 10 years ago by drkirkby

I created a new account (csh), and set the shell to /bin/csh, then built 4.6.1.alpha2 on OpenSolaris 06/2009.

All tests passed, with the exception of

	sage -t  -long -force_lib devel/sage/sage/homology/examples.py # Time out

which is due to the fact the tests assumes the experimental homology package is installed, so is a bug in the test suite, rather than a test failure.

I've not tried the tcsh shell yet (I need to install that first).

I'll try this patch later. I'm going to look at John's SAGE64 patch first.

comment:16 Changed 10 years ago by jdemeyer

Build and test with tcsh on sage.math was 100% successful.

Changed 10 years ago by jdemeyer

comment:17 Changed 10 years ago by aapitzsch

  • Status changed from needs_review to positive_review

Couldn't test optional kash but everything else passed.

Code looks good except for a few redundant whitespaces.

comment:18 Changed 10 years ago by jdemeyer

  • Reviewers set to André Apitzsch

comment:19 Changed 10 years ago by jdemeyer

  • Status changed from positive_review to needs_work

comment:20 Changed 10 years ago by jdemeyer

  • Status changed from needs_work to needs_review

The following IPython message when it's run for the first time messes up the IPython test:

**********************************************************************
Welcome to IPython. I will try to create a personal configuration directory
where you can customize many aspects of IPython's functionality in:

/space/jdemeyer/home/.ipython
Initializing from configuration /mnt/usb1/scratch/jdemeyer/merger/sage-4.6.1.alpha3/local/lib/python2.6/site-packages/IPython/UserConfig

Successful installation!

Please read the sections 'Initial Configuration' and 'Quick Tips' in the
IPython manual (there are both HTML and PDF versions supplied with the
distribution) to make sure that your system environment is properly configured
to take advantage of IPython's features.

Important note: the configuration system has changed! The old system is
still in place, but its setting may be partly overridden by the settings in
"~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
if some of the new settings bother you.


Please press <RETURN> to start IPython.

The initial \n as input should fix this, see the new patch.

Changed 10 years ago by jdemeyer

Apply on top of previous patch

comment:21 Changed 10 years ago by aapitzsch

  • Status changed from needs_review to positive_review

comment:22 Changed 10 years ago by jdemeyer

See #10326 for a follow-up ticket (cleaning up sage-sage)

comment:23 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.6.1.alpha3
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.