From 92f656725d4bd6d813bbafbd2e0d2e58f3a35a43 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 13 May 2002 03:25:56 +0000 Subject: [PATCH] Fix some bad exceptions in Defaults.py (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@371 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Defaults.py | 4 ++-- test/SharedLibrary.py | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index a7b0dc04..2259f404 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -69,7 +69,7 @@ class SharedCmdGenerator: for src in source: try: if src.attributes.shared != shared: - raise UserError("Source file: %s must be built with shared=%s in order to be compatible with the selected target." % (src, str(shared))) + raise SCons.Errors.UserError("Source file: %s must be built with shared=%s in order to be compatible with the selected target." % (src, str(shared))) except AttributeError: pass for t in target: @@ -247,7 +247,7 @@ def win32LibEmitter(target, source, env, shared=0, dll = tgt break if not dll: - raise UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) + raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) if env.has_key("WIN32_INSERT_DEF") and \ env["WIN32_INSERT_DEF"] and \ diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py index d00f5951..8675c4b4 100644 --- a/test/SharedLibrary.py +++ b/test/SharedLibrary.py @@ -25,9 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import TestCmd import os -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match=TestCmd.match_re) test.write('SConstruct', """ env=Environment(WIN32_INSERT_DEF=1) @@ -39,6 +40,24 @@ env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'], shared=1) env2.Program(target = 'prog', source = 'prog.c') """) +test.write('SConstructFoo', """ +env=Environment() +obj = env.Object('foo', 'foo.c', shared=0) +Default(env.Library(target = 'foo', source = obj, shared=1)) +""") + +test.write('foo.c', r""" +#include + +void +f1(void) +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + + test.write('f1.c', r""" #include @@ -162,4 +181,10 @@ if os.name == 'posix': test.run(program = test.workpath('prog'), stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n") +test.run(arguments = '-f SConstructFoo', status=2, stderr=''' +SCons error: Source file: foo.o must be built with shared=1 in order to be compatible with the selected target. +File ".*", line .*, in .* +''' +) + test.pass_test() -- 2.26.2