summaryrefslogtreecommitdiff
path: root/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl
blob: bce70bae00dd399a57283e93a03e1b868e1e8992 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! perl


use File::Find;
use Cwd;
use File::Basename;

#  find(\&Visitfile,"../../../content/tf");

foreach $_ ( @sheetfiles )
  {
	$dest_sheet_name=$_;
	$dest_sheet_name =~ s/\.mks/.sht/i;
	$dest_sheet_name =~ s@/content/([^/]+)/materialsrc/@/game/\1/materials/@gi;
	print "**Checking $_\n";
	if (! -e $dest_sheet_name )
	  {
		push @errors,"sheet $_ exists but not $dest_sheet_name";
	  }
	else
	  {
		# buid it and make sure they match
		$cmd="cd ".dirname($_)." & mksheet ".basename($_)." test.sht";
		$cmd=~tr/\//\\/;
		$cmdout=`$cmd`;
		if ( open(NEWFILE, dirname($_)."/test.sht") )
		  {
			binmode NEWFILE;
			open(OLDFILE, $dest_sheet_name ) || die "strange error - cant find $dest_sheet_name";
			binmode OLDFILE;
			{
			  local( $/, *FH ) ;
			  $old_data=<OLDFILE>;
			  $new_data=<NEWFILE>;
			  if ( $new_data ne $old_data )
				{
				  push @errors,"Sheet source file $_ does not compile to the same output as the checked in $dest_sheet_name";
				}
			  close OLDFILE;
			  close NEWFILE;
			  unlink dirname($_)."/test.sht";
			}
		  }
		else
		  {
			push @errors, "Couldn't compile sheet $_ by running $cmd : \n$cmdout";
		  }
	  }
  }

$errout=join("\n", @errors);
print $errout;
if (length($errout))
  {
	open(ERRFILE,">errors.txt") || die "can't write errors.txt";
	print ERRFILE $errout;
	close ERRFILE;
  }


sub Visitfile
  {
	local($_)= $File::Find::name;
	s@\\@\/@g;
	if (m@content/(\S+)/.*\.mks$@i)
	  {
		push @sheetfiles, $_;
	  }
  }