Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test some command line options #10300

Closed
jdemeyer opened this issue Nov 20, 2010 · 24 comments
Closed

Test some command line options #10300

jdemeyer opened this issue Nov 20, 2010 · 24 comments

Comments

@jdemeyer
Copy link

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

CC: @a-andre

Component: doctest coverage

Keywords: command line tests

Author: Jeroen Demeyer

Reviewer: André Apitzsch

Merged: sage-4.6.1.alpha3

Issue created by migration from https://trac.sagemath.org/ticket/10300

@jdemeyer
Copy link
Author

comment:1

Attachment: 10300_cmdline_test.2.patch.gz

@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link
Author

Author: Jeroen Demeyer

@jdemeyer

This comment has been minimized.

@a-andre
Copy link

a-andre commented Nov 23, 2010

comment:5

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:
    ''

@jdemeyer
Copy link
Author

comment:6

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

@a-andre
Copy link

a-andre commented Nov 23, 2010

comment:7

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

@jdemeyer
Copy link
Author

comment:8

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

@wjp
Copy link
Mannequin

wjp mannequin commented Nov 24, 2010

comment:9

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

@jdemeyer
Copy link
Author

comment:10

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.

@sagetrac-drkirkby
Copy link
Mannequin

sagetrac-drkirkby mannequin commented Nov 24, 2010

comment:11

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

@jdemeyer
Copy link
Author

comment:12

Replying to @sagetrac-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...

@jhpalmieri
Copy link
Member

comment:13

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.

@jdemeyer

This comment has been minimized.

@sagetrac-drkirkby
Copy link
Mannequin

sagetrac-drkirkby mannequin commented Nov 24, 2010

comment:15

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.

@jdemeyer
Copy link
Author

comment:16

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

@a-andre
Copy link

a-andre commented Nov 25, 2010

comment:17

Attachment: 10300_cmdline_test.patch.gz

Couldn't test optional kash but everything else passed.

Code looks good except for a few redundant whitespaces.

@jdemeyer
Copy link
Author

Reviewer: André Apitzsch

@jdemeyer
Copy link
Author

comment:20

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.

@jdemeyer
Copy link
Author

Apply on top of previous patch

@a-andre
Copy link

a-andre commented Nov 26, 2010

comment:21

Attachment: 10300_ipython_fix.patch.gz

@jdemeyer
Copy link
Author

comment:22

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

@jdemeyer
Copy link
Author

jdemeyer commented Dec 2, 2010

Merged: sage-4.6.1.alpha3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants