view Makefile @ 14:eec2474fdaaa

* src/ClassInfo.java: Added new helper class. * src/FileUtils.java: Added new method for reading contents of text file. Refactored. * src/ReportGenerator.java: New functionality: methods coverage are printed in package list (previously only class coverage were printed). Refactored. * templates/all_packages_template.html: * templates/index.html: Changed width of left column. * templates/style.css: Tables have black borders (they are more visible). * Makefile: Updated according to previous changes.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Fri, 23 Mar 2012 11:55:40 +0100
parents 5bc6733b29bd
children 7bb9210fb192
line wrap: on
line source

# Test coverage tool.
#
# Copyright (C) 2012 Red Hat
#
#
#
# This tool is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This tool is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this tool; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
# 
# Linking this library statically or dynamically with other modules is
# making a combined work based on this library.  Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# As a special exception, the copyright holders of this library give you
# permission to link this library with independent modules to produce an
# executable, regardless of the license terms of these independent
# modules, and to copy and distribute the resulting executable under
# terms of your choice, provided that you also meet, for each linked
# independent module, the terms and conditions of the license of that
# module.  An independent module is a module which is not derived from
# or based on this library.  If you modify this library, you may extend
# this exception to your version of the library, but you are not
# obligated to do so.  If you do not wish to do so, delete this
# exception statement from your version.

SOURCEPATH=src
CLASSDIR=bin
REPORTDIR=reports
DOCS=docs
TEMPLATEDIR=templates

JAVA=java
JAVAC=javac

# Name of file containing all API classes to be checked by this tool
CLASS_LIST=class_list.txt

# Name of file where all API classes should be stored
ALL_CLASS_LIST=all_class_list.txt

# File containing path to directory where (Mauve) test resides
TEST_DIRECTORY_FILE=test_directory.txt
TESTDIR=`cat $(TEST_DIRECTORY_FILE)`

# Name of file containing path to rt.jar or other tested Java archive
PATH_TO_RT_JAR_FILE=path_to_rt_jar.txt
JARFILE=`cat $(PATH_TO_RT_JAR_FILE)`



all:	build report

report:	api_class_list public_method_list tested_method_list gen_report

clean:
	rm -f $(CLASSDIR)/*.class
	rm -f $(REPORTDIR)/*

build:	$(CLASSDIR) \
	$(CLASSDIR)/PrintClassList.class \
	$(CLASSDIR)/PrintPublicMethods.class \
	$(CLASSDIR)/PrintTestCoverage.class \
	$(CLASSDIR)/ReportGenerator.class \
	$(CLASSDIR)/FileUtils.class \
	$(CLASSDIR)/ClassInfo.class

api_class_list:	$(REPORTDIR) $(REPORTDIR)/$(ALL_CLASS_LIST)

public_method_list:	$(REPORTDIR) $(CLASS_LIST)
	if [ ! -f $(CLASS_LIST) ]; \
	then \
	    echo "Please create file $(CLASS_LIST) containing list of classes to check"; \
	    exit 1; \
	else \
	    echo "Ok, file $(CLASS_LIST) exists, go to next step"; \
	fi
	while read line; \
	do \
	    rm -rf $(REPORTDIR)/$${line}_api.txt; \
	    java -cp $(CLASSDIR) PrintPublicMethods $${line} > $(REPORTDIR)/$${line}_api.txt; \
	done < $(CLASS_LIST);

tested_method_list:	$(REPORTDIR) $(TEST_DIRECTORY_FILE)
	if [ ! -f $(TEST_DIRECTORY_FILE) ]; \
	then \
	    echo "Please create file $(TEST_DIRECTORY_FILE) containing path to test directory"; \
	    exit 1; \
	else \
	    echo "Ok, file $(TEST_DIRECTORY_FILE) exists, go to next step"; \
	fi
	if [ ! -d $(TESTDIR) ]; \
	then \
	    echo "$(TESTDIR) directory does not exists"; \
	    exit 1; \
	else \
	    echo "Ok, test directory $(TESTDIR) exists"; \
	fi
	while read line; \
	do \
	    rm -rf $(REPORTDIR)/$${line}_test.txt; \
	    java -cp $(CLASSDIR) PrintTestCoverage $${line} > $(REPORTDIR)/$${line}_test.txt; \
	done < $(CLASS_LIST);

$(CLASSDIR):
	mkdir -p $(CLASSDIR)

$(CLASSDIR)/%.class:	$(SOURCEPATH)/%.java
	$(JAVAC) -d $(CLASSDIR) -sourcepath $(SOURCEPATH)/ $<

$(REPORTDIR):
	mkdir -p $(REPORTDIR)

# Target to make the file containing list of all API classes
$(REPORTDIR)/$(ALL_CLASS_LIST): $(PATH_TO_RT_JAR_FILE)
	if [ ! -f $(PATH_TO_RT_JAR_FILE) ]; \
	then \
	    echo "Please create file $(PATH_TO_RT_JAR_FILE) containing path rt.jar (or other jar)"; \
	    exit 1; \
	else \
	    echo "Ok, file $(PATH_TO_RT_JAR_FILE) exists, go to next step"; \
	fi
	if [ ! -f $(JARFILE) ]; \
	then \
	    echo "Jar file $(JARFILE) does not exists"; \
	    exit 1; \
	else \
	    echo "Ok, Jar file $(JARFILE) exists"; \
	fi
	$(JAVA) -cp $(CLASSDIR) PrintClassList `cat $(PATH_TO_RT_JAR_FILE)` > $(REPORTDIR)/$(ALL_CLASS_LIST)

gen_report: $(REPORTDIR)
	cp -u $(TEMPLATEDIR)/index.html $(REPORTDIR)
	cp -u $(TEMPLATEDIR)/style.css $(REPORTDIR)
	cp -u $(TEMPLATEDIR)/class_report.js $(REPORTDIR)
	java -cp $(CLASSDIR) ReportGenerator $(REPORTDIR)/$(ALL_CLASS_LIST) $(CLASS_LIST) $(REPORTDIR)