public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Fischer <rep.dot.nop@gmail.com>
To: FX Coudert <fxcoudert@gmail.com>
Cc: Brooks Moses <brooks.moses@codesourcery.com>,
	fortran@gcc.gnu.org, 	gcc-patches@gcc.gnu.org
Subject: Re: [patch, testsuite, committed] Clean up gfortran.dg leftover module  files.
Date: Tue, 27 Mar 2007 17:24:00 -0000	[thread overview]
Message-ID: <20070327165423.GA11354@aon.at> (raw)
In-Reply-To: <8FCB7046-4436-4B07-B925-E120A52AF907@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2878 bytes --]

On Mon, Mar 26, 2007 at 10:28:40PM +0200, FX Coudert wrote:
>>There are still a lot of module files left over from running  
>>gfortran.fortran-torture, since (as Kaveh pointed out) that doesn't  
>>recognize dg-final directives.  I've got a patch that adds the  
>>directives, but not one for recognizing them yet....
>
>I'm wondering why we don't simply incorporate all these tests in the  
>gfortran.dg framework. It's rather easy to do, we just need to add  
>the compile tests a { dg-do compile } line, and the execution tests  
>both { dg-do run } and { dg-options "-w" }. There are a few special  
>cases (the execution tests associated to a .x file), but nothing too  
>difficult. We could even move them into subdirectory so we don't mix  
>everything.

Short of teaching dejagnu to automagically rm all .mod by scanning the
input for 'module [procedure] name', perhaps a quick script like the
attached would ease the handling of those?

Something for contrib/, perhaps?
Just a thought..

Sample output:
gfortran.dg$ ~/gfortran.dg-final.cleanup-mods.awk  *f *f90 *inc
Wrong encoding! sed -i -e 's/\x0D//g' actual_array_constructor_2.f90
[snip a handful of those]
Wrong encoding! sed -i -e 's/\x0D//g' used_types_4.f90
alloc_comp_basics_1.f90: no cleanup for module 'alloc_m'
assumed_charlen_function_1.f90: no cleanup for module 'integer_sets'
equiv_constraint_7.f90: no cleanup for module 'data'
error_recovery_1.f90: no cleanup for module 'gfcbug29_import'
func_derived_4.f90: no cleanup for module 'class_field'
interface_3.f90: no cleanup for module 'test_mod2'
keyword_symbol_1.f90: no cleanup for module 'blahblah'
sequence_types_1.f90: no cleanup for module 'data_types'
simpleif_2.f90: no cleanup for module 'read'
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ \1/' actual_array_constructor_1.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ alloc_m\1/' alloc_comp_basics_1.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ integer_sets\1/' assumed_charlen_function_1.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ data\1/' equiv_constraint_7.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ gfcbug29_import\1/' error_recovery_1.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ class_field\1/' func_derived_4.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ test_mod2\1/' interface_3.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ blahblah\1/' keyword_symbol_1.f90
sed -i -e '/cleanup-modules/s/\("[[:space:]]*}\)/ data_types\1/' sequence_types_1.f90

The "Wrong encoding" and "no cleanup for module" go to stderr, so to
automatically append the missing modules to cleanup-modules, do >
/dev/null and eval the rest

Untested, so beware..
>
>Speaking of which: there's a gfortran.dg/g77 directory, but it looks  
>like the tests in it are never actually run when I do "make check- 
>gfortran". Is that expected?
>
>FX
>

[-- Attachment #2: gfortran.dg-final.cleanup-mods.awk --]
[-- Type: text/plain, Size: 1469 bytes --]

#! /usr/bin/awk -f
# Public Domain
/[eE][nN][dD][ \t]*[mM][oO][dD][uU][lL][eE]/ { next; }
/^[ \t]*[mM][oO][dD][uU][lL][eE][ \t]/ {
	if (tolower($2) == "procedure")
		next;
	pos++;
	tmp = tolower($2);
	gsub(/[ \t
]*/, "", tmp);
	mod[pos] = tmp;
	file[pos] = FILENAME;
#	printf("%s:%d saw module '%s'\n", FILENAME, FNR, $2);
}
/{[ \t]*cleanup-modules/ {
	cleanup = tolower($0);
	sub(/.*{[ \t]*cleanup-modules/, "", cleanup);
	gsub(/[ \t][ \t]*/, " ", cleanup);
	gsub(/(^[ \t]+|["{}])/, "", cleanup);
	gsub(/[ \t]*$/, "", cleanup);
	split(cleanup, mods);
	for (i in mods) {
		cleaned++;
		clean[cleaned] = mods[i];
	}
}
/
/ {
	if (warned_encoding[FILENAME] != 1) {
		warned_encoding[FILENAME] = 1;
		print "Wrong encoding\x21 sed -i -e 's/\\x0D//g' "FILENAME > "/dev/stderr"
	}
}
BEGIN {
	pos = -1;
	cleaned = -1;
	fixup = 1;
}
END {
		done = 0;
	for (i = 0; i <= pos; i++) {
		for (j in clean) {
			if (mod[i] == clean[j]) {
				delete mod[i];
			}
		}
	}
	for (i = 0; i <= pos; i++) {
		if (length(mod[i])) {
			printf("%s: no cleanup for module '%s'\n",
				file[i], mod[i]) > "/dev/stderr";
			if (fixup) {
				emit[file[i]] = emit[file[i]] " " mod[i];
				gsub(/^[ ]*/, "", emit[file[i]]);
			}
		}
	}

	if (fixup) {
		oldfile = file[0];
		for (i = 0; i <= pos; i++) {
			if (length(emit[file[i]]) && (oldfile != file[i])) {
				printf("sed -i -e '/cleanup-modules/s/\\(\"[[:space:]]*}\\)/ %s\\1/' %s\n", emit[oldfile], oldfile);
				oldfile = file[i];
			}
		}
	}
}

  reply	other threads:[~2007-03-27 16:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-26 21:40 Brooks Moses
2007-03-26 21:45 ` FX Coudert
2007-03-27 17:24   ` Bernhard Fischer [this message]
2007-03-27 17:29     ` Bernhard Fischer
2012-03-01 21:10       ` [PATCH] gfortran testsuite: implicitly cleanup-modules Bernhard Reutner-Fischer
2012-03-09  0:04         ` Mikael Morin
2012-03-13 16:39           ` Bernhard Reutner-Fischer
2012-03-13 20:31             ` Mike Stump
2012-03-15 12:40               ` Bernhard Reutner-Fischer
2012-03-15 15:57                 ` Richard Guenther
2012-03-15 16:56                   ` Bernhard Reutner-Fischer
2012-03-15 19:36                     ` Jakub Jelinek
2012-03-16 10:05                       ` Bernhard Reutner-Fischer
2012-03-16 15:00                         ` Bernhard Reutner-Fischer
2012-06-29  0:15                           ` Bernhard Reutner-Fischer
2012-06-29  0:55                             ` Mike Stump
2012-06-29  0:56                               ` Bernhard Reutner-Fischer
2012-06-29  5:43                                 ` Mike Stump
2013-06-07 14:30                                   ` Bernhard Reutner-Fischer
2013-06-10 23:21                                     ` Ben Elliston
2012-03-19 17:36                         ` Rainer Orth
2012-03-22 12:30                           ` Bernhard Reutner-Fischer
2012-04-03 12:17                             ` [PATCH] gfortran testsuite: implicitly cleanup-modules, part 2 Bernhard Reutner-Fischer
2012-04-03 12:58                               ` Bernhard Reutner-Fischer
2012-04-13 10:51                                 ` PING " Bernhard Reutner-Fischer
2012-04-13 13:58                                   ` Mike Stump
2012-04-13 14:40                                     ` Bernhard Reutner-Fischer
2012-04-13 20:09                                       ` Mike Stump
2012-04-13 14:15                               ` Mike Stump
2015-04-23  8:55                         ` [PATCH] gfortran testsuite: implicitly cleanup-modules Bernhard Reutner-Fischer
2015-04-29 21:58                           ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070327165423.GA11354@aon.at \
    --to=rep.dot.nop@gmail.com \
    --cc=brooks.moses@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=fxcoudert@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).