-
Notifications
You must be signed in to change notification settings - Fork 2
/
cleantest.bat
62 lines (51 loc) · 1.26 KB
/
cleantest.bat
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
rem ( /*
@echo off
cscript /nologo /e:javascript %0
goto end
*/ )
//
// main function is below
function rem() {
WScript.StdOut.WriteLine("Removing generated test parsers and lexers");
var files = GetFolderFiles(GetTestPath() + "\\test");
var fso = new ActiveXObject("Scripting.FileSystemObject");
for (i in files)
{
if ((!MatchTest(files[i].Name)) &&
(MatchExt(files[i].Name,"php") ||
MatchExt(files[i].Name,"tokens") )) {
var removeme = fso.GetFile(files[i].Path);
WScript.StdOut.WriteLine("Deleteing "+files[i].Name);
removeme.Delete();
}
}
}
function GetFolderFiles(path)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = fso.GetFolder(path);
var fc = new Enumerator(folder.files);
var result = new Array();
for (; !fc.atEnd(); fc.moveNext())
{
result.push(fc.item());
}
return result;
}
function GetTestPath()
{
var name = WScript.ScriptFullName;
return name.substr(0,name.lastIndexOf("\\"));
}
function MatchExt(fname,ext) {
var re = new RegExp("\."+ext+"$");
var m = re.exec(fname);
return (m != null);
}
function MatchTest(fname) {
var re = new RegExp("Test\.php$");
var m = re.exec(fname);
return (m != null);
}
/*
:end */