view Makefile @ 0:29318fe8d6d0

2012-01-04 Pavel Tisnovsky <ptisnovs@redhat.com> * adding .classpath: * adding .project: * adding .settings/org.eclipse.jdt.core.prefs: * adding AUTHORS: * adding ChangeLog: * adding LICENSE: * adding Makefile: * adding NEWS: * adding README: * adding TODO: * adding class_list.txt: * adding path_to_rt_jar.txt: * adding src/PrintClassList.java: * adding src/PrintPublicMethods.java: * adding src/PrintTestCoverage.java: * adding src/ReportGenerator.java: * adding src/index.html: * adding src/style.css: * adding test_directory.txt: Initial push to this project.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Wed, 04 Jan 2012 11:20:55 +0100
parents
children 17f81193758a
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

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)/PrintClassList.class \
	$(CLASSDIR)/PrintPublicMethods.class \
	$(CLASSDIR)/PrintTestCoverage.class \
	$(CLASSDIR)/ReportGenerator.class

api_class_list:	$(REPORTDIR)/$(ALL_CLASS_LIST)

public_method_list:	$(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: $(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)/%.class:	$(SOURCEPATH)/%.java
	$(JAVAC) -d $(CLASSDIR) -sourcepath $(SOURCEPATH)/ $<

# 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:
	cp -u $(SOURCEPATH)/index.html $(REPORTDIR)
	cp -u $(SOURCEPATH)/style.css $(REPORTDIR)
	java -cp $(CLASSDIR) ReportGenerator $(REPORTDIR)/$(ALL_CLASS_LIST) $(CLASS_LIST) $(REPORTDIR)