Skip to content

Commit 3c172a0

Browse files
itoysVladimir Kotikov
authored and
Vladimir Kotikov
committed
Move test folder to project root (#519)
1 parent 0db0be1 commit 3c172a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+412
-408
lines changed

Diff for: .npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
node_modules/
44
src/
5+
test/
56
.vscode-test/
67

78
tools/

Diff for: .vscodeignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.vscode-test/**
55
.gitignore
66
src/**
7+
test/**
78
out/test/**
89
**/*.js.map
910
SampleApplication/**

Diff for: gulpfile.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ var imports = GulpExtras.checkImports;
2323
var executeCommand = GulpExtras.executeCommand;
2424

2525
var srcPath = "src";
26+
var testPath = "test";
2627
var outPath = "out";
2728

2829
var sources = [
2930
srcPath,
30-
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; })
31-
.concat(["test/*.ts"]);
31+
testPath,
32+
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
3233

3334
var knownOptions = {
3435
string: "env",
@@ -76,10 +77,11 @@ gulp.task("default", function (callback) {
7677

7778
var lintSources = [
7879
srcPath,
80+
testPath
7981
].map(function (tsFolder) { return tsFolder + "/**/*.ts"; });
8082
lintSources = lintSources.concat([
8183
"!src/typings/**",
82-
"!src/test/resources/sampleReactNative022Project/**",
84+
"!test/resources/sampleReactNative022Project/**",
8385
]);
8486

8587
var libtslint = require("tslint");
@@ -167,7 +169,7 @@ gulp.task("check-copyright", function (cb) {
167169
"!node_modules/**",
168170
"!out/test/**/*.js",
169171
"!SampleApplication/**",
170-
"!src/test/resources/sampleReactNative022Project/**/*.js",
172+
"!test/resources/sampleReactNative022Project/**/*.js",
171173
])
172174
.pipe(copyright());
173175
});

Diff for: src/common/error/errorHelper.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for details.
33

4-
import * as path from "path";
54
import {InternalError, NestedError, InternalErrorLevel} from "./internalError";
65
import {InternalErrorCode} from "./internalErrorCode";
6+
import {ERROR_STRINGS} from "./errorStrings";
77

88
export class ErrorHelper {
9-
private static errorStringsJsonLoc = path.resolve(__dirname, "..", "..", "..", "errorStrings", "errorStrings.json");
9+
public static ERROR_STRINGS = ERROR_STRINGS;
1010
public static getInternalError(errorCode: InternalErrorCode, ...optionalArgs: any[]): InternalError {
1111
let message = ErrorHelper.getErrorMessage(errorCode, ...optionalArgs);
1212
return new InternalError(<number> errorCode, message);
@@ -29,8 +29,7 @@ export class ErrorHelper {
2929
}
3030

3131
private static getErrorMessage(errorCode: InternalErrorCode, ...optionalArgs: any[]): string {
32-
let errorStrings = require (ErrorHelper.errorStringsJsonLoc);
33-
return ErrorHelper.formatErrorMessage(errorStrings[InternalErrorCode[errorCode]], ...optionalArgs);
32+
return ErrorHelper.formatErrorMessage(ErrorHelper.ERROR_STRINGS[InternalErrorCode[errorCode]], ...optionalArgs);
3433
}
3534

3635
private static formatErrorMessage(errorMessage: string, ...optionalArgs: any[]): string {

Diff for: errorStrings/errorStrings.json renamed to src/common/error/errorStrings.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for details.
3+
4+
export const ERROR_STRINGS = {
25
"CommandFailed": "Error while executing command '{0}'",
36
"CommandFailedWithErrorCode": "Command '{0}' failed with error code {1}",
47
"ExpectedIntegerValue": "Expected an integer. Couldn't read {0}",
@@ -14,7 +17,7 @@
1417
"PlatformNotSupported": "Platform '{0}' is not supported on host platform: {1}",
1518
"ProjectVersionNotParsable": "Couldn't parse the version component of the package at {0}: version = {1}",
1619
"ProjectVersionUnsupported": "Project version = {0}",
17-
"ProjectVersionNotReadable":"Unable to read version = {0}",
20+
"ProjectVersionNotReadable": "Unable to read version = {0}",
1821
"TelemetryInitializationFailed": "{0}. Couldn't initialize telemetry",
1922
"ExtensionActivationFailed": "Failed to activate the React Native Tools extension",
2023
"DebuggerStubLauncherFailed": "Failed to setup the stub launcher for the debugger",
@@ -32,5 +35,5 @@
3235
"CouldNotFindLocationOfNodeDebugger": "Couldn't find the location of the node-debugger extension",
3336
"PackagerRunningInDifferentPort": "A packager cannot be started on port {0} because a packager process is already running on port {1}",
3437
"ErrorWhileProcessingMessageInIPMSServer": "An error ocurred while handling message: {0}",
35-
"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?"
36-
}
38+
"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?",
39+
};

Diff for: src/common/error/internalErrorCode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export enum InternalErrorCode {
1616
FailedToPublishToExpHost = 111,
1717

1818
// Device Deployer errors
19-
IDeviceInstallerNotFound = 201,
19+
IOSDeployNotFound = 201,
2020

2121
// Device Runner errors
2222
DeviceNotPluggedIn = 301,

Diff for: src/common/ios/iOSPlatform.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import {PlistBuddy} from "../../common/ios/plistBuddy";
1313
import {IOSDebugModeManager} from "../../common/ios/iOSDebugModeManager";
1414
import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
1515
import {RemoteExtension} from "../../common/remoteExtension";
16-
17-
/* tslint:disable:no-var-requires */
18-
const ErrorStrings = require("../../../errorStrings/errorStrings.json");
19-
/* tslint:enable:no-var-requires */
16+
import {ErrorHelper} from "../../common/error/errorHelper";
2017

2118
export class IOSPlatform extends GeneralMobilePlatform {
2219
public static DEFAULT_IOS_PROJECT_RELATIVE_PATH = "ios";
@@ -33,13 +30,13 @@ export class IOSPlatform extends GeneralMobilePlatform {
3330
// We should add the common iOS build/run erros we find to this list
3431
private static RUN_IOS_FAILURE_PATTERNS: PatternToFailure[] = [{
3532
pattern: "No devices are booted",
36-
message: ErrorStrings.IOSSimulatorNotLaunchable,
33+
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
3734
}, {
3835
pattern: "FBSOpenApplicationErrorDomain",
39-
message: ErrorStrings.IOSSimulatorNotLaunchable,
36+
message: ErrorHelper.ERROR_STRINGS.IOSSimulatorNotLaunchable,
4037
}, {
4138
pattern: "ios-deploy",
42-
message: ErrorStrings.IOSDeployNotFound,
39+
message: ErrorHelper.ERROR_STRINGS.IOSDeployNotFound,
4340
}];
4441

4542
private static RUN_IOS_SUCCESS_PATTERNS = ["BUILD SUCCEEDED"];

Diff for: src/common/node/childProcess.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {ErrorHelper} from "../error/errorHelper";
77
import {InternalErrorCode} from "../error/internalErrorCode";
88

99
// Uncomment the following lines to record all spawned processes executions
10-
// import {Recorder} from "../../test/resources/processExecution/recorder";
10+
// import {Recorder} from "../../../test/resources/processExecution/recorder";
1111
// Recorder.installGlobalRecorder();
1212

1313
export interface IExecResult {

Diff for: src/extension/commandPaletteHandler.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class CommandPaletteHandler {
7777
*/
7878
public publishToExpHost(): Q.Promise<void> {
7979
return this.executeCommandInContext("publishToExpHost", () => {
80-
this.executePublishToExpHost().then((didPublish) => {
80+
return this.executePublishToExpHost().then((didPublish) => {
8181
if (!didPublish) {
8282
Log.logMessage("Publishing was unsuccessful. Please make sure you are logged in Exponent and your project is a valid Exponentjs project");
8383
}
@@ -164,7 +164,7 @@ export class CommandPaletteHandler {
164164
* Otherwise, displays an error message banner
165165
* {operation} - a function that performs the expected operation
166166
*/
167-
private executeCommandInContext(rnCommand: string, operation: () => Q.Promise<void> | void): Q.Promise<void> {
167+
private executeCommandInContext(rnCommand: string, operation: () => Q.Promise<void>): Q.Promise<void> {
168168
let reactNativeProjectHelper = new ReactNativeProjectHelper(this.workspaceRoot);
169169
return TelemetryHelper.generate("RNCommand", (generator) => {
170170
generator.add("command", rnCommand, false);
@@ -178,6 +178,7 @@ export class CommandPaletteHandler {
178178
return operation();
179179
} else {
180180
vscode.window.showErrorMessage("Current workspace is not a React Native project.");
181+
return;
181182
}
182183
});
183184
});

Diff for: src/test/common/commandExecutor.test.ts renamed to test/common/commandExecutor.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for details.
33

4-
import {CommandExecutor} from "../../common/commandExecutor";
5-
import { Log } from "../../common/log/log";
4+
import {CommandExecutor} from "../../src/common/commandExecutor";
5+
import { Log } from "../../src/common/log/log";
66

7-
import { Node } from "../../common/node/node";
8-
import { ChildProcess } from "../../common/node/childProcess";
7+
import { Node } from "../../src/common/node/node";
8+
import { ChildProcess } from "../../src/common/node/childProcess";
99

1010

1111
import { EventEmitter } from "events";

Diff for: src/test/common/extensionMessaging.test.ts renamed to test/common/extensionMessaging.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for details.
33

4-
import {ExtensionMessage, MessagingChannel} from "../../common/extensionMessaging";
4+
import {ExtensionMessage, MessagingChannel} from "../../src/common/extensionMessaging";
55

6-
import {RemoteExtension} from "../../common/remoteExtension";
6+
import {RemoteExtension} from "../../src/common/remoteExtension";
77

8-
import {InterProcessMessageSender} from "../../common/interProcessMessageSender";
8+
import {InterProcessMessageSender} from "../../src/common/interProcessMessageSender";
99

1010
import * as assert from "assert";
1111
import * as net from "net";

0 commit comments

Comments
 (0)