Commit 94a941ed authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Move unit tests to test/unittests

Change-Id: I4dd89cae3441f1da5ae4b2a393a3ff66a67f6451
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859787
Auto-Submit: Yang Guo <yangguo@chromium.org>
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: default avatarPaul Lewis <aerotwist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705524}
parent 4e201bf5
...@@ -17,14 +17,14 @@ module.exports = function(config) { ...@@ -17,14 +17,14 @@ module.exports = function(config) {
included: false, included: false,
served: true served: true
},{ },{
pattern: 'tests/**/*.ts', pattern: 'test/unittests/**/*.ts',
type: 'module' type: 'module'
}], }],
reporters: ['dots', 'coverage-istanbul'], reporters: ['dots', 'coverage-istanbul'],
preprocessors: { preprocessors: {
'./tests/**/*.ts': ['karma-typescript'], './test/unittests/**/*.ts': ['karma-typescript'],
'./front_end/common/*.js': ['karma-coverage-istanbul-instrumenter'] './front_end/common/*.js': ['karma-coverage-istanbul-instrumenter']
}, },
......
...@@ -11,14 +11,14 @@ import sys ...@@ -11,14 +11,14 @@ import sys
import devtools_paths import devtools_paths
is_cygwin = sys.platform == "cygwin" is_cygwin = sys.platform == 'cygwin'
chrome_binary = None chrome_binary = None
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
chrome_binary = re.sub(r"^\-\-chrome-binary=(.*)", "\\1", sys.argv[1]) chrome_binary = re.sub(r'^\-\-chrome-binary=(.*)', '\\1', sys.argv[1])
is_executable = os.path.exists(chrome_binary) and os.path.isfile(chrome_binary) and os.access(chrome_binary, os.X_OK) is_executable = os.path.exists(chrome_binary) and os.path.isfile(chrome_binary) and os.access(chrome_binary, os.X_OK)
if not is_executable: if not is_executable:
print("Unable to find a Chrome binary at \"%s\"" % chrome_binary) print('Unable to find a Chrome binary at \'%s\'' % chrome_binary)
sys.exit(1) sys.exit(1)
...@@ -29,26 +29,26 @@ def popen(arguments, cwd=None, env=None): ...@@ -29,26 +29,26 @@ def popen(arguments, cwd=None, env=None):
def to_platform_path_exact(filepath): def to_platform_path_exact(filepath):
if not is_cygwin: if not is_cygwin:
return filepath return filepath
output, _ = popen(["cygpath", "-w", filepath]).communicate() output, _ = popen(['cygpath', '-w', filepath]).communicate()
# pylint: disable=E1103 # pylint: disable=E1103
return output.strip().replace("\\", "\\\\") return output.strip().replace('\\', '\\\\')
scripts_path = os.path.dirname(os.path.abspath(__file__)) scripts_path = os.path.dirname(os.path.abspath(__file__))
devtools_path = os.path.dirname(scripts_path) devtools_path = os.path.dirname(scripts_path)
print("Running tests with Karma...") print('Running tests with Karma...')
if (chrome_binary is not None): if (chrome_binary is not None):
print("Using custom Chrome Binary (%s)\n" % chrome_binary) print('Using custom Chrome Binary (%s)\n' % chrome_binary)
else: else:
print("Using system Chrome") print('Using system Chrome')
def run_tests(): def run_tests():
karma_errors_found = False karma_errors_found = False
karmaconfig_path = os.path.join(devtools_path, "karma.conf.js") karmaconfig_path = os.path.join(devtools_path, 'karma.conf.js')
exec_command = [devtools_paths.node_path(), devtools_paths.karma_path(), "start", to_platform_path_exact(karmaconfig_path)] exec_command = [devtools_paths.node_path(), devtools_paths.karma_path(), 'start', to_platform_path_exact(karmaconfig_path)]
env = {'NODE_PATH': devtools_paths.node_modules_path()} env = {'NODE_PATH': devtools_paths.node_modules_path()}
if (chrome_binary is not None): if (chrome_binary is not None):
...@@ -60,7 +60,7 @@ def run_tests(): ...@@ -60,7 +60,7 @@ def run_tests():
if karma_proc.returncode != 0: if karma_proc.returncode != 0:
karma_errors_found = True karma_errors_found = True
else: else:
print("Karma exited successfully") print('Karma exited successfully')
print(karma_proc_out) print(karma_proc_out)
return karma_errors_found return karma_errors_found
...@@ -69,5 +69,5 @@ def run_tests(): ...@@ -69,5 +69,5 @@ def run_tests():
errors_found = run_tests() errors_found = run_tests()
if errors_found: if errors_found:
print("ERRORS DETECTED") print('ERRORS DETECTED')
sys.exit(1) sys.exit(1)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const { assert } = chai; const { assert } = chai;
import { default as Color } from '../../../front_end/common/Color.js'; import { default as Color } from '../../../../front_end/common/Color.js';
describe('Color', () => { describe('Color', () => {
describe('parse', () => { describe('parse', () => {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const { assert } = chai; const { assert } = chai;
import { default as Console, Events, MessageLevel } from '../../../front_end/common/Console.js'; import { default as Console, Events, MessageLevel } from '../../../../front_end/common/Console.js';
describe('Console', () => { describe('Console', () => {
let consoleImpl: Console; let consoleImpl: Console;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const { assert } = chai; const { assert } = chai;
import { default as ObjectWrapper } from '../../../front_end/common/Object.js'; import { default as ObjectWrapper } from '../../../../front_end/common/Object.js';
describe('ObjectWrapper', () => { describe('ObjectWrapper', () => {
let obj: ObjectWrapper; let obj: ObjectWrapper;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const {assert} = chai; const {assert} = chai;
import {default as ParsedURL} from '../../../front_end/common/ParsedURL.js'; import {default as ParsedURL} from '../../../../front_end/common/ParsedURL.js';
describe('Parsed URL', () => { describe('Parsed URL', () => {
it('recognizes valid URLs', () => { it('recognizes valid URLs', () => {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const { assert } = chai; const { assert } = chai;
import { default as SegmentedRange, Segment } from '../../../front_end/common/SegmentedRange.js'; import { default as SegmentedRange, Segment } from '../../../../front_end/common/SegmentedRange.js';
describe('Segment', () => { describe('Segment', () => {
it('calculates intersections', () => { it('calculates intersections', () => {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
const {assert} = chai; const {assert} = chai;
import {default as TextDictionary} from '../../../front_end/common/TextDictionary.js'; import {default as TextDictionary} from '../../../../front_end/common/TextDictionary.js';
import {default as Trie} from '../../../front_end/common/Trie.js'; import {default as Trie} from '../../../../front_end/common/Trie.js';
describe('Text Dictionary', () => { describe('Text Dictionary', () => {
it('can be created with its basic attributes', () => { it('can be created with its basic attributes', () => {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
const { assert } = chai; const { assert } = chai;
import { default as Trie } from '../../../front_end/common/Trie.js'; import { default as Trie } from '../../../../front_end/common/Trie.js';
describe('Trie', () => { describe('Trie', () => {
let trie: Trie; let trie: Trie;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
const { assert } = chai; const { assert } = chai;
import '../../../front_end/dom_extension/DOMExtension.js'; import '../../../../front_end/dom_extension/DOMExtension.js';
declare global { declare global {
function createElementWithClass(tagName: string, className?: string, content?: string): HTMLElement; function createElementWithClass(tagName: string, className?: string, content?: string): HTMLElement;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
const { assert } = chai; const { assert } = chai;
// FIXME: Convert to pure functions as these utilities have side effects. // FIXME: Convert to pure functions as these utilities have side effects.
import '../../../front_end/platform/utilities.js'; import '../../../../front_end/platform/utilities.js';
declare global { declare global {
interface Array<T> { interface Array<T> {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment