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

Fix bug when displaying example errors #3460

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

d-torrance
Copy link
Member

We were trying to concatenate a list of nets, but concatenate expects a list of strings.

Before

Consider the following simple package:

newPackage("Foo", Headline => "foo",)
beginDocumentation()

doc ///
  Key
    Foo
  Description
    Example
      1/0
///

Of course, we get an error when installing it, but it's the wrong error!

i1 : installPackage("Foo", FileName => "Foo.m2")
 -- making example results for "Foo"                                        
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-1280044-0/1-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/usr/bin/M2-binary" --no-randomize --no-readline --silent --stop --print-width 77 -e 'needsPackage("Foo",Reload=>true,FileName=>"/home/profzoom/tmp/Foo.m2")' <"/tmp/M2-1280044-0/0___Foo.m2" >>"/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/___Foo.errors" 2>&1
/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/___Foo.errors:0:1:(3):[10]: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-1280044-0/0___Foo.m2:0:1: (input file)
M2: *** Error 1
 -- 1.04873s elapsed
stdio:1:14:(3): error: expected strings, integers, or symbols

After

i1 : installPackage("Foo", FileName => "Foo.m2")
 -- making example results for "Foo"                                        
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-1280380-0/1-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/usr/bin/M2-binary" --no-randomize --no-readline --silent --stop --print-width 77 --srcdir "/home/profzoom/src/macaulay2/M2/M2" -e 'needsPackage("Foo",Reload=>true,FileName=>"/home/profzoom/tmp/Foo.m2")' <"/tmp/M2-1280380-0/0___Foo.m2" >>"/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/___Foo.errors" 2>&1
/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/___Foo.errors:0:1:(3):[10]: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-1280380-0/0___Foo.m2:0:1: (input file)
M2: *** Error 1
 -- 1.13406s elapsed
stdio:1:14:(3): error: installPackage: 1 error(s) occurred in running examples for package Foo

@mahrud
Copy link
Member

mahrud commented Sep 6, 2024

Why concatenate as opposed to stack?

@d-torrance
Copy link
Member Author

I played around with that, too. I stuck with concatenate since that doesn't change the behavior. The nets in the list already have a trailing newline, so stacking them adds one additional newline, giving us some extra vertical space when there's more than one error and we're running installPackage in verbose mode. In particular:

concatenate & toString

 -- _bar.errors
 -- ***********
 -- -- -*- M2-comint -*- hash: 1330311532778
 -- 
 -- i1 : 1/0
 -- stdio:1:1:(3): error: division by zero
 -- _foo.errors
 -- ***********
 -- -- -*- M2-comint -*- hash: 1330311532778
 -- 
 -- i1 : 1/0
 -- stdio:1:1:(3): error: division by zero

stack

 -- _bar.errors
 -- ***********
 -- -- -*- M2-comint -*- hash: 1330311532778
 -- 
 -- i1 : 1/0
 -- stdio:1:1:(3): error: division by zero
 -- 
 -- _foo.errors
 -- ***********
 -- -- -*- M2-comint -*- hash: 1330311532778
 -- 
 -- i1 : 1/0
 -- stdio:1:1:(3): error: division by zero

I have no strong opinion one way or the other.

@mahrud
Copy link
Member

mahrud commented Sep 7, 2024

I think I slightly prefer the extra line? And also, what do you think about removing the first two lines. Is knowing the hash useful?

We were trying to concatenate a list of nets, but "concatenate"
expects a list of strings.  So we use "stack" instead.
@d-torrance
Copy link
Member Author

I switched it to use stack.

We need the hash information to determine whether we should regenerate cached examples on subsequent calls to installPackage. And all the .out cached examples files with this hash information started out as one of these .errors files -- we rename them if the run was successful.

@mahrud
Copy link
Member

mahrud commented Sep 8, 2024

Oh sorry I know why we use the hash, I meant is printing it useful for debugging? Like we could just skip printing the first two lines.

@d-torrance
Copy link
Member Author

Ah ok. We only see the hash for this example because it appears just before the error occurred. In general, it prints up to 9 lines before the error (assuming we can locate it using a regex):

i3 : installPackage("Foo", FileName => "~/tmp/Foo.m2", Verbose => true)
 -- installing package Foo in ../.Macaulay2/local/ with layout #1
 -- using package sources found in ./
 -- storing raw documentation in ../.Macaulay2/local/lib/x86_64-linux-gnu/Macaulay2/Foo/cache/rawdocumentation-dcba-8.db
 -- new raw documentation, not already in database, for foo
 -- closed the database
 -- making example result files in ../.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/
 -- making example results for "foo"                                        
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-1902730-0/1-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/usr/bin/M2-binary" --no-randomize --no-readline --silent --stop --print-width 77 --srcdir "/home/profzoom/src/macaulay2/M2/M2" -e 'needsPackage("Foo",Reload=>true,FileName=>"/home/profzoom/tmp/Foo.m2")' <"/tmp/M2-1902730-0/0_foo.m2" >>"/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/_foo.errors" 2>&1
/home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/_foo.errors:0:1:(3):[10]: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-1902730-0/0_foo.m2:0:1: (input file)
M2: *** Error 1
 -- 1.08838s elapsed
 -- storing example results in ../.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/_foo.out
 -- warning: missing file /home/profzoom/.Macaulay2/local/share/doc/Macaulay2/Foo/example-output/_foo.out
 -- _foo.errors
 -- ***********
 -- tristique nisl.  Praesent augue.  Fusce commodo.  Vestibulum
 -- convallis, lorem a tempus semper, dui dui euismod elit, vitae
 -- placerat urna tortor vitae lacus.  Nullam libero mauris,
 -- consequat quis, varius et, dictum id, arcu.  Mauris mollis
 -- tincidunt felis.  Aliquam feugiat tellus ut neque.  Nulla
 -- facilisis, risus a rhoncus fermentum, tellus tellus lacinia
 -- purus, et dictum nunc justo sit amet elit.
 -- 
 -- i3 : 1/0
 -- stdio:26:1:(3): error: division by zero
 -- 
stdio:3:14:(3): error: installPackage: 1 error(s) occurred in running examples for package Foo

@mahrud mahrud merged commit 6a17cf4 into Macaulay2:development Sep 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants