Skip to content

Commit 87b94e0

Browse files
committed
updated test browser to latest version
1 parent e483b96 commit 87b94e0

File tree

1 file changed

+109
-60
lines changed

1 file changed

+109
-60
lines changed

test-harness/tests/index.cfm

Lines changed: 109 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
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>
4641
<!DOCTYPE html>
4742
<html>
4843
<head>
4944
<meta charset="utf-8">
50-
<meta name="generator" content="TestBox v#testbox.getVersion()#">
45+
<meta name="generator" content="TestBox v#TESTBOX_VERSION#">
5146
<title>TestBox Browser</title>
5247
<cfoutput>
5348
<style>#fileRead( '#ASSETS_DIR#/css/main.css' )#</style>
@@ -56,51 +51,105 @@
5651
<script>#fileRead( '#ASSETS_DIR#/js/bootstrap.min.js' )#</script>
5752
<script>#fileRead( '#ASSETS_DIR#/js/stupidtable.min.js' )#</script>
5853
</cfoutput>
59-
6054
</head>
6155
<cfoutput>
6256
<body>
6357
64-
<!--- Title --->
6558
<div id="tb-runner" class="container">
59+
60+
<!--- Header --->
6661
<div class="row">
6762
<div class="col-md-4 text-center mx-auto">
6863
<img class="mt-3" src="http://www.ortussolutions.com/__media/testbox-185.png" alt="TestBox" id="tb-logo"/>
6964
<br>
70-
v#testbox.getVersion()#
65+
v#TESTBOX_VERSION#
7166
<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>
7377
</div>
7478
</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 --->
7596
<div class="row">
7697
<div class="col-md-12">
7798
<form name="runnerForm" id="runnerForm">
7899
<input type="hidden" name="opt_run" id="opt_run" value="true">
79100
<h2>TestBox Test Browser: </h2>
80101
<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
82103
or click on the <strong>Run All</strong> button on your left and it will execute a directory runner from the visible folder.
83104
</p>
84105
85106
<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>
89116
</cfif>
117+
90118
<cfloop query="qResults">
119+
<!--- Skip . folder file names --->
91120
<cfif refind( "^\.", qResults.name )>
92121
<cfcontinue>
93122
</cfif>
94123
95-
<cfset dirPath = URLEncodedFormat( ( url.path neq '/' ? '#url.path#/' : '/' ) & qResults.name )>
96124
<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 />
98132
<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 />
100141
<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 />
102150
<cfelse>
103-
#qResults.name#<br/>
151+
#qResults.name#
152+
<br/>
104153
</cfif>
105154
106155
</cfloop>
@@ -112,4 +161,4 @@
112161
113162
</body>
114163
</html>
115-
</cfoutput>
164+
</cfoutput>

0 commit comments

Comments
 (0)