test262/tools/TestCaseHTMLPackager/TestCasePackager.ps1
David Fugate 7396642963 This commit includes Microsoft's initial contributions to Test262:
- external\contributions\: test contributions to Test262 from external entities such as Microsoft and Google.
                           This directory consists of the external tests without any modifications
- test\harness\:  test harness used to run Test262 tests.  Presently web-based
- test\suite\:    suite of vendor-neutral ECMAScript test cases conforming to the ES5 spec
- tools\:         among other things this includes a set of tools used to convert various external test
                  contributions to a format the Test262 test harness can consume
- website\:       an archived copy of the http://test262.ecmascript.org website
2010-10-18 20:50:07 -07:00

85 lines
7.0 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
$utf8=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")
$sectionEl.Attributes.Append($sectionAttr)
$numTestAttr=$testsList.CreateAttribute("numTests")
$sectionEl.Attributes.Append($numTestAttr)
$testEl= $testsList.CreateElement("test")
$testAttr=$testsList.CreateAttribute("id")
$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()
$newTestEl.GetAttributeNode("id").innerText=$testName
$scriptCode=Get-Content $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($utf8.GetBytes($comments+$scriptCodeContent))
$cdata=$testsList.CreateCDataSection($scriptCodeContent)
$newTestEl.AppendChild($cdata)
$newSection.AppendChild($newTestel)
}
else
{
$excluded++
}
}
$newSection.numTests=($sourceFiles.Length-$excluded ).ToString()
$testsList.testCollection.AppendChild($newSection)
$baseDir=$chapters[0].Parent.FullName
$testGroupPathname=$baseDir+"\"+$chapter.Name+".xml"
$testsList.Save($testGroupPathname)
$testGroupEl=$masterList.CreateElement("testGroup")
$testGroupEl.innerText=$webRootPath+$chapter.Name+".xml"
$masterList["testSuite"].AppendChild($testGroupEl)
$numTests+= $sourceFiles.Length-$excluded
}
}
$masterList["testSuite"].GetAttributeNode("numTests").innerText=$numTests
$masterList["testSuite"].GetAttributeNode("version").innerText=$suiteVersion
$masterList["testSuite"].GetAttributeNode("date").innerText=[datetime]::Now.Date.toString("MM/dd/yyyy")
$masterList.Save($baseDir+"\testcaseslist.xml")