Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5233d3

Browse files
authored
Merge pull requestmicrosoft#24003 from Microsoft/useEdgeForBrowserTests
Default to 'edge' instead of 'IE' for browser tests
2 parents20f9493 +d06f9c2 commitb5233d3

File tree

3 files changed

+110
-64
lines changed

3 files changed

+110
-64
lines changed

‎Gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5454
debug:process.env.debug||process.env["debug-brk"]||process.env.d,
5555
inspect:process.env.inspect||process.env["inspect-brk"]||process.env.i,
5656
host:process.env.TYPESCRIPT_HOST||process.env.host||"node",
57-
browser:process.env.browser||process.env.b||"IE",
57+
browser:process.env.browser||process.env.b||(os.platform()==="win32" ?"edge" :"chrome"),
5858
timeout:process.env.timeout||40000,
5959
tests:process.env.test||process.env.tests||process.env.t,
6060
runners:process.env.runners||process.env.runner||process.env.ru,

‎Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is
922922
task("runtests-browser",["browserify",nodeServerOutFile],function(){
923923
cleanTestDirs();
924924
host="node";
925-
varbrowser=process.env.browser||process.env.b||(os.platform()==="linux" ?"chrome" :"IE");
925+
varbrowser=process.env.browser||process.env.b||(os.platform()==="win32" ?"edge" :"chrome");
926926
varrunners=process.env.runners||process.env.runner||process.env.ru;
927927
vartests=process.env.test||process.env.tests||process.env.t;
928928
varlight=process.env.light||false;

‎tests/webTestServer.ts

Lines changed: 108 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference types="node" />
22
// tslint:disable:no-null-keyword
33

4+
importminimist= require("minimist");
45
importhttp= require("http");
56
importfs= require("fs");
67
importpath= require("path");
@@ -20,7 +21,8 @@ const baseUrl = new URL(`http://localhost:${port}/`);
2021
constrootDir=path.dirname(__dirname);
2122
constuseCaseSensitiveFileNames=isFileSystemCaseSensitive();
2223

23-
letbrowser="IE";
24+
constdefaultBrowser=os.platform()==="win32" ?"edge" :"chrome";
25+
letbrowser:"edge"|"chrome"|"none"=defaultBrowser;
2426
letgrep:string|undefined;
2527
letverbose=false;
2628

@@ -862,93 +864,137 @@ function startServer() {
862864
returnhttp.createServer(handleRequest).listen(port);
863865
}
864866

867+
constREG_COLUMN_PADDING=4;
868+
869+
functionqueryRegistryValue(keyPath:string,callback:(error:Error|null,value:string)=>void){
870+
constargs=["query",keyPath];
871+
child_process.execFile("reg",["query",keyPath,"/ve"],{encoding:"utf8"},(error,stdout)=>{
872+
if(error)returncallback(error,null);
873+
874+
constvalueLine=stdout.replace(/^\r\n.+?\r\n|\r\n\r\n$/g,"");
875+
if(!valueLine){
876+
returncallback(newError("Unable to retrieve value."),null);
877+
}
878+
879+
constvalueNameColumnOffset=REG_COLUMN_PADDING;
880+
if(valueLine.lastIndexOf("(Default)",valueNameColumnOffset)!==valueNameColumnOffset){
881+
returncallback(newError("Unable to retrieve value."),null);
882+
}
883+
884+
constdataTypeColumnOffset=valueNameColumnOffset+"(Default)".length+REG_COLUMN_PADDING;
885+
if(valueLine.lastIndexOf("REG_SZ",dataTypeColumnOffset)!==dataTypeColumnOffset){
886+
returncallback(newError("Unable to retrieve value."),null);
887+
}
888+
889+
constvalueColumnOffset=dataTypeColumnOffset+"REG_SZ".length+REG_COLUMN_PADDING;
890+
constvalue=valueLine.slice(valueColumnOffset);
891+
returncallback(null,value);
892+
});
893+
}
894+
895+
interfaceBrowser{
896+
description:string;
897+
command:string;
898+
}
899+
900+
functioncreateBrowserFromPath(path:string):Browser{
901+
return{description:path,command:path};
902+
}
903+
904+
functiongetChromePath(callback:(error:Error|null,browser:Browser|string|null)=>void){
905+
switch(os.platform()){
906+
case"win32":
907+
returnqueryRegistryValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe",(error,value)=>{
908+
if(error)returncallback(null,"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
909+
returncallback(null,createBrowserFromPath(value));
910+
});
911+
case"darwin":returncallback(null,"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
912+
case"linux":returncallback(null,"/opt/google/chrome/chrome");
913+
default:returncallback(newError(`Chrome location is unknown for platform '${os.platform()}'`),null);
914+
}
915+
}
916+
917+
functiongetEdgePath(callback:(error:Error|null,browser:Browser|null)=>void){
918+
switch(os.platform()){
919+
case"win32":returncallback(null,{description:"Microsoft Edge",command:"cmd /c start microsoft-edge:%1"});
920+
default:returncallback(newError(`Edge location is unknown for platform '${os.platform()}'`),null);
921+
}
922+
}
923+
924+
functiongetBrowserPath(callback:(error:Error|null,browser:Browser|null)=>void){
925+
switch(browser){
926+
case"chrome":returngetChromePath(afterGetBrowserPath);
927+
case"edge":returngetEdgePath(afterGetBrowserPath);
928+
default:returncallback(newError(`Browser location is unknown for '${browser}'`),null);
929+
}
930+
931+
functionafterGetBrowserPath(error:Error|null,browser:Browser|string|null){
932+
if(error)returncallback(error,null);
933+
if(typeofbrowser==="object")returncallback(null,browser);
934+
returnfs.stat(browser,(error,stats)=>{
935+
if(!error&&stats.isFile()){
936+
returncallback(null,createBrowserFromPath(browser));
937+
}
938+
if(browser==="chrome")returncallback(null,createBrowserFromPath("chrome"));
939+
returncallback(newError(`Browser location is unknown for '${browser}'`),null);
940+
});
941+
}
942+
}
943+
865944
functionstartClient(server:http.Server){
866945
letbrowserPath:string;
867946
if(browser==="none"){
868947
return;
869948
}
870949

871-
if(browser==="chrome"){
872-
letdefaultChromePath="";
873-
switch(os.platform()){
874-
case"win32":
875-
defaultChromePath="C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
876-
break;
877-
case"darwin":
878-
defaultChromePath="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
879-
break;
880-
case"linux":
881-
defaultChromePath="/opt/google/chrome/chrome";
882-
break;
883-
default:
884-
console.log(`default Chrome location is unknown for platform '${os.platform()}'`);
885-
break;
886-
}
887-
if(fs.existsSync(defaultChromePath)){
888-
browserPath=defaultChromePath;
889-
}
890-
else{
891-
browserPath=browser;
892-
}
893-
}
894-
else{
895-
constdefaultIEPath="C:/Program Files/Internet Explorer/iexplore.exe";
896-
if(fs.existsSync(defaultIEPath)){
897-
browserPath=defaultIEPath;
950+
getBrowserPath((error,browser)=>{
951+
if(error)returnconsole.error(error);
952+
console.log(`Using browser:${browser.description}`);
953+
constqueryString=grep ?`?grep=${grep}` :"";
954+
constargs=[`http://localhost:${port}/tests/webTestResults.html${queryString}`];
955+
if(browser.command.indexOf("%")===-1){
956+
child_process.spawn(browser.command,args);
898957
}
899958
else{
900-
browserPath=browser;
959+
constcommand=browser.command.replace(/%(\d+)/g,(_,offset)=>args[+offset-1]);
960+
child_process.exec(command);
901961
}
902-
}
903-
904-
console.log(`Using browser:${browserPath}`);
905-
906-
constqueryString=grep ?`?grep=${grep}` :"";
907-
constchild=child_process.spawn(browserPath,[`http://localhost:${port}/tests/webTestResults.html${queryString}`],{
908-
stdio:"inherit"
909962
});
910963
}
911964

912965
functionprintHelp(){
913966
console.log("Runs an http server on port 8888, looking for tests folder in the current directory\n");
914967
console.log("Syntax: node webTestServer.js [browser] [tests] [--verbose]\n");
915968
console.log("Options:");
916-
console.log(" <browser> The browser to launch. One of 'IE', 'chrome', or 'none' (default 'IE').");
969+
console.log(" <browser> The browser to launch. One of 'edge', 'chrome', or 'none' (default 'edge' on Windows, otherwise `chrome`).");
917970
console.log(" <tests> A regular expression to pass to Mocha.");
918971
console.log(" --verbose Enables verbose logging.");
919972
}
920973

921974
functionparseCommandLine(args:string[]){
922-
letoffset=0;
923-
for(constargofargs){
924-
constargLower=arg.toLowerCase();
925-
if(argLower==="--help"){
926-
printHelp();
927-
returnfalse;
928-
}
929-
elseif(argLower==="--verbose"){
930-
verbose=true;
931-
}
932-
else{
933-
if(offset===0){
934-
browser=arg;
935-
}
936-
elseif(offset===1){
937-
grep=arg;
938-
}
939-
else{
940-
console.log(`Unrecognized argument:${arg}\n`);
941-
returnfalse;
942-
}
943-
offset++;
944-
}
975+
constparsed=minimist(args,{boolean:["help","verbose"]});
976+
if(parsed.help){
977+
printHelp();
978+
returnfalse;
979+
}
980+
981+
if(parsed.verbose){
982+
verbose=true;
983+
}
984+
985+
const[parsedBrowser=defaultBrowser,parsedGrep, ...unrecognized]=parsed._;
986+
if(parsedBrowser!=="edge"&&parsedBrowser!=="chrome"&&parsedBrowser!=="none"){
987+
console.log(`Unrecognized browser '${parsedBrowser}', expected 'edge', 'chrome', or 'none'.`);
988+
returnfalse;
945989
}
946990

947-
if(browser!=="IE"&&browser!=="chrome"&&browser!=="none"){
948-
console.log(`Unrecognizedbrowser '${browser}', expected 'IE' or 'chrome'.`);
991+
if(unrecognized.length>0){
992+
console.log(`Unrecognizedargument:${unrecognized[0]}`);
949993
returnfalse;
950994
}
951995

996+
browser=parsedBrowser;
997+
grep=parsedGrep;
952998
returntrue;
953999
}
9541000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp