1
- <cfsetting showdebugoutput =" false" >
2
- <!--- CPU Integration --->
3
- <cfparam name =" url.cpu" default =" false" >
4
- <!--- SETUP THE ROOTS OF THE BROWSER RIGHT HERE --->
5
- <cfset rootMapping = " /tests/specs" >
6
- <cfif directoryExists ( rootMapping ) >
7
- <cfset rootPath = rootMapping >
8
- <cfelse >
9
- <cfset rootPath = expandPath ( rootMapping ) >
10
- </cfif >
11
-
12
- <!--- param incoming --->
13
- <cfparam name =" url.path" default =" /" >
14
-
15
- <!--- Decodes & Path Defaults --->
16
- <cfif ! len ( url .path ) >
17
- <cfset url .path = " /" >
18
- </cfif >
19
-
20
- <!--- Prepare TestBox --->
21
- <cfset testbox = new testbox .system .TestBox () >
22
-
23
- <!--- Run Tests Action?--->
24
- <cfif structKeyExists ( url , " action" ) >
25
- <cfif directoryExists ( expandPath ( rootMapping & url .path ) ) >
26
- <cfoutput >#testbox .init ( directory = rootMapping & url .path ).run () #</cfoutput >
27
- <cfelse >
28
- <cfoutput ><h2 >Invalid incoming directory: #rootMapping & url .path #</h2 ></cfoutput >
29
- </cfif >
30
- <cfabort >
31
-
32
- </cfif >
33
-
34
- <!--- Get list of files --->
35
- <cfdirectory action =" list" directory =" #rootPath & url .path #" name =" qResults" sort =" directory asc, name asc" >
36
- <!--- Get the execute path --->
37
- <cfset executePath = rootMapping & ( url .path eq " /" ? " /" : url .path & " /" ) >
38
- <!--- Get the Back Path --->
39
- <cfif url .path neq " /" >
40
- <cfset backPath = replacenocase ( url .path , listLast ( url .path , " /" ), " " ) >
41
- <cfset backPath = reReplace ( backpath , " /$" , " " ) >
42
- </cfif >
43
-
44
- <cfset ASSETS_DIR = expandPath ( " /testbox/system/reports/assets" ) >
45
- <!--- Do HTML --->
1
+ <cfscript >
2
+ // No cf debugging
3
+ cfsetting ( showdebugoutput = " false" );
4
+ // Path Navigation
5
+ param name = " url.path" default = " " ;
6
+ // Root Tests Directory
7
+ rootMapping = " /tests/specs" ;
8
+ rootPath = expandPath ( rootMapping );
9
+ targetPath = rootPath ;
10
+ // Append navigation path
11
+ if ( len ( url .path ) ){
12
+ targetPath = getCanonicalPath ( rootpath & " /" & url .path );
13
+ // Avoid traversals
14
+ if ( ! findNoCase ( rootpath , targetPath ) ){
15
+ targetPath = rootpath ;
16
+ }
17
+ }
18
+ // Get the actual execution path
19
+ executePath = rootMapping & ( len ( url .path ) ? " /#url .path #" : " /" );
20
+ // Directory Runner
21
+ if ( ! isNull ( url .action ) ){
22
+ if ( directoryExists ( targetPath ) ){
23
+ writeOutput ( " #new testbox .system .TestBox ( directory = executePath ).run () #" );
24
+ } else {
25
+ writeOutput ( " <h2>Invalid Directory: #encodeForHTML ( targetPath ) #</h2>" );
26
+ }
27
+ abort ;
28
+ }
29
+ // Get target path listing
30
+ qResults = directoryList ( targetPath , false , " query" , " " , " name" );
31
+ // Get the back path
32
+ if ( len ( url .path ) ){
33
+ backPath = url .path .listToArray ( " /\" );
34
+ backPath .pop ();
35
+ backPath = backPath .toList ( " /" );
36
+ }
37
+ // TestBox Assets
38
+ ASSETS_DIR = expandPath ( " /testbox/system/reports/assets" );
39
+ TESTBOX_VERSION = new testBox .system .TestBox ().getVersion ();
40
+ </cfscript >
46
41
<!DOCTYPE html>
47
42
<html >
48
43
<head >
49
44
<meta charset =" utf-8" >
50
- <meta name =" generator" content =" TestBox v#testbox . getVersion () #" >
45
+ <meta name =" generator" content =" TestBox v#TESTBOX_VERSION #" >
51
46
<title >TestBox Browser</title >
52
47
<cfoutput >
53
48
<style >#fileRead( '#ASSETS_DIR #/css/main .css' )#</style >
56
51
<script > #fileRead( '#ASSETS_DIR #/js/bootstrap.min .js' )#</script >
57
52
<script > #fileRead( '#ASSETS_DIR #/js/stupidtable.min .js' )#</script >
58
53
</cfoutput>
59
-
60
54
</head >
61
55
<cfoutput>
62
56
<body >
63
57
64
- <!--- Title --->
65
58
<div id="tb-runner " class="container">
59
+
60
+ <!--- Header --->
66
61
<div class="row">
67
62
<div class="col-md-4 text-center mx-auto ">
68
63
<img class="mt-3 " src="http://www.ortussolutions .com/__media/testbox-185 .png" alt="TestBox" id="tb-logo "/>
69
64
<br >
70
- v#testbox .getVersion() #
65
+ v#TESTBOX_VERSION #
71
66
<br >
72
- <a href="index.cfm?action=runTestBox&path=#URLEncodedFormat( url.path )#" target="_blank"> <button class="btn btn-primary btn-sm my-1 " type="button"> Run All</button > </a >
67
+ <a
68
+ href="index.cfm?action=runTestBox&path=#URLEncodedFormat( url.path )#"
69
+ target="_blank"
70
+ >
71
+ <button
72
+ class="btn btn-primary btn-sm my-1 "
73
+ type="button">
74
+ Run All
75
+ </button >
76
+ </a >
73
77
</div >
74
78
</div >
79
+
80
+ <!--- Runners --->
81
+ <div class="row">
82
+ <div class="col-md-12 mb-4 ">
83
+ <h2 > Availble Test Runners: </h2 >
84
+ <p >
85
+ Below is a listing of the runners matching the "runner* .cfm" pattern .
86
+ </p >
87
+
88
+ <cfset runners = directoryList( expandPath( "./" ), false, "query", "runner* .cfm" )>
89
+ <cfoutput query =" runners" >
90
+ <a href =" #runners .name #" target =" _blank" class =" btn btn-secondary btn-sm my-1 mx-1" >#runners .name #</a >
91
+ </cfoutput >
92
+ </div >
93
+ </div >
94
+
95
+ <!--- Listing --->
75
96
<div class =" row" >
76
97
<div class =" col-md-12" >
77
98
<form name =" runnerForm" id =" runnerForm" >
78
99
<input type =" hidden" name =" opt_run" id =" opt_run" value =" true" >
79
100
<h2 >TestBox Test Browser: </h2 >
80
101
<p >
81
- Below is a listing of the files and folders starting from your root <code > #rootPath #</code > . You can click on individual tests in order to execute them
102
+ Below is a listing of the files and folders starting from your root <code > #rootMapping #</code > . You can click on individual tests in order to execute them
82
103
or click on the <strong > Run All</strong > button on your left and it will execute a directory runner from the visible folder.
83
104
</p >
84
105
85
106
<fieldset >
86
- <legend > Contents: #executePath #</legend >
87
- <cfif url.path neq "/">
88
- <a href =" index.cfm?path=#URLEncodedFormat ( backPath ) #" ><button type =" button" class =" btn btn-secondary btn-sm my-1" >« Back</button > </a > <br > <hr >
107
+ <legend > #targetPath .replace( rootPath, "" )#</legend >
108
+
109
+ <!--- Show Back If we are traversing --->
110
+ <cfif len( url.path )>
111
+ <a href =" index.cfm?path=#URLEncodedFormat ( backPath ) #" >
112
+ <button type =" button" class =" btn btn-secondary btn-sm my-1" >& ##xAB; Back</button >
113
+ </a >
114
+ <br >
115
+ <hr >
89
116
</cfif>
117
+
90
118
<cfloop query="qResults">
119
+ <!--- Skip . folder file names --->
91
120
<cfif refind( "^\. ", qResults.name )>
92
121
<cfcontinue >
93
122
</cfif >
94
123
95
- <cfset dirPath = URLEncodedFormat ( ( url .path neq ' /' ? ' #url .path #/' : ' /' ) & qResults .name ) >
96
124
<cfif qResults .type eq " Dir" >
97
- <a class =" btn btn-secondary btn-sm my-1" href =" index.cfm?path=#dirPath #" >✚ #qResults .name #</a > <br/>
125
+ <a
126
+ class =" btn btn-secondary btn-sm my-1"
127
+ href =" index.cfm?path=#urlEncodedFormat ( url .path & " /" & qResults .name ) #"
128
+ >
129
+ & ##x271A; #qResults .name #
130
+ </a >
131
+ <br />
98
132
<cfelseif listLast ( qresults .name , " ." ) eq " cfm" >
99
- <a class =" btn btn-primary btn-sm my-1" href =" #executePath & qResults .name #" <cfif ! url .cpu >target =" _blank" </cfif >>#qResults .name #</a > <br/>
133
+ <a
134
+ class =" btn btn-primary btn-sm my-1"
135
+ href =" #executePath & " /" & qResults .name #"
136
+ target =" _blank"
137
+ >
138
+ #qResults .name #
139
+ </a >
140
+ <br />
100
141
<cfelseif listLast ( qresults .name , " ." ) eq " cfc" and qresults .name neq " Application.cfc" >
101
- <a class =" btn btn-primary btn-sm my-1" href =" #executePath & qResults .name #?method=runRemote" <cfif ! url .cpu >target =" _blank" </cfif >>#qResults .name #</a > <br/>
142
+ <a
143
+ class =" btn btn-primary btn-sm my-1"
144
+ href =" #executePath & " /" & qResults .name #?method=runRemote"
145
+ target =" _blank"
146
+ >
147
+ #qResults .name #
148
+ </a >
149
+ <br />
102
150
<cfelse >
103
- #qResults .name #<br/>
151
+ #qResults .name #
152
+ <br/>
104
153
</cfif >
105
154
106
155
</cfloop >
112
161
113
162
</body >
114
163
</html >
115
- </cfoutput >
164
+ </cfoutput >
0 commit comments