Move test folder to project root (#519)

This commit is contained in:
Artem Egorov 2017-08-28 10:58:30 +03:00 коммит произвёл Vladimir Kotikov
Родитель 0db0be15f4
Коммит 3c172a0565
55 изменённых файлов: 412 добавлений и 408 удалений

Просмотреть файл

@ -2,6 +2,7 @@
node_modules/
src/
test/
.vscode-test/
tools/

Просмотреть файл

@ -4,6 +4,7 @@
.vscode-test/**
.gitignore
src/**
test/**
out/test/**
**/*.js.map
SampleApplication/**

Просмотреть файл

@ -23,12 +23,13 @@ var imports = GulpExtras.checkImports;
var executeCommand = GulpExtras.executeCommand;
var srcPath = "src";
var testPath = "test";
var outPath = "out";
var sources = [
srcPath,
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; })
.concat(["test/*.ts"]);
testPath,
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
var knownOptions = {
string: "env",
@ -76,10 +77,11 @@ gulp.task("default", function (callback) {
var lintSources = [
srcPath,
testPath
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
lintSources = lintSources.concat([
"!src/typings/**",
"!src/test/resources/sampleReactNative022Project/**",
"!test/resources/sampleReactNative022Project/**",
]);
var libtslint = require("tslint");
@ -167,7 +169,7 @@ gulp.task("check-copyright", function (cb) {
"!node_modules/**",
"!out/test/**/*.js",
"!SampleApplication/**",
"!src/test/resources/sampleReactNative022Project/**/*.js",
"!test/resources/sampleReactNative022Project/**/*.js",
])
.pipe(copyright());
});

Просмотреть файл

@ -1,12 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// 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 {InternalErrorCode} from "./internalErrorCode";
import {ERROR_STRINGS} from "./errorStrings";
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 {
let message = ErrorHelper.getErrorMessage(errorCode, ...optionalArgs);
return new InternalError(<number> errorCode, message);
@ -29,8 +29,7 @@ export class ErrorHelper {
}
private static getErrorMessage(errorCode: InternalErrorCode, ...optionalArgs: any[]): string {
let errorStrings = require (ErrorHelper.errorStringsJsonLoc);
return ErrorHelper.formatErrorMessage(errorStrings[InternalErrorCode[errorCode]], ...optionalArgs);
return ErrorHelper.formatErrorMessage(ErrorHelper.ERROR_STRINGS[InternalErrorCode[errorCode]], ...optionalArgs);
}
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}'",
"CommandFailedWithErrorCode": "Command '{0}' failed with error code {1}",
"ExpectedIntegerValue": "Expected an integer. Couldn't read {0}",
@ -14,7 +17,7 @@
"PlatformNotSupported": "Platform '{0}' is not supported on host platform: {1}",
"ProjectVersionNotParsable": "Couldn't parse the version component of the package at {0}: version = {1}",
"ProjectVersionUnsupported": "Project version = {0}",
"ProjectVersionNotReadable":"Unable to read version = {0}",
"ProjectVersionNotReadable": "Unable to read version = {0}",
"TelemetryInitializationFailed": "{0}. Couldn't initialize telemetry",
"ExtensionActivationFailed": "Failed to activate the React Native Tools extension",
"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",
"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}",
"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,
// Device Deployer errors
IDeviceInstallerNotFound = 201,
IOSDeployNotFound = 201,
// Device Runner errors
DeviceNotPluggedIn = 301,

Просмотреть файл

