Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7c340b4b5eb9bf0fc14a433670f2d0f9d3d40875
[simgrid.git] / tools / cmake / Scripts / update_tesh.pl
1 #!/usr/bin/perl -w
2
3 # Copyright (c) 2012, 2014. The SimGrid Team.
4 # All rights reserved.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
8
9 use strict;
10
11 if($#ARGV!=1) {
12     die "Usage: perl make_tesh.pl <directory> <old.tesh>\n";
13 }
14
15 my($directory)=$ARGV[0];
16 my($old)=$ARGV[1];
17
18 chdir("$directory");
19
20 open SH_LIGNE, $old or die "Unable to open $old. $!\n";
21
22 my($line);
23 my($line_exec);
24 my($l);
25 my($tmp);
26
27 while(defined($line=<SH_LIGNE>))
28 {
29         if($line =~ /^\$(.*)$/)
30         {
31                 $line_exec = $line;
32                 $line =~ s/\$\{srcdir\:\=\.\}/./g;
33                 $line =~ s/\(/\\(/g;
34                 $line =~ s/\)/\\)/g;
35                 $line =~ s/\$SG_TEST_EXENV//g;
36                 $line =~ s/\$EXEEXT//g;
37                 $line =~ s/^\$\ */.\//g;
38                 $line =~ s/^.\/lua/lua/g;
39                 $line =~ s/^.\/ruby/ruby/g;
40                 $line =~ s/--log=([^ ]*)/--log="$1"/g;
41                 print "$line_exec";
42                 chomp $line;
43                 open (FILE, "$line 2>&1|");
44                 while(defined($l=<FILE>))
45                 {
46                 chomp $l;
47                 print "\> $l\n";
48                 }
49                 close(FILE);
50         }
51         else
52         {
53                 if($line =~ /^\>(.*)$/)
54                 {
55                 }
56                 else
57                 {
58                 print "$line";
59                 }
60         }       
61 }
62
63 close(SH_LIGNE);