mirror of
https://github.com/tc39/test262.git
synced 2025-10-17 05:48:56 +02:00
processing of unicode-related test cases. tools\TestCaseHTMLPackager\TestUpdater.ps1: new script which preprocesses test cases (rips out comments, etc.) external\contributions\Microsoft\ietestcenter_ppb5\chapter11\11.4\11.4.1\11.4.1-4.a-10.js and website\resources\scripts\testcases\chapter11\11.4\11.4.1\11.4.1-4.a-10.js: cleaned up a code comment website\enginereports\sample.xml: removed website\resources\scripts\global\jquery-1.4.2.js: removed website\resources\scripts\*.ps1: moved into the tools\ directory website\Web.config: removed. This is only relevant for Windows-based hosting of test262 website\browserreport.html: removed
89 lines
7.2 KiB
PowerShell
89 lines
7.2 KiB
PowerShell
param($rootDir, $webRootPath, $excludeListFilename, $suiteVersion)
|
||
|
||
|
||
|
||
|
||
$chapters = get-childitem $rootDir | where-object{$_.mode -match "d"}
|
||
$template='
|
||
<testCollection>
|
||
<!-- adding section element if in the future we want to store information about the -->
|
||
<!-- spec structure in this file, for now the section structure is defined in the -->
|
||
<!-- sections.js file -->
|
||
</testCollection>'
|
||
$templateMasterList='
|
||
<testSuite numTests="" version="" date="">
|
||
</testSuite>'
|
||
|
||
$masterList=[xml]$templateMasterList
|
||
$numTests=0
|
||
$utf8Encoding = New-Object System.Text.UTF8Encoding
|
||
[xml]$excludeList= get-content $excludeListFilename
|
||
|
||
foreach($chapter in $chapters)
|
||
{
|
||
$testsList = [xml] $template
|
||
$sectionEl = $testsList.CreateElement("section")
|
||
$sectionAttr=$testsList.CreateAttribute("name")
|
||
$null=$sectionEl.Attributes.Append($sectionAttr)
|
||
$numTestAttr=$testsList.CreateAttribute("numTests")
|
||
$null=$sectionEl.Attributes.Append($numTestAttr)
|
||
|
||
$testEl= $testsList.CreateElement("test")
|
||
$testAttr=$testsList.CreateAttribute("id")
|
||
$null=$testEl.Attributes.Append($testAttr)
|
||
$newSection=$sectionEl.clone()
|
||
$newSection.GetAttributeNode("name").innerText="Chapter - "+$Chapter.Name
|
||
$sourceFiles = get-childitem $chapter.FullName -include *.js -recurse | where-object{$_.mode -notmatch "d"}
|
||
if($sourceFiles -ne $NULL)
|
||
{
|
||
$excluded=0
|
||
foreach($test in $sourceFiles){
|
||
$testName=$test.Name.Remove($test.Name.Length-3)
|
||
if(($testName.length -gt 0) -and ($excludeList.excludeList.SelectNodes("test[@id ='"+$testName+"']").Count -eq 0))
|
||
{
|
||
$newTestEl=$testEl.clone()
|
||
$null=$newTestEl.GetAttributeNode("id").innerText=$testName
|
||
|
||
$scriptCode=Get-Content -Encoding UTF8 $test.FullName
|
||
|
||
$scriptCodeContent=""
|
||
foreach($line in $scriptCode){
|
||
$scriptCodeContent+=$line+"`r`n"
|
||
}
|
||
|
||
|
||
# remove comments
|
||
$hs5HarnessPos=$scriptCodeContent.IndexOf("ES5Harness")
|
||
$comments=$scriptCodeContent.Substring(0,$hs5HarnessPos)
|
||
$comments=$comments -replace "(//.*\n|/\*(.|\n)*?\*/)"
|
||
$scriptCodeContent=$scriptCodeContent.Substring($hs5HarnessPos)
|
||
|
||
$scriptCodeContent=[Convert]::ToBase64String($utf8Encoding.GetBytes($scriptCodeContent))
|
||
$cdata=$testsList.CreateCDataSection($scriptCodeContent)
|
||
$null=$newTestEl.AppendChild($cdata)
|
||
$null=$newSection.AppendChild($newTestel)
|
||
}
|
||
else
|
||
{
|
||
$excluded++
|
||
}
|
||
|
||
}
|
||
$newSection.numTests=($sourceFiles.Length-$excluded ).ToString()
|
||
$null=$testsList.testCollection.AppendChild($newSection)
|
||
$baseDir=$chapters[0].Parent.FullName
|
||
$testGroupPathname=$baseDir+"\"+$chapter.Name+".xml"
|
||
$null=$testsList.Save($testGroupPathname)
|
||
$testGroupEl=$masterList.CreateElement("testGroup")
|
||
$testGroupEl.innerText=$webRootPath+$chapter.Name+".xml"
|
||
$null=$masterList["testSuite"].AppendChild($testGroupEl)
|
||
|
||
$numTests+= $sourceFiles.Length-$excluded
|
||
|
||
}
|
||
}
|
||
$null=$masterList["testSuite"].GetAttributeNode("numTests").innerText=$numTests
|
||
$null=$masterList["testSuite"].GetAttributeNode("version").innerText=$suiteVersion
|
||
$null=$masterList["testSuite"].GetAttributeNode("date").innerText=[datetime]::Now.Date.toString("MM/dd/yyyy")
|
||
$null=$masterList.Save($baseDir+"\testcaseslist.xml")
|