@ -13,10 +13,7 @@ import {PlistBuddy} from "../../common/ios/plistBuddy";
import {IOSDebugModeManager} from "../../common/ios/iOSDebugModeManager";
import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
import {RemoteExtension} from "../../common/remoteExtension";
/* tslint:disable:no-var-requires */
const ErrorStrings = require("../../../errorStrings/errorStrings.json");
/* tslint:enable:no-var-requires */
import {ErrorHelper} from "../../common/error/errorHelper";
export class IOSPlatform extends GeneralMobilePlatform {
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
private static RUN_IOS_FAILURE_PATTERNS: PatternToFailure[] = [{
pattern: "No devices are booted",
message: ErrorStrings.IOSSimulatorNotLaunchable,
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
}, {
pattern: "FBSOpenApplicationErrorDomain",
message: ErrorStrings.IOSSimulatorNotLaunchable,
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
}, {
pattern: "ios-deploy",
message: ErrorStrings.IOSDeployNotFound,
message: ErrorHelper.ERROR_STRINGS.IOSDeployNotFound,
}];
private static RUN_IOS_SUCCESS_PATTERNS = ["BUILD SUCCEEDED"];

Просмотреть файл

@ -7,7 +7,7 @@ import {ErrorHelper} from "../error/errorHelper";
import {InternalErrorCode} from "../error/internalErrorCode";
// 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();
export interface IExecResult {

Просмотреть файл

@ -77,7 +77,7 @@ export class CommandPaletteHandler {
*/
public publishToExpHost(): Q.Promise<void> {
return this.executeCommandInContext("publishToExpHost", () => {
this.executePublishToExpHost().then((didPublish) => {
return this.executePublishToExpHost().then((didPublish) => {
if (!didPublish) {
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
* {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);
return TelemetryHelper.generate("RNCommand", (generator) => {
generator.add("command", rnCommand, false);
@ -178,6 +178,7 @@ export class CommandPaletteHandler {
return operation();
} else {
vscode.window.showErrorMessage("Current workspace is not a React Native project.");
return;
}
});
});

Просмотреть файл

@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {CommandExecutor} from "../../common/commandExecutor";
import { Log } from "../../common/log/log";
import {CommandExecutor} from "../../src/common/commandExecutor";
import { Log } from "../../src/common/log/log";
import { Node } from "../../common/node/node";
import { ChildProcess } from "../../common/node/childProcess";
import { Node } from "../../src/common/node/node";
import { ChildProcess } from "../../src/common/node/childProcess";
import { EventEmitter } from "events";

Просмотреть файл

@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// 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 net from "net";

Просмотреть файл

@ -1,106 +1,106 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {PlistBuddy} from "../../../common/ios/plistBuddy";
import {IXcodeProjFile} from "../../../common/ios/xcodeproj";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
import * as sinon from "sinon";
suite("plistBuddy", function() {
suite("commonContext", function() {
test("setPlistProperty should attempt to modify, then add, plist properties", function() {
const plistFileName = "testFile.plist";
const plistProperty = ":RCTDevMenu:ExecutorClass";
const plistValue = "RCTWebSocketExecutor";
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
const addCallArgs = `/usr/libexec/PlistBuddy -c 'Add ${plistProperty} string ${plistValue}' '${plistFileName}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.reject(new Error("Setting does not exist")) });
mockedExecFunc.withArgs(addCallArgs).returns({ outcome: Q.resolve("stdout") });
mockedExecFunc.throws();
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
.then(() => {
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.equal(mockedExecFunc.callCount, 2);
});
});
test("setPlistProperty should stop after modifying if the attempt succeeds", function() {
const plistFileName = "testFile.plist";
const plistProperty = ":RCTDevMenu:ExecutorClass";
const plistValue = "RCTWebSocketExecutor";
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.resolve("stdout") });
mockedExecFunc.throws();
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
.then(() => {
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
assert.equal(mockedExecFunc.callCount, 1);
});
});
test("getBundleId should return the bundle ID", function() {
const projectRoot = path.join("/", "userHome", "rnProject");
const appName = "myApp";
const infoPlistPath = (simulator: boolean) =>
path.join(projectRoot, "build", "Build", "Products",
simulator ? "Debug-iphonesimulator" : "Debug-iphoneos",
`${appName}.app`, "Info.plist");
const simulatorBundleId = "com.contoso.simulator";
const deviceBundleId = "com.contoso.device";
const printExecCall = (simulator: boolean) => `/usr/libexec/PlistBuddy -c 'Print:CFBundleIdentifier' '${infoPlistPath(simulator)}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(printExecCall(true)).returns({outcome: Q.resolve(simulatorBundleId)});
mockedExecFunc.withArgs(printExecCall(false)).returns({outcome: Q.resolve(deviceBundleId)});
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const mockedFindXcodeprojFile = sinon.stub();
const mockedProjResult: IXcodeProjFile = {
fileName: appName + ".xcodeproj",
fileType: ".xcodeproj",
projectName: appName,
};
mockedFindXcodeprojFile.withArgs(projectRoot).returns(Q.resolve(mockedProjResult));
const mockXcodeproj: any = {
findXcodeprojFile: mockedFindXcodeprojFile,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess, xcodeproj: mockXcodeproj });
return Q.all([
plistBuddy.getBundleId(projectRoot, true),
plistBuddy.getBundleId(projectRoot, false),
]).spread((simulatorId, deviceId) => {
assert.equal(simulatorBundleId, simulatorId);
assert.equal(deviceBundleId, deviceId);
});
});
});
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {PlistBuddy} from "../../../src/common/ios/plistBuddy";
import {IXcodeProjFile} from "../../../src/common/ios/xcodeproj";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
import * as sinon from "sinon";
suite("plistBuddy", function() {
suite("commonContext", function() {
test("setPlistProperty should attempt to modify, then add, plist properties", function() {
const plistFileName = "testFile.plist";
const plistProperty = ":RCTDevMenu:ExecutorClass";
const plistValue = "RCTWebSocketExecutor";
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
const addCallArgs = `/usr/libexec/PlistBuddy -c 'Add ${plistProperty} string ${plistValue}' '${plistFileName}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.reject(new Error("Setting does not exist")) });
mockedExecFunc.withArgs(addCallArgs).returns({ outcome: Q.resolve("stdout") });
mockedExecFunc.throws();
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
.then(() => {
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.equal(mockedExecFunc.callCount, 2);
});
});
test("setPlistProperty should stop after modifying if the attempt succeeds", function() {
const plistFileName = "testFile.plist";
const plistProperty = ":RCTDevMenu:ExecutorClass";
const plistValue = "RCTWebSocketExecutor";
const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.resolve("stdout") });
mockedExecFunc.throws();
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });
return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
.then(() => {
assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
assert.equal(mockedExecFunc.callCount, 1);
});
});
test("getBundleId should return the bundle ID", function() {
const projectRoot = path.join("/", "userHome", "rnProject");
const appName = "myApp";
const infoPlistPath = (simulator: boolean) =>
path.join(projectRoot, "build", "Build", "Products",
simulator ? "Debug-iphonesimulator" : "Debug-iphoneos",
`${appName}.app`, "Info.plist");
const simulatorBundleId = "com.contoso.simulator";
const deviceBundleId = "com.contoso.device";
const printExecCall = (simulator: boolean) => `/usr/libexec/PlistBuddy -c 'Print:CFBundleIdentifier' '${infoPlistPath(simulator)}'`;
const mockedExecFunc = sinon.stub();
mockedExecFunc.withArgs(printExecCall(true)).returns({outcome: Q.resolve(simulatorBundleId)});
mockedExecFunc.withArgs(printExecCall(false)).returns({outcome: Q.resolve(deviceBundleId)});
const mockChildProcess: any = {
exec: mockedExecFunc,
};
const mockedFindXcodeprojFile = sinon.stub();
const mockedProjResult: IXcodeProjFile = {
fileName: appName + ".xcodeproj",
fileType: ".xcodeproj",
projectName: appName,
};
mockedFindXcodeprojFile.withArgs(projectRoot).returns(Q.resolve(mockedProjResult));
const mockXcodeproj: any = {
findXcodeprojFile: mockedFindXcodeprojFile,
};
const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess, xcodeproj: mockXcodeproj });
return Q.all([
plistBuddy.getBundleId(projectRoot, true),
plistBuddy.getBundleId(projectRoot, false),
]).spread((simulatorId, deviceId) => {
assert.equal(simulatorBundleId, simulatorId);
assert.equal(deviceBundleId, deviceId);
});
});
});
});

Просмотреть файл

@ -1,77 +1,77 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {SimulatorPlist} from "../../../common/ios/simulatorPlist";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
import * as sinon from "sinon";
suite("plistBuddy", function() {
suite("commonContext", function() {
test("findPlistFile should correctly find the NSUserDefaults plist file for the simulator", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const bundleId = "com.contoso.app";
const findSimulatorHomeCommand = "xcrun simctl getenv booted 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 prefix = path.join("Containers", "Data", "Application");
const suffix = path.join("Library", "Preferences");
// The emulator has 3 apps
const appIds = ["17F3AED1-5B1D-4F97-B419-D1F079D9DE2D",
"957660FD-3417-474E-B2AC-8AA0A05AD9A0",
"18319C8B-0583-4967-8023-15859A0BF0F3",
];
// readdir finds appIds
const mockReadDir = sinon.stub();
mockReadDir.withArgs(path.join(findSimulatorHomeResult, prefix)).returns(Q.resolve(appIds));
mockReadDir.throws();
// 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`);
// existsSync only finds existingPlistFile to exist
const mockExistsSync = sinon.stub();
mockExistsSync.withArgs(existingPlistFile).returns(true);
mockExistsSync.returns(false);
const mockFS: any = {
existsSync: mockExistsSync,
readDir: mockReadDir,
};
// getBundleId returns bundleId
const bundleIdStub = sinon.stub();
bundleIdStub.withArgs(projectRoot).returns(Q.resolve(bundleId));
bundleIdStub.returns(Q.reject("Incorrect project root"));
const mockPlistBuddy: any = {
getBundleId: bundleIdStub,
};
// exec-ing the correct command returns the simulator home
const execStub = sinon.stub();
execStub.withArgs(findSimulatorHomeCommand).returns({ outcome: Q.resolve(findSimulatorHomeResult) });
execStub.throws();
const mockChildProcess: any = {
exec: execStub,
};
const simulatorPlist = new SimulatorPlist(projectRoot, {
nodeFileSystem: mockFS,
plistBuddy: mockPlistBuddy,
nodeChildProcess: mockChildProcess,
});
return simulatorPlist.findPlistFile().then((plistFile) => {
assert(plistFile === existingPlistFile, "Returned incorrect value");
});
});
});
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {SimulatorPlist} from "../../../src/common/ios/simulatorPlist";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
import * as sinon from "sinon";
suite("plistBuddy", function() {
suite("commonContext", function() {
test("findPlistFile should correctly find the NSUserDefaults plist file for the simulator", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const bundleId = "com.contoso.app";
const findSimulatorHomeCommand = "xcrun simctl getenv booted 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 prefix = path.join("Containers", "Data", "Application");
const suffix = path.join("Library", "Preferences");
// The emulator has 3 apps
const appIds = ["17F3AED1-5B1D-4F97-B419-D1F079D9DE2D",
"957660FD-3417-474E-B2AC-8AA0A05AD9A0",
"18319C8B-0583-4967-8023-15859A0BF0F3",
];
// readdir finds appIds
const mockReadDir = sinon.stub();
mockReadDir.withArgs(path.join(findSimulatorHomeResult, prefix)).returns(Q.resolve(appIds));
mockReadDir.throws();
// 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`);
// existsSync only finds existingPlistFile to exist
const mockExistsSync = sinon.stub();
mockExistsSync.withArgs(existingPlistFile).returns(true);
mockExistsSync.returns(false);
const mockFS: any = {
existsSync: mockExistsSync,
readDir: mockReadDir,
};
// getBundleId returns bundleId
const bundleIdStub = sinon.stub();
bundleIdStub.withArgs(projectRoot).returns(Q.resolve(bundleId));
bundleIdStub.returns(Q.reject("Incorrect project root"));
const mockPlistBuddy: any = {
getBundleId: bundleIdStub,
};
// exec-ing the correct command returns the simulator home
const execStub = sinon.stub();
execStub.withArgs(findSimulatorHomeCommand).returns({ outcome: Q.resolve(findSimulatorHomeResult) });
execStub.throws();
const mockChildProcess: any = {
exec: execStub,
};
const simulatorPlist = new SimulatorPlist(projectRoot, {
nodeFileSystem: mockFS,
plistBuddy: mockPlistBuddy,
nodeChildProcess: mockChildProcess,
});
return simulatorPlist.findPlistFile().then((plistFile) => {
assert(plistFile === existingPlistFile, "Returned incorrect value");
});
});
});
});

Просмотреть файл

@ -1,60 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {Xcodeproj} from "../../../common/ios/xcodeproj";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
suite("xcodeproj", function() {
suite("commonContext", function() {
test("should look in the correct location for xcodeproj files and return one", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const projectName = "foo";
const fileType = ".xcodeproj";
const testFiles = [projectName + fileType];
const mockFileSystem: any = {
readDir: () => {
return Q(testFiles);
},
};
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
return xcodeproj.findXcodeprojFile(projectRoot)
.then((proj) => {
assert.deepEqual(proj, {
fileName: path.join(projectRoot, testFiles[0]),
fileType,
projectName,
});
});
});
test("should look in the correct location for xcodeproj/xcworkspace files and prefer xcworkspace over xcodeproj", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const projectName = "foo";
const xcodeprojFileType = ".xcodeproj";
const xcworkspaceFileType = ".xcworkspace";
const xcodeprojFileName = projectName + xcodeprojFileType;
const xcworkspaceFileName = projectName + xcworkspaceFileType;
const testFiles = [xcodeprojFileName, xcworkspaceFileName];
const mockFileSystem: any = {
readDir: () => {
return Q(testFiles);
},
};
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
return xcodeproj.findXcodeprojFile(projectRoot)
.then((proj) => {
assert.deepEqual(proj, {
fileName: path.join(projectRoot, xcworkspaceFileName),
fileType: xcworkspaceFileType,
projectName,
});
});
});
});
});
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {Xcodeproj} from "../../../src/common/ios/xcodeproj";
import * as assert from "assert";
import * as path from "path";
import * as Q from "q";
suite("xcodeproj", function() {
suite("commonContext", function() {
test("should look in the correct location for xcodeproj files and return one", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const projectName = "foo";
const fileType = ".xcodeproj";
const testFiles = [projectName + fileType];
const mockFileSystem: any = {
readDir: () => {
return Q(testFiles);
},
};
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
return xcodeproj.findXcodeprojFile(projectRoot)
.then((proj) => {
assert.deepEqual(proj, {
fileName: path.join(projectRoot, testFiles[0]),
fileType,
projectName,
});
});
});
test("should look in the correct location for xcodeproj/xcworkspace files and prefer xcworkspace over xcodeproj", function() {
const projectRoot = path.join("/", "tmp", "myProject");
const projectName = "foo";
const xcodeprojFileType = ".xcodeproj";
const xcworkspaceFileType = ".xcworkspace";
const xcodeprojFileName = projectName + xcodeprojFileType;
const xcworkspaceFileName = projectName + xcworkspaceFileType;
const testFiles = [xcodeprojFileName, xcworkspaceFileName];
const mockFileSystem: any = {
readDir: () => {
return Q(testFiles);
},
};
const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
return xcodeproj.findXcodeprojFile(projectRoot)
.then((proj) => {
assert.deepEqual(proj, {
fileName: path.join(projectRoot, xcworkspaceFileName),
fileType: xcworkspaceFileType,
projectName,
});
});
});
});
});

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import { Packager } from "../../common/packager";
import { Request } from "../../common/node/request";
import { Packager } from "../../src/common/packager";
import { Request } from "../../src/common/node/request";
import * as assert from "assert";
import * as sinon from "sinon";

Просмотреть файл

@ -6,16 +6,16 @@ import * as fs from "fs";
import * as path from "path";
import * as mockFs from "mock-fs";
import {AndroidPlatform} from "../../../common/android/androidPlatform";
import {IAndroidRunOptions} from "../../../common/launchArgs";
import {FileSystem} from "../../../common/node/fileSystem";
import {AndroidPlatform} from "../../../src/common/android/androidPlatform";
import {IAndroidRunOptions} from "../../../src/common/launchArgs";
import {FileSystem} from "../../../src/common/node/fileSystem";
import {ReactNative022} from "../../resources/reactNative022";
import {AdbSimulator} from "../../resources/simulators/adbSimulator";
import {AVDManager} from "../../resources/simulators/avdManager";
import {FakeExtensionMessageSender} from "../../resources/fakeExtensionMessageSender";
import {ExtensionMessage} from "../../../common/extensionMessaging";
import {ExtensionMessage} from "../../../src/common/extensionMessaging";
import {RecordingsHelper} from "../../resources/recordingsHelper";
import {RemoteExtension} from "../../../common/remoteExtension";
import {RemoteExtension} from "../../../src/common/remoteExtension";
import "should";

Просмотреть файл

@ -8,10 +8,10 @@ import * as Q from "q";
import * as sinon from "sinon";
import * as child_process from "child_process";
import { MultipleLifetimesAppWorker } from "../../debugger/appWorker";
import { ForkedAppWorker } from "../../debugger/forkedAppWorker";
import * as ForkedAppWorkerModule from "../../debugger/forkedAppWorker";
import {Packager} from "../../common/packager";
import { MultipleLifetimesAppWorker } from "../../src/debugger/appWorker";
import { ForkedAppWorker } from "../../src/debugger/forkedAppWorker";
import * as ForkedAppWorkerModule from "../../src/debugger/forkedAppWorker";
import {Packager} from "../../src/common/packager";
suite("appWorker", function() {
suite("debuggerContext", function() {

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
// This file intentionally left blank
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
// This file intentionally left blank
// It is just needed to satisfy a "require.resolve"

Просмотреть файл

Просмотреть файл

@ -3,8 +3,8 @@
import * as assert from "assert";
import { IOSPlatform } from "../../../common/ios/iOSPlatform";
import { IRunOptions } from "../../../common/launchArgs";
import { IOSPlatform } from "../../../src/common/ios/iOSPlatform";
import { IRunOptions } from "../../../src/common/launchArgs";
import "should";

Просмотреть файл

Просмотреть файл

@ -1,100 +1,100 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {SourceMapUtil, IStrictUrl} from "../../debugger/sourceMap";
import * as assert from "assert";
import * as path from "path";
import * as url from "url";
suite("sourceMap", function() {
suite("debuggerContext", function() {
test("should convert host filesystem paths to URL-style-paths", function() {
const sourceMap = new SourceMapUtil();
const filePath = path.join("foo", "bar", "baz");
const urlPath = "foo/bar/baz";
const result = (<any>sourceMap).makeUnixStylePath(filePath);
assert(result === urlPath, `Expected "${urlPath}", found "${result}"`);
});
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 scriptBody = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.equal(expectedUrlHref, result && result.href);
});
test("should ignore inline sourcemap urls", function () {
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" +
"//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.equal(expectedUrlHref, result && result.href);
});
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 scriptBody = "";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.deepEqual(null, result);
});
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 scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
"//# sourceMappingURL=data:application/json;base64,eyJiYXoiOiJxdXV4In0=";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.deepEqual(null, result);
});
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 scriptPath: string = "test/newIndex.ts";
const sourcesRootPath: string = "new/src";
const expectedSourceMapBody: string = JSON.stringify({"version": 3, "sources": ["../../test/index.ts"], "names": [], "mappings": "", "file": scriptPath, "sourceRoot": ""});
const sourceMap = new SourceMapUtil();
const result: string = sourceMap.updateSourceMapFile(sourceMapBody, scriptPath, sourcesRootPath);
assert.equal(expectedSourceMapBody, result);
});
test("should update scripts with source mapping urls", function() {
const scriptBody: string = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
const expectedScriptBody = "//# sourceMappingURL=index.android.map";
const sourceMap = new SourceMapUtil();
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
assert.equal(expectedScriptBody, result);
});
test("should not update scripts without source mapping urls", function() {
const scriptBody: string = "var path = require('path');";
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
const sourceMap = new SourceMapUtil();
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
assert.equal(scriptBody, result);
});
test("should update absolute source path to relative unix style path", function() {
const sourcePath: string = "foo/bar";
const sourcesRootPath: string = "baz/fuzz";
const expectedPath: string = "../../foo/bar";
const sourceMap = new SourceMapUtil();
const result = (<any>sourceMap).updateSourceMapPath(sourcePath, sourcesRootPath);
assert.equal(expectedPath, result);
});
});
});
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {SourceMapUtil, IStrictUrl} from "../../src/debugger/sourceMap";
import * as assert from "assert";
import * as path from "path";
import * as url from "url";
suite("sourceMap", function() {
suite("debuggerContext", function() {
test("should convert host filesystem paths to URL-style-paths", function() {
const sourceMap = new SourceMapUtil();
const filePath = path.join("foo", "bar", "baz");
const urlPath = "foo/bar/baz";
const result = (<any>sourceMap).makeUnixStylePath(filePath);
assert(result === urlPath, `Expected "${urlPath}", found "${result}"`);
});
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 scriptBody = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.equal(expectedUrlHref, result && result.href);
});
test("should ignore inline sourcemap urls", function () {
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" +
"//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const expectedUrlHref = "http://localhost:8081/index.ios.map?platform=ios&dev=true";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.equal(expectedUrlHref, result && result.href);
});
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 scriptBody = "";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.deepEqual(null, result);
});
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 scriptBody = "//# sourceMappingURL=data:application/json;base64,eyJmb28iOiJiYXIifQ==\n" +
"//# sourceMappingURL=data:application/json;base64,eyJiYXoiOiJxdXV4In0=";
const sourceMap = new SourceMapUtil();
const result = sourceMap.getSourceMapURL(scriptUrl, scriptBody);
assert.deepEqual(null, result);
});
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 scriptPath: string = "test/newIndex.ts";
const sourcesRootPath: string = "new/src";
const expectedSourceMapBody: string = JSON.stringify({"version": 3, "sources": ["../../test/index.ts"], "names": [], "mappings": "", "file": scriptPath, "sourceRoot": ""});
const sourceMap = new SourceMapUtil();
const result: string = sourceMap.updateSourceMapFile(sourceMapBody, scriptPath, sourcesRootPath);
assert.equal(expectedSourceMapBody, result);
});
test("should update scripts with source mapping urls", function() {
const scriptBody: string = "//# sourceMappingURL=/index.ios.map?platform=ios&dev=true";
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
const expectedScriptBody = "//# sourceMappingURL=index.android.map";
const sourceMap = new SourceMapUtil();
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
assert.equal(expectedScriptBody, result);
});
test("should not update scripts without source mapping urls", function() {
const scriptBody: string = "var path = require('path');";
const sourceMappingUrl: IStrictUrl = <IStrictUrl>url.parse("/index.android.map");
const sourceMap = new SourceMapUtil();
const result = sourceMap.updateScriptPaths(scriptBody, sourceMappingUrl);
assert.equal(scriptBody, result);
});
test("should update absolute source path to relative unix style path", function() {
const sourcePath: string = "foo/bar";
const sourcesRootPath: string = "baz/fuzz";
const expectedPath: string = "../../foo/bar";
const sourceMap = new SourceMapUtil();
const result = (<any>sourceMap).updateSourceMapPath(sourcePath, sourcesRootPath);
assert.equal(expectedPath, result);
});
});
});

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// 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 * as assert from "assert";
@ -26,7 +26,7 @@ suite("sourceMapsCombinator", function () {
const pathToTS = "d:/hello.ts";
const sourcemapPath = "d:/hello.js.map";
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 = {
"version": 3,
"sources": [

Просмотреть файл

@ -5,7 +5,7 @@
import * as assert from "assert";
import * as path from "path";
import * as reactDirManager from "../../extension/reactDirManager";
import * as reactDirManager from "../../src/extension/reactDirManager";
suite("reactDirManager.ts", () => {
suite("extensionContext", function() {

Просмотреть файл

Просмотреть файл

@ -3,8 +3,8 @@
import * as Q from "q";
import * as extensionMessaging from "../../common/extensionMessaging";
import {IInterProcessMessageSender} from "../../common/interProcessMessageSender";
import * as extensionMessaging from "../../src/common/extensionMessaging";
import {IInterProcessMessageSender} from "../../src/common/interProcessMessageSender";
type ExtensionMessage = extensionMessaging.ExtensionMessage;

Просмотреть файл

@ -5,8 +5,8 @@ import * as assert from "assert";
import * as child_process from "child_process";
import * as Q from "q";
import {ISpawnResult, ChildProcess} from "../../../common/node/childProcess";
import {PromiseUtil} from "../../../common/node/promise";
import {ISpawnResult, ChildProcess} from "../../../src/common/node/childProcess";
import {PromiseUtil} from "../../../src/common/node/promise";
import {IStdOutEvent, IStdErrEvent, IErrorEvent, IExitEvent, ICustomEvent} from "./recording";
import * as recording from "./recording";

Просмотреть файл

@ -5,18 +5,18 @@ import * as Q from "q";
import * as path from "path";
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 {IAndroidRunOptions} from "../../common/launchArgs";
import {ISpawnResult} from "../../common/node/childProcess";
import {FileSystem} from "../../common/node/fileSystem";
import {Package} from "../../common/node/package";
import * as reactNative from "../../src/common/reactNative";
import {IAndroidRunOptions} from "../../src/common/launchArgs";
import {ISpawnResult} from "../../src/common/node/childProcess";
import {FileSystem} from "../../src/common/node/fileSystem";
import {Package} from "../../src/common/node/package";
import {Recording, Simulator} from "./processExecution/simulator";
import {AdbSimulator} from "./simulators/adbSimulator";
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 processExecutionsRecordingsPath = path.join(resourcesPath, "processExecutionsRecordings");

Просмотреть файл

@ -4,7 +4,7 @@
import * as fs from "fs";
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 {
(expectation: string, recordingNames: string[], assertion?: () => void): Mocha.ITest;

Просмотреть файл

@ -3,9 +3,9 @@
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";
export type IDevice = adb.IDevice;

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for details.
import * as path from "path";
import {FileSystem} from "../../../common/node/fileSystem";
import {FileSystem} from "../../../src/common/node/fileSystem";
interface IAPKInformation {
packageName: string;

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for details.
import * as Q from "q";
import {DeviceType} from "../../../common/android/adb";
import {DeviceType} from "../../../src/common/android/adb";
import {AdbSimulator} from "./adbSimulator";
export interface IAVDManager {

Просмотреть файл

@ -7,7 +7,7 @@
"es2015"
],
"outDir": "out",
"rootDir": "src",
"rootDir": "./",
"sourceMap": true,
"removeComments": false,
"preserveConstEnums": true,
@ -30,6 +30,6 @@
"SampleApplication/.vscode",
"ReactTypings",
"tools/",
"src/test/resources/sampleReactNative022Project/"
"test/resources/sampleReactNative022Project/"
]
}