Skip unittests in imported modules

This commit is contained in:
Alexey Prokhin 2011-04-30 15:30:57 +04:00
parent 7070239e7d
commit 6bc2431b6b
7 changed files with 12 additions and 1 deletions

View file

@ -156,6 +156,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
moduleInfoType = new llvm::PATypeHolder(llvm::OpaqueType::get(llvm::getGlobalContext()));
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
this->isRoot = false;
#endif
}

View file

@ -206,6 +206,8 @@ struct Module : Package
// array ops emitted in this module already
StringTable arrayfuncs;
bool isRoot;
#endif
};

View file

@ -3700,7 +3700,11 @@ Dsymbol *UnitTestDeclaration::syntaxCopy(Dsymbol *s)
void UnitTestDeclaration::semantic(Scope *sc)
{
#if IN_LLVM
if (global.params.useUnitTests && sc->module->isRoot)
#else
if (global.params.useUnitTests)
#endif
{
if (!type)
type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd);

View file

@ -218,6 +218,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
moduleInfoType = new llvm::PATypeHolder(llvm::OpaqueType::get(llvm::getGlobalContext()));
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
this->isRoot = false;
#endif
}
#if IN_LLVM

View file

@ -214,6 +214,8 @@ struct Module : Package
// array ops emitted in this module already
StringTable arrayfuncs;
bool isRoot;
#endif
};

View file

@ -298,7 +298,7 @@ static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl)
void DtoResolveFunction(FuncDeclaration* fdecl)
{
if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) {
if ((!global.params.useUnitTests || !fdecl->type) && fdecl->isUnitTestDeclaration()) {
Logger::println("Ignoring unittest %s", fdecl->toPrettyChars());
return; // ignore declaration completely
}

View file

@ -780,6 +780,7 @@ LDC_TARGETS
id = Lexer::idPool(name);
m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration);
m->isRoot = true;
modules.push(m);
}