Move test folder to project root (#519)
This commit is contained in:
Родитель
0db0be15f4
Коммит
3c172a0565
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
src/
|
src/
|
||||||
|
test/
|
||||||
.vscode-test/
|
.vscode-test/
|
||||||
|
|
||||||
tools/
|
tools/
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
.vscode-test/**
|
.vscode-test/**
|
||||||
.gitignore
|
.gitignore
|
||||||
src/**
|
src/**
|
||||||
|
test/**
|
||||||
out/test/**
|
out/test/**
|
||||||
**/*.js.map
|
**/*.js.map
|
||||||
SampleApplication/**
|
SampleApplication/**
|
||||||
|
|
10
gulpfile.js
10
gulpfile.js
|
@ -23,12 +23,13 @@ var imports = GulpExtras.checkImports;
|
||||||
var executeCommand = GulpExtras.executeCommand;
|
var executeCommand = GulpExtras.executeCommand;
|
||||||
|
|
||||||
var srcPath = "src";
|
var srcPath = "src";
|
||||||
|
var testPath = "test";
|
||||||
var outPath = "out";
|
var outPath = "out";
|
||||||
|
|
||||||
var sources = [
|
var sources = [
|
||||||
srcPath,
|
srcPath,
|
||||||
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; })
|
testPath,
|
||||||
.concat(["test/*.ts"]);
|
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
|
||||||
|
|
||||||
var knownOptions = {
|
var knownOptions = {
|
||||||
string: "env",
|
string: "env",
|
||||||
|
@ -76,10 +77,11 @@ gulp.task("default", function (callback) {
|
||||||
|
|
||||||
var lintSources = [
|
var lintSources = [
|
||||||
srcPath,
|
srcPath,
|
||||||
|
testPath
|
||||||
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
|
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
|
||||||
lintSources = lintSources.concat([
|
lintSources = lintSources.concat([
|
||||||
"!src/typings/**",
|
"!src/typings/**",
|
||||||
"!src/test/resources/sampleReactNative022Project/**",
|
"!test/resources/sampleReactNative022Project/**",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var libtslint = require("tslint");
|
var libtslint = require("tslint");
|
||||||
|
@ -167,7 +169,7 @@ gulp.task("check-copyright", function (cb) {
|
||||||
"!node_modules/**",
|
"!node_modules/**",
|
||||||
"!out/test/**/*.js",
|
"!out/test/**/*.js",
|
||||||
"!SampleApplication/**",
|
"!SampleApplication/**",
|
||||||
"!src/test/resources/sampleReactNative022Project/**/*.js",
|
"!test/resources/sampleReactNative022Project/**/*.js",
|
||||||
])
|
])
|
||||||
.pipe(copyright());
|
.pipe(copyright());
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import * as path from "path";
|
|
||||||
import {InternalError, NestedError, InternalErrorLevel} from "./internalError";
|
import {InternalError, NestedError, InternalErrorLevel} from "./internalError";
|
||||||
import {InternalErrorCode} from "./internalErrorCode";
|
import {InternalErrorCode} from "./internalErrorCode";
|
||||||
|
import {ERROR_STRINGS} from "./errorStrings";
|
||||||
|
|
||||||
export class ErrorHelper {
|
export class ErrorHelper {
|
||||||
private static errorStringsJsonLoc = path.resolve(__dirname, "..", "..", "..", "errorStrings", "errorStrings.json");
|
public static ERROR_STRINGS = ERROR_STRINGS;
|
||||||
public static getInternalError(errorCode: InternalErrorCode, ...optionalArgs: any[]): InternalError {
|
public static getInternalError(errorCode: InternalErrorCode, ...optionalArgs: any[]): InternalError {
|
||||||
let message = ErrorHelper.getErrorMessage(errorCode, ...optionalArgs);
|
let message = ErrorHelper.getErrorMessage(errorCode, ...optionalArgs);
|
||||||
return new InternalError(<number> errorCode, message);
|
return new InternalError(<number> errorCode, message);
|
||||||
|
@ -29,8 +29,7 @@ export class ErrorHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getErrorMessage(errorCode: InternalErrorCode, ...optionalArgs: any[]): string {
|
private static getErrorMessage(errorCode: InternalErrorCode, ...optionalArgs: any[]): string {
|
||||||
let errorStrings = require (ErrorHelper.errorStringsJsonLoc);
|
return ErrorHelper.formatErrorMessage(ErrorHelper.ERROR_STRINGS[InternalErrorCode[errorCode]], ...optionalArgs);
|
||||||
return ErrorHelper.formatErrorMessage(errorStrings[InternalErrorCode[errorCode]], ...optionalArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static formatErrorMessage(errorMessage: string, ...optionalArgs: any[]): string {
|
private static formatErrorMessage(errorMessage: string, ...optionalArgs: any[]): string {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
|
export const ERROR_STRINGS = {
|
||||||
"CommandFailed": "Error while executing command '{0}'",
|
"CommandFailed": "Error while executing command '{0}'",
|
||||||
"CommandFailedWithErrorCode": "Command '{0}' failed with error code {1}",
|
"CommandFailedWithErrorCode": "Command '{0}' failed with error code {1}",
|
||||||
"ExpectedIntegerValue": "Expected an integer. Couldn't read {0}",
|
"ExpectedIntegerValue": "Expected an integer. Couldn't read {0}",
|
||||||
|
@ -14,7 +17,7 @@
|
||||||
"PlatformNotSupported": "Platform '{0}' is not supported on host platform: {1}",
|
"PlatformNotSupported": "Platform '{0}' is not supported on host platform: {1}",
|
||||||
"ProjectVersionNotParsable": "Couldn't parse the version component of the package at {0}: version = {1}",
|
"ProjectVersionNotParsable": "Couldn't parse the version component of the package at {0}: version = {1}",
|
||||||
"ProjectVersionUnsupported": "Project version = {0}",
|
"ProjectVersionUnsupported": "Project version = {0}",
|
||||||
"ProjectVersionNotReadable":"Unable to read version = {0}",
|
"ProjectVersionNotReadable": "Unable to read version = {0}",
|
||||||
"TelemetryInitializationFailed": "{0}. Couldn't initialize telemetry",
|
"TelemetryInitializationFailed": "{0}. Couldn't initialize telemetry",
|
||||||
"ExtensionActivationFailed": "Failed to activate the React Native Tools extension",
|
"ExtensionActivationFailed": "Failed to activate the React Native Tools extension",
|
||||||
"DebuggerStubLauncherFailed": "Failed to setup the stub launcher for the debugger",
|
"DebuggerStubLauncherFailed": "Failed to setup the stub launcher for the debugger",
|
||||||
|
@ -32,5 +35,5 @@
|
||||||
"CouldNotFindLocationOfNodeDebugger": "Couldn't find the location of the node-debugger extension",
|
"CouldNotFindLocationOfNodeDebugger": "Couldn't find the location of the node-debugger extension",
|
||||||
"PackagerRunningInDifferentPort": "A packager cannot be started on port {0} because a packager process is already running on port {1}",
|
"PackagerRunningInDifferentPort": "A packager cannot be started on port {0} because a packager process is already running on port {1}",
|
||||||
"ErrorWhileProcessingMessageInIPMSServer": "An error ocurred while handling message: {0}",
|
"ErrorWhileProcessingMessageInIPMSServer": "An error ocurred while handling message: {0}",
|
||||||
"ErrorNoPipeFound": "Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?"
|
"ErrorNoPipeFound": "Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?",
|
||||||
}
|
};
|
|
@ -16,7 +16,7 @@ export enum InternalErrorCode {
|
||||||
FailedToPublishToExpHost = 111,
|
FailedToPublishToExpHost = 111,
|
||||||
|
|
||||||
// Device Deployer errors
|
// Device Deployer errors
|
||||||
IDeviceInstallerNotFound = 201,
|
IOSDeployNotFound = 201,
|
||||||
|
|
||||||
// Device Runner errors
|
// Device Runner errors
|
||||||
DeviceNotPluggedIn = 301,
|
DeviceNotPluggedIn = 301,
|
||||||
|
|
|
@ -13,10 +13,7 @@ import {PlistBuddy} from "../../common/ios/plistBuddy";
|
||||||
import {IOSDebugModeManager} from "../../common/ios/iOSDebugModeManager";
|
import {IOSDebugModeManager} from "../../common/ios/iOSDebugModeManager";
|
||||||
import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
|
import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
|
||||||
import {RemoteExtension} from "../../common/remoteExtension";
|
import {RemoteExtension} from "../../common/remoteExtension";
|
||||||
|
import {ErrorHelper} from "../../common/error/errorHelper";
|
||||||
/* tslint:disable:no-var-requires */
|
|
||||||
const ErrorStrings = require("../../../errorStrings/errorStrings.json");
|
|
||||||
/* tslint:enable:no-var-requires */
|
|
||||||
|
|
||||||
export class IOSPlatform extends GeneralMobilePlatform {
|
export class IOSPlatform extends GeneralMobilePlatform {
|
||||||
public static DEFAULT_IOS_PROJECT_RELATIVE_PATH = "ios";
|
public static DEFAULT_IOS_PROJECT_RELATIVE_PATH = "ios";
|
||||||
|
@ -33,13 +30,13 @@ export class IOSPlatform extends GeneralMobilePlatform {
|
||||||
// We should add the common iOS build/run erros we find to this list
|
// We should add the common iOS build/run erros we find to this list
|
||||||
private static RUN_IOS_FAILURE_PATTERNS: PatternToFailure[] = [{
|
private static RUN_IOS_FAILURE_PATTERNS: PatternToFailure[] = [{
|
||||||
pattern: "No devices are booted",
|
pattern: "No devices are booted",
|
||||||
message: ErrorStrings.IOSSimulatorNotLaunchable,
|
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
|
||||||
}, {
|
}, {
|
||||||
pattern: "FBSOpenApplicationErrorDomain",
|
pattern: "FBSOpenApplicationErrorDomain",
|
||||||
message: ErrorStrings.IOSSimulatorNotLaunchable,
|
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
|
||||||
}, {
|
}, {
|
||||||
pattern: "ios-deploy",
|
pattern: "ios-deploy",
|
||||||
message: ErrorStrings.IOSDeployNotFound,
|
message: ErrorHelper.ERROR_STRINGS.IOSDeployNotFound,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
private static RUN_IOS_SUCCESS_PATTERNS = ["BUILD SUCCEEDED"];
|
private static RUN_IOS_SUCCESS_PATTERNS = ["BUILD SUCCEEDED"];
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {ErrorHelper} from "../error/errorHelper";
|
||||||
import {InternalErrorCode} from "../error/internalErrorCode";
|
import {InternalErrorCode} from "../error/internalErrorCode";
|
||||||
|
|
||||||
// Uncomment the following lines to record all spawned processes executions
|
// Uncomment the following lines to record all spawned processes executions
|
||||||
// import {Recorder} from "../../test/resources/processExecution/recorder";
|
// import {Recorder} from "../../../test/resources/processExecution/recorder";
|
||||||
// Recorder.installGlobalRecorder();
|
// Recorder.installGlobalRecorder();
|
||||||
|
|
||||||
export interface IExecResult {
|
export interface IExecResult {
|
||||||
|
|
|
@ -77,7 +77,7 @@ export class CommandPaletteHandler {
|
||||||
*/
|
*/
|
||||||
public publishToExpHost(): Q.Promise<void> {
|
public publishToExpHost(): Q.Promise<void> {
|
||||||
return this.executeCommandInContext("publishToExpHost", () => {
|
return this.executeCommandInContext("publishToExpHost", () => {
|
||||||
this.executePublishToExpHost().then((didPublish) => {
|
return this.executePublishToExpHost().then((didPublish) => {
|
||||||
if (!didPublish) {
|
if (!didPublish) {
|
||||||
Log.logMessage("Publishing was unsuccessful. Please make sure you are logged in Exponent and your project is a valid Exponentjs project");
|
Log.logMessage("Publishing was unsuccessful. Please make sure you are logged in Exponent and your project is a valid Exponentjs project");
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ export class CommandPaletteHandler {
|
||||||
* Otherwise, displays an error message banner
|
* Otherwise, displays an error message banner
|
||||||
* {operation} - a function that performs the expected operation
|
* {operation} - a function that performs the expected operation
|
||||||
*/
|
*/
|
||||||
private executeCommandInContext(rnCommand: string, operation: () => Q.Promise<void> | void): Q.Promise<void> {
|
private executeCommandInContext(rnCommand: string, operation: () => Q.Promise<void>): Q.Promise<void> {
|
||||||
let reactNativeProjectHelper = new ReactNativeProjectHelper(this.workspaceRoot);
|
let reactNativeProjectHelper = new ReactNativeProjectHelper(this.workspaceRoot);
|
||||||
return TelemetryHelper.generate("RNCommand", (generator) => {
|
return TelemetryHelper.generate("RNCommand", (generator) => {
|
||||||
generator.add("command", rnCommand, false);
|
generator.add("command", rnCommand, false);
|
||||||
|
@ -178,6 +178,7 @@ export class CommandPaletteHandler {
|
||||||
return operation();
|
return operation();
|
||||||
} else {
|
} else {
|
||||||
vscode.window.showErrorMessage("Current workspace is not a React Native project.");
|
vscode.window.showErrorMessage("Current workspace is not a React Native project.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {CommandExecutor} from "../../common/commandExecutor";
|
import {CommandExecutor} from "../../src/common/commandExecutor";
|
||||||
import { Log } from "../../common/log/log";
|
import { Log } from "../../src/common/log/log";
|
||||||
|
|
||||||
import { Node } from "../../common/node/node";
|
import { Node } from "../../src/common/node/node";
|
||||||
import { ChildProcess } from "../../common/node/childProcess";
|
import { ChildProcess } from "../../src/common/node/childProcess";
|
||||||
|
|
||||||
|
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {ExtensionMessage, MessagingChannel} from "../../common/extensionMessaging";
|
import {ExtensionMessage, MessagingChannel} from "../../src/common/extensionMessaging";
|
||||||
|
|
||||||
import {RemoteExtension} from "../../common/remoteExtension";
|
import {RemoteExtension} from "../../src/common/remoteExtension";
|
||||||
|
|
||||||
import {InterProcessMessageSender} from "../../common/interProcessMessageSender";
|
import {InterProcessMessageSender} from "../../src/common/interProcessMessageSender";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as net from "net";
|
import * as net from "net";
|
|
@ -1,106 +1,106 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {PlistBuddy} from "../../../common/ios/plistBuddy";
|
import {PlistBuddy} from "../../../src/common/ios/plistBuddy";
|
||||||
|
|
||||||
import {IXcodeProjFile} from "../../../common/ios/xcodeproj";
|
import {IXcodeProjFile} from "../../../src/common/ios/xcodeproj";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
suite("plistBuddy", function() {
|
suite("plistBuddy", function() {
|
||||||
suite("commonContext", function() {
|
suite("commonContext", function() {
|
||||||
test("setPlistProperty should attempt to modify, then add, plist properties", function() {
|
test("setPlistProperty should attempt to modify, then add, plist properties", function() {
|
||||||
const plistFileName = "testFile.plist";
|
const plistFileName = "testFile.plist";
|
||||||
const plistProperty = ":RCTDevMenu:ExecutorClass";
|
const plistProperty = ":RCTDevMenu:ExecutorClass";
|
||||||
const plistValue = "RCTWebSocketExecutor";
|
const plistValue = "RCTWebSocketExecutor";
|
||||||
|
|
||||||
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
|
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
|
||||||
const addCallArgs = `/usr/libexec/PlistBuddy -c 'Add ${plistProperty} string ${plistValue}' '${plistFileName}'`;
|
const addCallArgs = `/usr/libexec/PlistBuddy -c 'Add ${plistProperty} string ${plistValue}' '${plistFileName}'`;
|
||||||
|
|
||||||
const mockedExecFunc = sinon.stub();
|
const mockedExecFunc = sinon.stub();
|
||||||
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.reject(new Error("Setting does not exist")) });
|
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.reject(new Error("Setting does not exist")) });
|
||||||
mockedExecFunc.withArgs(addCallArgs).returns({ outcome: Q.resolve("stdout") });
|
mockedExecFunc.withArgs(addCallArgs).returns({ outcome: Q.resolve("stdout") });
|
||||||
mockedExecFunc.throws();
|
mockedExecFunc.throws();
|
||||||
|
|
||||||
const mockChildProcess: any = {
|
const mockChildProcess: any = {
|
||||||
exec: mockedExecFunc,
|
exec: mockedExecFunc,
|
||||||
};
|
};
|
||||||
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
|
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
|
||||||
|
|
||||||
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
|
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
|
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
|
||||||
assert(mockedExecFunc.calledWithExactly(addCallArgs), "plistBuddy did not attempt to add after set failed");
|
assert(mockedExecFunc.calledWithExactly(addCallArgs), "plistBuddy did not attempt to add after set failed");
|
||||||
assert.equal(mockedExecFunc.callCount, 2);
|
assert.equal(mockedExecFunc.callCount, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("setPlistProperty should stop after modifying if the attempt succeeds", function() {
|
test("setPlistProperty should stop after modifying if the attempt succeeds", function() {
|
||||||
const plistFileName = "testFile.plist";
|
const plistFileName = "testFile.plist";
|
||||||
const plistProperty = ":RCTDevMenu:ExecutorClass";
|
const plistProperty = ":RCTDevMenu:ExecutorClass";
|
||||||
const plistValue = "RCTWebSocketExecutor";
|
const plistValue = "RCTWebSocketExecutor";
|
||||||
|
|
||||||
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
|
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
|
||||||
|
|
||||||
const mockedExecFunc = sinon.stub();
|
const mockedExecFunc = sinon.stub();
|
||||||
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.resolve("stdout") });
|
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.resolve("stdout") });
|
||||||
mockedExecFunc.throws();
|
mockedExecFunc.throws();
|
||||||
|
|
||||||
const mockChildProcess: any = {
|
const mockChildProcess: any = {
|
||||||
exec: mockedExecFunc,
|
exec: mockedExecFunc,
|
||||||
};
|
};
|
||||||
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
|
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
|
||||||
|
|
||||||
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
|
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
|
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
|
||||||
assert.equal(mockedExecFunc.callCount, 1);
|
assert.equal(mockedExecFunc.callCount, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getBundleId should return the bundle ID", function() {
|
test("getBundleId should return the bundle ID", function() {
|
||||||
const projectRoot = path.join("/", "userHome", "rnProject");
|
const projectRoot = path.join("/", "userHome", "rnProject");
|
||||||
const appName = "myApp";
|
const appName = "myApp";
|
||||||
|
|
||||||
const infoPlistPath = (simulator: boolean) =>
|
const infoPlistPath = (simulator: boolean) =>
|
||||||
path.join(projectRoot, "build", "Build", "Products",
|
path.join(projectRoot, "build", "Build", "Products",
|
||||||
simulator ? "Debug-iphonesimulator" : "Debug-iphoneos",
|
simulator ? "Debug-iphonesimulator" : "Debug-iphoneos",
|
||||||
`${appName}.app`, "Info.plist");
|
`${appName}.app`, "Info.plist");
|
||||||
|
|
||||||
const simulatorBundleId = "com.contoso.simulator";
|
const simulatorBundleId = "com.contoso.simulator";
|
||||||
const deviceBundleId = "com.contoso.device";
|
const deviceBundleId = "com.contoso.device";
|
||||||
|
|
||||||
const printExecCall = (simulator: boolean) => `/usr/libexec/PlistBuddy -c 'Print:CFBundleIdentifier' '${infoPlistPath(simulator)}'`;
|
const printExecCall = (simulator: boolean) => `/usr/libexec/PlistBuddy -c 'Print:CFBundleIdentifier' '${infoPlistPath(simulator)}'`;
|
||||||
|
|
||||||
const mockedExecFunc = sinon.stub();
|
const mockedExecFunc = sinon.stub();
|
||||||
mockedExecFunc.withArgs(printExecCall(true)).returns({outcome: Q.resolve(simulatorBundleId)});
|
mockedExecFunc.withArgs(printExecCall(true)).returns({outcome: Q.resolve(simulatorBundleId)});
|
||||||
mockedExecFunc.withArgs(printExecCall(false)).returns({outcome: Q.resolve(deviceBundleId)});
|
mockedExecFunc.withArgs(printExecCall(false)).returns({outcome: Q.resolve(deviceBundleId)});
|
||||||
const mockChildProcess: any = {
|
const mockChildProcess: any = {
|
||||||
exec: mockedExecFunc,
|
exec: mockedExecFunc,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockedFindXcodeprojFile = sinon.stub();
|
const mockedFindXcodeprojFile = sinon.stub();
|
||||||
const mockedProjResult: IXcodeProjFile = {
|
const mockedProjResult: IXcodeProjFile = {
|
||||||
fileName: appName + ".xcodeproj",
|
fileName: appName + ".xcodeproj",
|
||||||
fileType: ".xcodeproj",
|
fileType: ".xcodeproj",
|
||||||
projectName: appName,
|
projectName: appName,
|
||||||
};
|
};
|
||||||
mockedFindXcodeprojFile.withArgs(projectRoot).returns(Q.resolve(mockedProjResult));
|
mockedFindXcodeprojFile.withArgs(projectRoot).returns(Q.resolve(mockedProjResult));
|
||||||
const mockXcodeproj: any = {
|
const mockXcodeproj: any = {
|
||||||
findXcodeprojFile: mockedFindXcodeprojFile,
|
findXcodeprojFile: mockedFindXcodeprojFile,
|
||||||
};
|
};
|
||||||
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess, xcodeproj: mockXcodeproj });
|
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess, xcodeproj: mockXcodeproj });
|
||||||
|
|
||||||
return Q.all([
|
return Q.all([
|
||||||
plistBuddy.getBundleId(projectRoot, true),
|
plistBuddy.getBundleId(projectRoot, true),
|
||||||
plistBuddy.getBundleId(projectRoot, false),
|
plistBuddy.getBundleId(projectRoot, false),
|
||||||
]).spread((simulatorId, deviceId) => {
|
]).spread((simulatorId, deviceId) => {
|
||||||
assert.equal(simulatorBundleId, simulatorId);
|
assert.equal(simulatorBundleId, simulatorId);
|
||||||
assert.equal(deviceBundleId, deviceId);
|
assert.equal(deviceBundleId, deviceId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,77 +1,77 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {SimulatorPlist} from "../../../common/ios/simulatorPlist";
|
import {SimulatorPlist} from "../../../src/common/ios/simulatorPlist";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
suite("plistBuddy", function() {
|
suite("plistBuddy", function() {
|
||||||
suite("commonContext", function() {
|
suite("commonContext", function() {
|
||||||
test("findPlistFile should correctly find the NSUserDefaults plist file for the simulator", function() {
|
test("findPlistFile should correctly find the NSUserDefaults plist file for the simulator", function() {
|
||||||
const projectRoot = path.join("/", "tmp", "myProject");
|
const projectRoot = path.join("/", "tmp", "myProject");
|
||||||
|
|
||||||
const bundleId = "com.contoso.app";
|
const bundleId = "com.contoso.app";
|
||||||
|
|
||||||
const findSimulatorHomeCommand = "xcrun simctl getenv booted HOME";
|
const findSimulatorHomeCommand = "xcrun simctl getenv booted HOME";
|
||||||
// The emulator's home folder is /simulator/home
|
// The emulator's home folder is /simulator/home
|
||||||
const findSimulatorHomeResult = path.join("/", "Users", "theUser", "Library", "Developer", "CoreSimulaotr", "Devices", "FA511653-BA51-479F-A218-1DBD1910D5E5/data");
|
const findSimulatorHomeResult = path.join("/", "Users", "theUser", "Library", "Developer", "CoreSimulaotr", "Devices", "FA511653-BA51-479F-A218-1DBD1910D5E5/data");
|
||||||
|
|
||||||
const prefix = path.join("Containers", "Data", "Application");
|
const prefix = path.join("Containers", "Data", "Application");
|
||||||
const suffix = path.join("Library", "Preferences");
|
const suffix = path.join("Library", "Preferences");
|
||||||
|
|
||||||
// The emulator has 3 apps
|
// The emulator has 3 apps
|
||||||
const appIds = ["17F3AED1-5B1D-4F97-B419-D1F079D9DE2D",
|
const appIds = ["17F3AED1-5B1D-4F97-B419-D1F079D9DE2D",
|
||||||
"957660FD-3417-474E-B2AC-8AA0A05AD9A0",
|
"957660FD-3417-474E-B2AC-8AA0A05AD9A0",
|
||||||
"18319C8B-0583-4967-8023-15859A0BF0F3",
|
"18319C8B-0583-4967-8023-15859A0BF0F3",
|
||||||
];
|
];
|
||||||
|
|
||||||
// readdir finds appIds
|
// readdir finds appIds
|
||||||
const mockReadDir = sinon.stub();
|
const mockReadDir = sinon.stub();
|
||||||
mockReadDir.withArgs(path.join(findSimulatorHomeResult, prefix)).returns(Q.resolve(appIds));
|
mockReadDir.withArgs(path.join(findSimulatorHomeResult, prefix)).returns(Q.resolve(appIds));
|
||||||
mockReadDir.throws();
|
mockReadDir.throws();
|
||||||
|
|
||||||
// Only the second app has a plist file with thus bundle name
|
// Only the second app has a plist file with thus bundle name
|
||||||
const existingPlistFile = path.join(findSimulatorHomeResult, prefix, "957660FD-3417-474E-B2AC-8AA0A05AD9A0", suffix, `${bundleId}.plist`);
|
const existingPlistFile = path.join(findSimulatorHomeResult, prefix, "957660FD-3417-474E-B2AC-8AA0A05AD9A0", suffix, `${bundleId}.plist`);
|
||||||
|
|
||||||
// existsSync only finds existingPlistFile to exist
|
// existsSync only finds existingPlistFile to exist
|
||||||
const mockExistsSync = sinon.stub();
|
const mockExistsSync = sinon.stub();
|
||||||
mockExistsSync.withArgs(existingPlistFile).returns(true);
|
mockExistsSync.withArgs(existingPlistFile).returns(true);
|
||||||
mockExistsSync.returns(false);
|
mockExistsSync.returns(false);
|
||||||
|
|
||||||
const mockFS: any = {
|
const mockFS: any = {
|
||||||
existsSync: mockExistsSync,
|
existsSync: mockExistsSync,
|
||||||
readDir: mockReadDir,
|
readDir: mockReadDir,
|
||||||
};
|
};
|
||||||
|
|
||||||
// getBundleId returns bundleId
|
// getBundleId returns bundleId
|
||||||
const bundleIdStub = sinon.stub();
|
const bundleIdStub = sinon.stub();
|
||||||
bundleIdStub.withArgs(projectRoot).returns(Q.resolve(bundleId));
|
bundleIdStub.withArgs(projectRoot).returns(Q.resolve(bundleId));
|
||||||
bundleIdStub.returns(Q.reject("Incorrect project root"));
|
bundleIdStub.returns(Q.reject("Incorrect project root"));
|
||||||
|
|
||||||
const mockPlistBuddy: any = {
|
const mockPlistBuddy: any = {
|
||||||
getBundleId: bundleIdStub,
|
getBundleId: bundleIdStub,
|
||||||
};
|
};
|
||||||
|
|
||||||
// exec-ing the correct command returns the simulator home
|
// exec-ing the correct command returns the simulator home
|
||||||
const execStub = sinon.stub();
|
const execStub = sinon.stub();
|
||||||
execStub.withArgs(findSimulatorHomeCommand).returns({ outcome: Q.resolve(findSimulatorHomeResult) });
|
execStub.withArgs(findSimulatorHomeCommand).returns({ outcome: Q.resolve(findSimulatorHomeResult) });
|
||||||
execStub.throws();
|
execStub.throws();
|
||||||
const mockChildProcess: any = {
|
const mockChildProcess: any = {
|
||||||
exec: execStub,
|
exec: execStub,
|
||||||
};
|
};
|
||||||
|
|
||||||
const simulatorPlist = new SimulatorPlist(projectRoot, {
|
const simulatorPlist = new SimulatorPlist(projectRoot, {
|
||||||
nodeFileSystem: mockFS,
|
nodeFileSystem: mockFS,
|
||||||
plistBuddy: mockPlistBuddy,
|
plistBuddy: mockPlistBuddy,
|
||||||
nodeChildProcess: mockChildProcess,
|
nodeChildProcess: mockChildProcess,
|
||||||
});
|
});
|
||||||
|
|
||||||
return simulatorPlist.findPlistFile().then((plistFile) => {
|
return simulatorPlist.findPlistFile().then((plistFile) => {
|
||||||
assert(plistFile === existingPlistFile, "Returned incorrect value");
|
assert(plistFile === existingPlistFile, "Returned incorrect value");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,60 +1,60 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {Xcodeproj} from "../../../common/ios/xcodeproj";
|
import {Xcodeproj} from "../../../src/common/ios/xcodeproj";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
|
|
||||||
suite("xcodeproj", function() {
|
suite("xcodeproj", function() {
|
||||||
suite("commonContext", function() {
|
suite("commonContext", function() {
|
||||||
test("should look in the correct location for xcodeproj files and return one", function() {
|
test("should look in the correct location for xcodeproj files and return one", function() {
|
||||||
const projectRoot = path.join("/", "tmp", "myProject");
|
const projectRoot = path.join("/", "tmp", "myProject");
|
||||||
const projectName = "foo";
|
const projectName = "foo";
|
||||||
const fileType = ".xcodeproj";
|
const fileType = ".xcodeproj";
|
||||||
const testFiles = [projectName + fileType];
|
const testFiles = [projectName + fileType];
|
||||||
const mockFileSystem: any = {
|
const mockFileSystem: any = {
|
||||||
readDir: () => {
|
readDir: () => {
|
||||||
return Q(testFiles);
|
return Q(testFiles);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
|
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
|
||||||
|
|
||||||
return xcodeproj.findXcodeprojFile(projectRoot)
|
return xcodeproj.findXcodeprojFile(projectRoot)
|
||||||
.then((proj) => {
|
.then((proj) => {
|
||||||
assert.deepEqual(proj, {
|
assert.deepEqual(proj, {
|
||||||
fileName: path.join(projectRoot, testFiles[0]),
|
fileName: path.join(projectRoot, testFiles[0]),
|
||||||
fileType,
|
fileType,
|
||||||
projectName,
|
projectName,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test("should look in the correct location for xcodeproj/xcworkspace files and prefer xcworkspace over xcodeproj", function() {
|
test("should look in the correct location for xcodeproj/xcworkspace files and prefer xcworkspace over xcodeproj", function() {
|
||||||
const projectRoot = path.join("/", "tmp", "myProject");
|
const projectRoot = path.join("/", "tmp", "myProject");
|
||||||
const projectName = "foo";
|
const projectName = "foo";
|
||||||
const xcodeprojFileType = ".xcodeproj";
|
const xcodeprojFileType = ".xcodeproj";
|
||||||
const xcworkspaceFileType = ".xcworkspace";
|
const xcworkspaceFileType = ".xcworkspace";
|
||||||
const xcodeprojFileName = projectName + xcodeprojFileType;
|
const xcodeprojFileName = projectName + xcodeprojFileType;
|
||||||
const xcworkspaceFileName = projectName + xcworkspaceFileType;
|
const xcworkspaceFileName = projectName + xcworkspaceFileType;
|
||||||
const testFiles = [xcodeprojFileName, xcworkspaceFileName];
|
const testFiles = [xcodeprojFileName, xcworkspaceFileName];
|
||||||
const mockFileSystem: any = {
|
const mockFileSystem: any = {
|
||||||
readDir: () => {
|
readDir: () => {
|
||||||
return Q(testFiles);
|
return Q(testFiles);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
|
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
|
||||||
|
|
||||||
return xcodeproj.findXcodeprojFile(projectRoot)
|
return xcodeproj.findXcodeprojFile(projectRoot)
|
||||||
.then((proj) => {
|
.then((proj) => {
|
||||||
assert.deepEqual(proj, {
|
assert.deepEqual(proj, {
|
||||||
fileName: path.join(projectRoot, xcworkspaceFileName),
|
fileName: path.join(projectRoot, xcworkspaceFileName),
|
||||||
fileType: xcworkspaceFileType,
|
fileType: xcworkspaceFileType,
|
||||||
projectName,
|
projectName,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import { Packager } from "../../common/packager";
|
import { Packager } from "../../src/common/packager";
|
||||||
import { Request } from "../../common/node/request";
|
import { Request } from "../../src/common/node/request";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
|
@ -6,16 +6,16 @@ import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as mockFs from "mock-fs";
|
import * as mockFs from "mock-fs";
|
||||||
|
|
||||||
import {AndroidPlatform} from "../../../common/android/androidPlatform";
|
import {AndroidPlatform} from "../../../src/common/android/androidPlatform";
|
||||||
import {IAndroidRunOptions} from "../../../common/launchArgs";
|
import {IAndroidRunOptions} from "../../../src/common/launchArgs";
|
||||||
import {FileSystem} from "../../../common/node/fileSystem";
|
import {FileSystem} from "../../../src/common/node/fileSystem";
|
||||||
import {ReactNative022} from "../../resources/reactNative022";
|
import {ReactNative022} from "../../resources/reactNative022";
|
||||||
import {AdbSimulator} from "../../resources/simulators/adbSimulator";
|
import {AdbSimulator} from "../../resources/simulators/adbSimulator";
|
||||||
import {AVDManager} from "../../resources/simulators/avdManager";
|
import {AVDManager} from "../../resources/simulators/avdManager";
|
||||||
import {FakeExtensionMessageSender} from "../../resources/fakeExtensionMessageSender";
|
import {FakeExtensionMessageSender} from "../../resources/fakeExtensionMessageSender";
|
||||||
import {ExtensionMessage} from "../../../common/extensionMessaging";
|
import {ExtensionMessage} from "../../../src/common/extensionMessaging";
|
||||||
import {RecordingsHelper} from "../../resources/recordingsHelper";
|
import {RecordingsHelper} from "../../resources/recordingsHelper";
|
||||||
import {RemoteExtension} from "../../../common/remoteExtension";
|
import {RemoteExtension} from "../../../src/common/remoteExtension";
|
||||||
|
|
||||||
import "should";
|
import "should";
|
||||||
|
|
|
@ -8,10 +8,10 @@ import * as Q from "q";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
|
|
||||||
import { MultipleLifetimesAppWorker } from "../../debugger/appWorker";
|
import { MultipleLifetimesAppWorker } from "../../src/debugger/appWorker";
|
||||||
import { ForkedAppWorker } from "../../debugger/forkedAppWorker";
|
import { ForkedAppWorker } from "../../src/debugger/forkedAppWorker";
|
||||||
import * as ForkedAppWorkerModule from "../../debugger/forkedAppWorker";
|
import * as ForkedAppWorkerModule from "../../src/debugger/forkedAppWorker";
|
||||||
import {Packager} from "../../common/packager";
|
import {Packager} from "../../src/common/packager";
|
||||||
|
|
||||||
suite("appWorker", function() {
|
suite("appWorker", function() {
|
||||||
suite("debuggerContext", function() {
|
suite("debuggerContext", function() {
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
// This file intentionally left blank
|
// This file intentionally left blank
|
||||||
// It is just needed to satisfy a "require.resolve"
|
// It is just needed to satisfy a "require.resolve"
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
import { IOSPlatform } from "../../../common/ios/iOSPlatform";
|
import { IOSPlatform } from "../../../src/common/ios/iOSPlatform";
|
||||||
import { IRunOptions } from "../../../common/launchArgs";
|
import { IRunOptions } from "../../../src/common/launchArgs";
|
||||||
|
|
||||||
import "should";
|
import "should";
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import {SourceMapUtil, IStrictUrl} from "../../debugger/sourceMap";
|
import {SourceMapUtil, IStrictUrl} from "../../src/debugger/sourceMap";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as url from "url";
|
import * as url from "url";
|
||||||
|
|
||||||
suite("sourceMap", function() {
|
suite("sourceMap", function() {
|
||||||
suite("debuggerContext", function() {
|
suite("debuggerContext", function() {
|
||||||
test("should convert host filesystem paths to URL-style-paths", function() {
|
test("should convert host filesystem paths to URL-style-paths", function() {
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
const filePath = path.join("foo", "bar", "baz");
|
const filePath = path.join("foo", "bar", "baz");
|
||||||
const urlPath = "foo/bar/baz";
|
const urlPath = "foo/bar/baz";
|
||||||
const result = (<any>sourceMap).makeUnixStylePath(filePath);
|
const result = (<any>sourceMap).makeUnixStylePath(filePath);
|
||||||
assert(result === urlPath, `Expected "${urlPath}", found "${result}"`);
|
assert(result === urlPath, `Expected "${urlPath}", found "${result}"`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should resolve a valid sourcemap url", function () {
|
test("should resolve a valid sourcemap url", function () {
|
||||||
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
||||||
const scriptBody = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
const scriptBody = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
||||||
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
|
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
|
||||||
|
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
||||||
assert.equal(expectedUrlHref, result && result.href);
|
assert.equal(expectedUrlHref, result && result.href);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should ignore inline sourcemap urls", function () {
|
test("should ignore inline sourcemap urls", function () {
|
||||||
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
||||||
const scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
|
const scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
|
||||||
"//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
"//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
||||||
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
|
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
|
||||||
|
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
||||||
assert.equal(expectedUrlHref, result && result.href);
|
assert.equal(expectedUrlHref, result && result.href);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return default IStrictUrl for an invalid sourcemap url", function () {
|
test("should return default IStrictUrl for an invalid sourcemap url", function () {
|
||||||
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
||||||
const scriptBody = "";
|
const scriptBody = "";
|
||||||
|
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
||||||
assert.deepEqual(null, result);
|
assert.deepEqual(null, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return default IStrictUrl if there are only inline sourcemap urls", function () {
|
test("should return default IStrictUrl if there are only inline sourcemap urls", function () {
|
||||||
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
const scriptUrl: url.Url = url.parse("http://localhost:8081/index.ios.bundle?platform=ios&dev=true");
|
||||||
const scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
|
const scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
|
||||||
"//# sourceMappingURL=data:application/json;base64,eyJiYXoiOiJxdXV4In0=";
|
"//# sourceMappingURL=data:application/json;base64,eyJiYXoiOiJxdXV4In0=";
|
||||||
|
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
|
||||||
assert.deepEqual(null, result);
|
assert.deepEqual(null, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should update the contents of a source map file", function() {
|
test("should update the contents of a source map file", function() {
|
||||||
const sourceMapBody: string = JSON.stringify({"version": 3, "sources": ["test/index.ts"], "names": [], "mappings": "", "file": "test/index.js", "sourceRoot": "../../src"});
|
const sourceMapBody: string = JSON.stringify({"version": 3, "sources": ["test/index.ts"], "names": [], "mappings": "", "file": "test/index.js", "sourceRoot": "../../src"});
|
||||||
const scriptPath: string = "test/newIndex.ts";
|
const scriptPath: string = "test/newIndex.ts";
|
||||||
const sourcesRootPath: string = "new/src";
|
const sourcesRootPath: string = "new/src";
|
||||||
const expectedSourceMapBody: string = JSON.stringify({"version": 3, "sources": ["../../test/index.ts"], "names": [], "mappings": "", "file": scriptPath, "sourceRoot": ""});
|
const expectedSourceMapBody: string = JSON.stringify({"version": 3, "sources": ["../../test/index.ts"], "names": [], "mappings": "", "file": scriptPath, "sourceRoot": ""});
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
|
|
||||||
const result: string = sourceMap.updateSourceMapFile(sourceMapBody, scriptPath, sourcesRootPath);
|
const result: string = sourceMap.updateSourceMapFile(sourceMapBody, scriptPath, sourcesRootPath);
|
||||||
assert.equal(expectedSourceMapBody, result);
|
assert.equal(expectedSourceMapBody, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should update scripts with source mapping urls", function() {
|
test("should update scripts with source mapping urls", function() {
|
||||||
const scriptBody: string = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
const scriptBody: string = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
|
||||||
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
|
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
|
||||||
const expectedScriptBody = "//# sourceMappingURL=index.android.map";
|
const expectedScriptBody = "//# sourceMappingURL=index.android.map";
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
|
|
||||||
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
|
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
|
||||||
assert.equal(expectedScriptBody, result);
|
assert.equal(expectedScriptBody, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should not update scripts without source mapping urls", function() {
|
test("should not update scripts without source mapping urls", function() {
|
||||||
const scriptBody: string = "var path = require('path');";
|
const scriptBody: string = "var path = require('path');";
|
||||||
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
|
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
|
|
||||||
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
|
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
|
||||||
assert.equal(scriptBody, result);
|
assert.equal(scriptBody, result);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should update absolute source path to relative unix style path", function() {
|
test("should update absolute source path to relative unix style path", function() {
|
||||||
const sourcePath: string = "foo/bar";
|
const sourcePath: string = "foo/bar";
|
||||||
const sourcesRootPath: string = "baz/fuzz";
|
const sourcesRootPath: string = "baz/fuzz";
|
||||||
const expectedPath: string = "../../foo/bar";
|
const expectedPath: string = "../../foo/bar";
|
||||||
const sourceMap = new SourceMapUtil();
|
const sourceMap = new SourceMapUtil();
|
||||||
|
|
||||||
const result = (<any>sourceMap).updateSourceMapPath(sourcePath, sourcesRootPath);
|
const result = (<any>sourceMap).updateSourceMapPath(sourcePath, sourcesRootPath);
|
||||||
assert.equal(expectedPath, result);
|
assert.equal(expectedPath, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import { SourceMapsCombinator } from "../../debugger/sourceMapsCombinator";
|
import { SourceMapsCombinator } from "../../src/debugger/sourceMapsCombinator";
|
||||||
import { RawSourceMap } from "source-map";
|
import { RawSourceMap } from "source-map";
|
||||||
|
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
@ -26,7 +26,7 @@ suite("sourceMapsCombinator", function () {
|
||||||
const pathToTS = "d:/hello.ts";
|
const pathToTS = "d:/hello.ts";
|
||||||
const sourcemapPath = "d:/hello.js.map";
|
const sourcemapPath = "d:/hello.js.map";
|
||||||
const codeJS = fs.readFileSync(path.resolve(__dirname, "assets/hello.js"));
|
const codeJS = fs.readFileSync(path.resolve(__dirname, "assets/hello.js"));
|
||||||
const codeTS = fs.readFileSync(path.resolve(__dirname, "../../../src/test/debugger/assets/hello.ts"));
|
const codeTS = fs.readFileSync(path.resolve(__dirname, "../../../test/debugger/assets/hello.ts"));
|
||||||
const sourcemap: RawSourceMap = {
|
const sourcemap: RawSourceMap = {
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"sources": [
|
"sources": [
|
|
@ -5,7 +5,7 @@
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import * as reactDirManager from "../../extension/reactDirManager";
|
import * as reactDirManager from "../../src/extension/reactDirManager";
|
||||||
|
|
||||||
suite("reactDirManager.ts", () => {
|
suite("reactDirManager.ts", () => {
|
||||||
suite("extensionContext", function() {
|
suite("extensionContext", function() {
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
|
|
||||||
import * as extensionMessaging from "../../common/extensionMessaging";
|
import * as extensionMessaging from "../../src/common/extensionMessaging";
|
||||||
import {IInterProcessMessageSender} from "../../common/interProcessMessageSender";
|
import {IInterProcessMessageSender} from "../../src/common/interProcessMessageSender";
|
||||||
|
|
||||||
type ExtensionMessage = extensionMessaging.ExtensionMessage;
|
type ExtensionMessage = extensionMessaging.ExtensionMessage;
|
||||||
|
|
|
@ -5,8 +5,8 @@ import * as assert from "assert";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
|
|
||||||
import {ISpawnResult, ChildProcess} from "../../../common/node/childProcess";
|
import {ISpawnResult, ChildProcess} from "../../../src/common/node/childProcess";
|
||||||
import {PromiseUtil} from "../../../common/node/promise";
|
import {PromiseUtil} from "../../../src/common/node/promise";
|
||||||
|
|
||||||
import {IStdOutEvent, IStdErrEvent, IErrorEvent, IExitEvent, ICustomEvent} from "./recording";
|
import {IStdOutEvent, IStdErrEvent, IErrorEvent, IExitEvent, ICustomEvent} from "./recording";
|
||||||
import * as recording from "./recording";
|
import * as recording from "./recording";
|
|
@ -5,18 +5,18 @@ import * as Q from "q";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
|
|
||||||
import {PromiseUtil} from "../../common/node/promise";
|
import {PromiseUtil} from "../../src/common/node/promise";
|
||||||
|
|
||||||
import * as reactNative from "../../common/reactNative";
|
import * as reactNative from "../../src/common/reactNative";
|
||||||
import {IAndroidRunOptions} from "../../common/launchArgs";
|
import {IAndroidRunOptions} from "../../src/common/launchArgs";
|
||||||
import {ISpawnResult} from "../../common/node/childProcess";
|
import {ISpawnResult} from "../../src/common/node/childProcess";
|
||||||
import {FileSystem} from "../../common/node/fileSystem";
|
import {FileSystem} from "../../src/common/node/fileSystem";
|
||||||
import {Package} from "../../common/node/package";
|
import {Package} from "../../src/common/node/package";
|
||||||
import {Recording, Simulator} from "./processExecution/simulator";
|
import {Recording, Simulator} from "./processExecution/simulator";
|
||||||
import {AdbSimulator} from "./simulators/adbSimulator";
|
import {AdbSimulator} from "./simulators/adbSimulator";
|
||||||
import {APKSerializer} from "./simulators/apkSerializer";
|
import {APKSerializer} from "./simulators/apkSerializer";
|
||||||
|
|
||||||
const resourcesPath = path.join(__dirname, "../../../src/test/resources/");
|
const resourcesPath = path.join(__dirname, "../../../test/resources/");
|
||||||
const sampleRNProjectPath = path.join(resourcesPath, "sampleReactNative022Project");
|
const sampleRNProjectPath = path.join(resourcesPath, "sampleReactNative022Project");
|
||||||
const processExecutionsRecordingsPath = path.join(resourcesPath, "processExecutionsRecordings");
|
const processExecutionsRecordingsPath = path.join(resourcesPath, "processExecutionsRecordings");
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
const RECORDINGS_ROOT = path.resolve(__dirname, "../../../src/test/resources/", "processExecutionsRecordings");
|
const RECORDINGS_ROOT = path.resolve(__dirname, "../../../test/resources/", "processExecutionsRecordings");
|
||||||
|
|
||||||
interface TestUsingRecording {
|
interface TestUsingRecording {
|
||||||
(expectation: string, recordingNames: string[], assertion?: () => void): Mocha.ITest;
|
(expectation: string, recordingNames: string[], assertion?: () => void): Mocha.ITest;
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
|
|
||||||
import * as adb from "../../../common/android/adb";
|
import * as adb from "../../../src/common/android/adb";
|
||||||
|
|
||||||
import {FileSystem} from "../../../common/node/fileSystem";
|
import {FileSystem} from "../../../src/common/node/fileSystem";
|
||||||
import {APKSerializer} from "./apkSerializer";
|
import {APKSerializer} from "./apkSerializer";
|
||||||
|
|
||||||
export type IDevice = adb.IDevice;
|
export type IDevice = adb.IDevice;
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import {FileSystem} from "../../../common/node/fileSystem";
|
import {FileSystem} from "../../../src/common/node/fileSystem";
|
||||||
|
|
||||||
interface IAPKInformation {
|
interface IAPKInformation {
|
||||||
packageName: string;
|
packageName: string;
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||||
|
|
||||||
import * as Q from "q";
|
import * as Q from "q";
|
||||||
import {DeviceType} from "../../../common/android/adb";
|
import {DeviceType} from "../../../src/common/android/adb";
|
||||||
import {AdbSimulator} from "./adbSimulator";
|
import {AdbSimulator} from "./adbSimulator";
|
||||||
|
|
||||||
export interface IAVDManager {
|
export interface IAVDManager {
|
|
@ -7,7 +7,7 @@
|
||||||
"es2015"
|
"es2015"
|
||||||
],
|
],
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"rootDir": "src",
|
"rootDir": "./",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
|
@ -30,6 +30,6 @@
|
||||||
"SampleApplication/.vscode",
|
"SampleApplication/.vscode",
|
||||||
"ReactTypings",
|
"ReactTypings",
|
||||||
"tools/",
|
"tools/",
|
||||||
"src/test/resources/sampleReactNative022Project/"
|
"test/resources/sampleReactNative022Project/"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче