Initial test building support along with a stub test file
git-svn-id: http://pugixml.googlecode.com/svn/trunk@138 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
78eddacef5
commit
52aa5325f3
3 changed files with 170 additions and 0 deletions
18
Jamfile.jam
Normal file
18
Jamfile.jam
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Latest jamplus is needed to use this
|
||||
# Targets:
|
||||
# pugixml - build pugixml library
|
||||
# tests - build pugixml test suite
|
||||
# run_tests - run pugixml test suite
|
||||
# coverage - get test suite coverage
|
||||
|
||||
include "Jamrules.jam" ;
|
||||
|
||||
BUILD = build/mingw/debug ;
|
||||
CCFLAGS = -fprofile-arcs -ftest-coverage ;
|
||||
LDFLAGS = -fprofile-arcs ;
|
||||
GCOVFLAGS = -n ;
|
||||
|
||||
Library pugixml : src/pugixml.cpp src/pugixpath.cpp ;
|
||||
Application tests : tests/main.cpp : pugixml ;
|
||||
Test run_tests : tests ;
|
||||
Coverage coverage : run_tests ;
|
142
Jamrules.jam
Normal file
142
Jamrules.jam
Normal file
|
@ -0,0 +1,142 @@
|
|||
# Rules for Jamfile.jam
|
||||
|
||||
actions ObjectAction
|
||||
{
|
||||
%MINGW_PATH%\bin\gcc -W -Wall -Wextra -Werror -ansi -pedantic -c $(>) -o $(<) $(CCFLAGS)
|
||||
}
|
||||
|
||||
actions LibraryAction
|
||||
{
|
||||
%MINGW_PATH%\bin\ar rc $(<) $(>)
|
||||
}
|
||||
|
||||
actions LinkAction
|
||||
{
|
||||
%MINGW_PATH%\bin\g++ $(>) -o $(<) $(LDFLAGS)
|
||||
}
|
||||
|
||||
actions CoverageAction
|
||||
{
|
||||
%MINGW_PATH%\bin\gcov $(>:\\) $(GCOVFLAGS)
|
||||
}
|
||||
|
||||
actions RunAction
|
||||
{
|
||||
$(>:\\)
|
||||
}
|
||||
|
||||
actions quietly ignore MakeDir
|
||||
{
|
||||
mkdir $(<:\\) >nul 2>&1
|
||||
}
|
||||
|
||||
rule MakeFileDir TARGET
|
||||
{
|
||||
local DIR = $(TARGET:D) ;
|
||||
|
||||
MakeDir $(DIR) ;
|
||||
Needs $(TARGET) : $(DIR) ;
|
||||
}
|
||||
|
||||
rule Alias TARGET : SOURCE
|
||||
{
|
||||
NotFile $(TARGET) ;
|
||||
Always $(TARGET) ;
|
||||
Depends $(TARGET) : $(SOURCE) ;
|
||||
}
|
||||
|
||||
rule Object TARGET : SOURCE
|
||||
{
|
||||
HDRRULE on $(SOURCE) = C.HdrRule ;
|
||||
HDRSCAN on $(SOURCE) = $(C.HDRPATTERN) ;
|
||||
|
||||
MakeFileDir $(TARGET) ;
|
||||
ObjectAction $(TARGET) : $(SOURCE) ;
|
||||
Depends $(TARGET) : $(SOURCE) ;
|
||||
}
|
||||
|
||||
rule Objects SOURCES
|
||||
{
|
||||
local OBJECTS ;
|
||||
|
||||
for SOURCE in $(SOURCES)
|
||||
{
|
||||
local OBJECT = $(BUILD)/$(SOURCE:S=.o) ;
|
||||
|
||||
Object $(OBJECT) : $(SOURCE) ;
|
||||
OBJECTS += $(OBJECT) ;
|
||||
}
|
||||
|
||||
return $(OBJECTS) ;
|
||||
}
|
||||
|
||||
rule Library TARGET : SOURCES
|
||||
{
|
||||
# build object files
|
||||
local OBJECTS = [ Objects $(SOURCES) ] ;
|
||||
|
||||
# build library
|
||||
local LIBRARY = $(BUILD)/$(TARGET).a ;
|
||||
|
||||
MakeFileDir $(LIBRARY) ;
|
||||
LibraryAction $(LIBRARY) : $(OBJECTS) ;
|
||||
Depends $(LIBRARY) : $(OBJECTS) ;
|
||||
|
||||
# make alias
|
||||
Alias $(TARGET) : $(LIBRARY) ;
|
||||
|
||||
# remember library path for linking
|
||||
$(TARGET)_path = $(LIBRARY) ;
|
||||
|
||||
# remember library objects for coverage
|
||||
$(TARGET)_objects = $(OBJECTS) ;
|
||||
}
|
||||
|
||||
rule Application TARGET : SOURCES : LIBRARIES
|
||||
{
|
||||
# build object files
|
||||
local OBJECTS = [ Objects $(SOURCES) ] ;
|
||||
|
||||
# get binary path
|
||||
local EXECUTABLE = $(BUILD)/$(TARGET).exe ;
|
||||
|
||||
# set libraries
|
||||
LDFLAGS on $(EXECUTABLE) = $(LDFLAGS) $($(LIBRARIES)_path) ;
|
||||
|
||||
# build application
|
||||
MakeFileDir $(EXECUTABLE) ;
|
||||
LinkAction $(EXECUTABLE) : $(OBJECTS) ;
|
||||
Depends $(EXECUTABLE) : $(OBJECTS) $(LIBRARIES) ;
|
||||
|
||||
# make alias
|
||||
Alias $(TARGET) : $(EXECUTABLE) ;
|
||||
|
||||
# remember executable path for running
|
||||
$(TARGET)_path = $(EXECUTABLE) ;
|
||||
|
||||
# remember executable objects for coverage
|
||||
$(TARGET)_objects = $(OBJECTS) $($(LIBRARIES)_objects) ;
|
||||
}
|
||||
|
||||
rule Test TARGET : SOURCE
|
||||
{
|
||||
# make alias
|
||||
Alias $(TARGET) : $(SOURCE) ;
|
||||
|
||||
# run tests
|
||||
RunAction $(TARGET) : $($(SOURCE)_path) ;
|
||||
|
||||
# remember executable objects for coverage
|
||||
$(TARGET)_objects = $($(SOURCE)_objects) ;
|
||||
}
|
||||
|
||||
rule Coverage TARGET : SOURCE
|
||||
{
|
||||
local FILES = $($(SOURCE)_objects:S=.gcda) ;
|
||||
|
||||
# disable "independent target" warnings
|
||||
NotFile $(FILES) ;
|
||||
|
||||
CoverageAction $(TARGET) : $(FILES) ;
|
||||
Depends $(TARGET) : $(SOURCE) ;
|
||||
}
|
10
tests/main.cpp
Normal file
10
tests/main.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include "../src/pugixml.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
pugi::xml_document doc;
|
||||
doc.load("<node/>");
|
||||
doc.select_single_node("node");
|
||||
|
||||
// doc.select_single_node("//"); - fails? why? :)
|
||||
}
|
Loading…
Add table
Reference in a new issue