@@ -31,6 +31,16 @@ function format_filename(s)
3131 return r
3232end
3333
34+ # Returns true if the given command errors, but doesn't signal
35+ function errors_not_signals (cmd:: Cmd )
36+ p = run (pipeline (ignorestatus (cmd); stdout = devnull , stderr = devnull ))
37+ return errors_not_signals (p)
38+ end
39+ function errors_not_signals (p:: Base.Process )
40+ wait (p)
41+ return process_exited (p) && ! Base. process_signaled (p) && ! success (p)
42+ end
43+
3444let
3545 fn = format_filename (" a%d %p %i %L %l %u z" )
3646 hd = withenv (" HOME" => nothing ) do
@@ -161,22 +171,22 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
161171
162172 # --eval
163173 @test success (` $exename -e "exit(0)"` )
164- @test ! success (` $exename -e "exit(1)"` )
174+ @test errors_not_signals (` $exename -e "exit(1)"` )
165175 @test success (` $exename --eval="exit(0)"` )
166- @test ! success (` $exename --eval="exit(1)"` )
167- @test ! success (` $exename -e` )
168- @test ! success (` $exename --eval` )
176+ @test errors_not_signals (` $exename --eval="exit(1)"` )
177+ @test errors_not_signals (` $exename -e` )
178+ @test errors_not_signals (` $exename --eval` )
169179 # --eval --interactive (replaced --post-boot)
170180 @test success (` $exename -i -e "exit(0)"` )
171- @test ! success (` $exename -i -e "exit(1)"` )
181+ @test errors_not_signals (` $exename -i -e "exit(1)"` )
172182 # issue #34924
173183 @test success (` $exename -e 'const LOAD_PATH=1'` )
174184
175185 # --print
176186 @test read (` $exename -E "1+1"` , String) == " 2\n "
177187 @test read (` $exename --print="1+1"` , String) == " 2\n "
178- @test ! success (` $exename -E` )
179- @test ! success (` $exename --print` )
188+ @test errors_not_signals (` $exename -E` )
189+ @test errors_not_signals (` $exename --print` )
180190
181191 # --load
182192 let testfile = tempname ()
@@ -209,12 +219,13 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
209219 end
210220 end
211221 # -L, --load requires an argument
212- @test ! success (` $exename -L` )
213- @test ! success (` $exename --load` )
222+ @test errors_not_signals (` $exename -L` )
223+ @test errors_not_signals (` $exename --load` )
214224
215225 # --cpu-target (requires LLVM enabled)
216- @test ! success (` $exename -C invalidtarget` )
217- @test ! success (` $exename --cpu-target=invalidtarget` )
226+ # Strictly test for failed error, not a segfault, since we had a false positive with just `success()` before.
227+ @test errors_not_signals (` $exename -C invalidtarget` )
228+ @test errors_not_signals (` $exename --cpu-target=invalidtarget` )
218229
219230 # -t, --threads
220231 code = " print(Threads.nthreads())"
@@ -240,8 +251,8 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
240251 withenv (" JULIA_NUM_THREADS" => string (cpu_threads)) do
241252 @test read (` $exename -e $code ` , String) == string (cpu_threads)
242253 end
243- @test ! success (` $exename -t 0` )
244- @test ! success (` $exename -t -1` )
254+ @test errors_not_signals (` $exename -t 0` )
255+ @test errors_not_signals (` $exename -t -1` )
245256
246257 # Combining --threads and --procs: --threads does propagate
247258 withenv (" JULIA_NUM_THREADS" => nothing ) do
@@ -250,11 +261,11 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
250261 end
251262
252263 # Combining --threads and invalid -C should yield a decent error
253- @test ! success (` $exename -t 2 -C invalidtarget` )
264+ @test errors_not_signals (` $exename -t 2 -C invalidtarget` )
254265
255266 # --procs
256267 @test readchomp (` $exename -q -p 2 -e "println(nworkers())"` ) == " 2"
257- @test ! success (` $exename -p 0` )
268+ @test errors_not_signals (` $exename -p 0` )
258269 let p = run (` $exename --procs=1.0` , wait= false )
259270 wait (p)
260271 @test p. exitcode == 1 && p. termsignal == 0
@@ -281,14 +292,14 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
281292 # --color
282293 @test readchomp (` $exename --color=yes -E "Base.have_color"` ) == " true"
283294 @test readchomp (` $exename --color=no -E "Base.have_color"` ) == " false"
284- @test ! success (` $exename --color=false` )
295+ @test errors_not_signals (` $exename --color=false` )
285296
286297 # --history-file
287298 @test readchomp (` $exename -E "Bool(Base.JLOptions().historyfile)"
288299 --history-file=yes` ) == " true"
289300 @test readchomp (` $exename -E "Bool(Base.JLOptions().historyfile)"
290301 --history-file=no` ) == " false"
291- @test ! success (` $exename --history-file=false` )
302+ @test errors_not_signals (` $exename --history-file=false` )
292303
293304 # --code-coverage
294305 mktempdir () do dir
@@ -452,16 +463,16 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
452463 --check-bounds=no` )) == JL_OPTIONS_CHECK_BOUNDS_OFF
453464 end
454465 # check-bounds takes yes/no as argument
455- @test ! success (` $exename -E "exit(0)" --check-bounds=false` )
466+ @test errors_not_signals (` $exename -E "exit(0)" --check-bounds=false` )
456467
457468 # --depwarn
458469 @test readchomp (` $exename --depwarn=no -E "Base.JLOptions().depwarn"` ) == " 0"
459470 @test readchomp (` $exename --depwarn=yes -E "Base.JLOptions().depwarn"` ) == " 1"
460- @test ! success (` $exename --depwarn=false` )
471+ @test errors_not_signals (` $exename --depwarn=false` )
461472 # test deprecated syntax
462- @test ! success (` $exename -e "foo (x::Int) = x * x" --depwarn=error` )
473+ @test errors_not_signals (` $exename -e "foo (x::Int) = x * x" --depwarn=error` )
463474 # test deprecated method
464- @test ! success (` $exename -e "
475+ @test errors_not_signals (` $exename -e "
465476 foo() = :foo; bar() = :bar
466477 @deprecate foo() bar()
467478 foo()
@@ -479,7 +490,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
479490 Foo.Deprecated
480491 """
481492
482- @test ! success (` $exename -E "$code " --depwarn=error` )
493+ @test errors_not_signals (` $exename -E "$code " --depwarn=error` )
483494
484495 @test readchomperrors (` $exename -E "$code " --depwarn=yes` ) ==
485496 (true , " true" , " WARNING: Foo.Deprecated is deprecated, use NotDeprecated instead.\n likely near none:8" )
@@ -493,14 +504,14 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
493504 @test readchomp (` $exename --inline=yes -E "Bool(Base.JLOptions().can_inline)"` ) == " true"
494505 @test readchomp (` $exename --inline=no -E "Bool(Base.JLOptions().can_inline)"` ) == " false"
495506 # --inline takes yes/no as argument
496- @test ! success (` $exename --inline=false` )
507+ @test errors_not_signals (` $exename --inline=false` )
497508
498509 # --polly
499510 @test readchomp (` $exename -E "Bool(Base.JLOptions().polly)"` ) == " true"
500511 @test readchomp (` $exename --polly=yes -E "Bool(Base.JLOptions().polly)"` ) == " true"
501512 @test readchomp (` $exename --polly=no -E "Bool(Base.JLOptions().polly)"` ) == " false"
502513 # --polly takes yes/no as argument
503- @test ! success (` $exename --polly=false` )
514+ @test errors_not_signals (` $exename --polly=false` )
504515
505516 # --fast-math
506517 let JL_OPTIONS_FAST_MATH_DEFAULT = 0 ,
@@ -518,7 +529,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
518529
519530 # --worker takes default / custom as argument (default/custom arguments
520531 # tested in test/parallel.jl)
521- @test ! success (` $exename --worker=true` )
532+ @test errors_not_signals (` $exename --worker=true` )
522533
523534 # test passing arguments
524535 mktempdir () do dir
@@ -554,7 +565,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
554565 @test readchomp (` $exename -L $testfile $testfile ` ) == output
555566 @test readchomp (` $exename --startup-file=yes $testfile ` ) == output
556567
557- @test ! success (` $exename --foo $testfile ` )
568+ @test errors_not_signals (` $exename --foo $testfile ` )
558569 end
559570 end
560571
@@ -623,7 +634,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
623634 "Bool(Base.JLOptions().use_compiled_modules)"` ) == " true"
624635 @test readchomp (` $exename --compiled-modules=no -E
625636 "Bool(Base.JLOptions().use_compiled_modules)"` ) == " false"
626- @test ! success (` $exename --compiled-modules=foo -e "exit(0)"` )
637+ @test errors_not_signals (` $exename --compiled-modules=foo -e "exit(0)"` )
627638
628639 # issue #12671, starting from a non-directory
629640 # rm(dir) fails on windows with Permission denied
@@ -669,8 +680,7 @@ let exename = `$(Base.julia_cmd().exec[1]) -t 1`
669680 @test ! occursin (" Segmentation fault" , s)
670681 @test ! occursin (" EXCEPTION_ACCESS_VIOLATION" , s)
671682 end
672- @test ! success (p)
673- @test ! Base. process_signaled (p)
683+ @test errors_not_signals (p)
674684 @test p. exitcode == 1
675685 end
676686 end
@@ -680,8 +690,7 @@ let exename = `$(Base.julia_cmd().exec[1]) -t 1`
680690 let s = read (err, String)
681691 @test s == " ERROR: System image file failed consistency check: maybe opened the wrong version?\n "
682692 end
683- @test ! success (p)
684- @test ! Base. process_signaled (p)
693+ @test errors_not_signals (p)
685694 @test p. exitcode == 1
686695 end
687696end
@@ -699,7 +708,7 @@ let exename = Base.julia_cmd()
699708 @test parse (Int,readchomp (` $exename -E "Base.JLOptions().startupfile"
700709 --startup-file=no` )) == JL_OPTIONS_STARTUPFILE_OFF
701710 end
702- @test ! success (` $exename --startup-file=false` )
711+ @test errors_not_signals (` $exename --startup-file=false` )
703712end
704713
705714# Make sure `julia --lisp` doesn't break
0 commit comments