rm array proto funcs
This commit is contained in:
42
test.ce
42
test.ce
@@ -191,7 +191,7 @@ function collect_actor_tests(package_name, specific_test) {
|
||||
if (test_base != match_base) continue
|
||||
}
|
||||
|
||||
actor_tests.push({
|
||||
push(actor_tests,{
|
||||
package: package_name || "local",
|
||||
file: f,
|
||||
path: prefix + '/' + f
|
||||
@@ -219,12 +219,12 @@ function spawn_actor_test(test_info) {
|
||||
// Spawn the actor test - it should send back results
|
||||
var actor_path = text(test_info.path, 0, -3) // remove .ce
|
||||
entry.actor = $start(actor_path)
|
||||
pending_actor_tests.push(entry)
|
||||
push(pending_actor_tests, entry)
|
||||
} catch (e) {
|
||||
entry.status = "failed"
|
||||
entry.error = { message: `Failed to spawn actor: ${e}` }
|
||||
entry.duration_ns = 0
|
||||
actor_test_results.push(entry)
|
||||
push(actor_test_results, entry)
|
||||
log.console(` FAIL ${test_name}: `)
|
||||
log.error(e)
|
||||
}
|
||||
@@ -259,7 +259,7 @@ function run_tests(package_name, specific_test) {
|
||||
var match_base = ends_with(match_name, '.cm') ? text(match_name, 0, -3) : match_name
|
||||
if (test_name != match_base) continue
|
||||
}
|
||||
test_files.push(f)
|
||||
push(test_files, f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,11 +287,11 @@ function run_tests(package_name, specific_test) {
|
||||
|
||||
var tests = []
|
||||
if (is_function(test_mod)) {
|
||||
tests.push({name: 'main', fn: test_mod})
|
||||
push(tests, {name: 'main', fn: test_mod})
|
||||
} else if (is_object(test_mod)) {
|
||||
arrfor(array(test_mod), function(k) {
|
||||
if (is_function(test_mod[k])) {
|
||||
tests.push({name: k, fn: test_mod[k]})
|
||||
push(tests, {name: k, fn: test_mod[k]})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -344,7 +344,7 @@ function run_tests(package_name, specific_test) {
|
||||
var end_time = time.number()
|
||||
test_entry.duration_ns = round((end_time - start_time) * 1000000000)
|
||||
|
||||
file_result.tests.push(test_entry)
|
||||
push(file_result.tests, test_entry)
|
||||
pkg_result.total++
|
||||
}
|
||||
}
|
||||
@@ -358,12 +358,12 @@ function run_tests(package_name, specific_test) {
|
||||
duration_ns: 0,
|
||||
error: { message: `Error loading module: ${e}` }
|
||||
}
|
||||
file_result.tests.push(test_entry)
|
||||
push(file_result.tests, test_entry)
|
||||
pkg_result.failed++
|
||||
file_result.failed++
|
||||
pkg_result.total++
|
||||
}
|
||||
pkg_result.files.push(file_result)
|
||||
push(pkg_result.files, file_result)
|
||||
}
|
||||
return pkg_result
|
||||
}
|
||||
@@ -374,18 +374,18 @@ var all_actor_tests = []
|
||||
if (all_pkgs) {
|
||||
// Run local first if we're in a valid package
|
||||
if (is_valid_package('.')) {
|
||||
all_results.push(run_tests(null, null))
|
||||
push(all_results, run_tests(null, null))
|
||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(null, null))
|
||||
}
|
||||
|
||||
// Then all packages in lock
|
||||
var packages = shop.list_packages()
|
||||
for (var i = 0; i < length(packages); i++) {
|
||||
all_results.push(run_tests(packages[i], null))
|
||||
push(all_results, run_tests(packages[i], null))
|
||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(packages[i], null))
|
||||
}
|
||||
} else {
|
||||
all_results.push(run_tests(target_pkg, target_test))
|
||||
push(all_results, run_tests(target_pkg, target_test))
|
||||
all_actor_tests = array(all_actor_tests, collect_actor_tests(target_pkg, target_test))
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ function handle_actor_message(msg) {
|
||||
if (found_idx == -1) return
|
||||
|
||||
var base_entry = pending_actor_tests[found_idx]
|
||||
pending_actor_tests.splice(found_idx, 1)
|
||||
pending_actor_tests = array(array(pending_actor_tests, 0, found_idx), array(pending_actor_tests, found_idx + 1))
|
||||
|
||||
var end_time = time.number()
|
||||
var duration_ns = round((end_time - base_entry.start_time) * 1000000000)
|
||||
@@ -447,7 +447,7 @@ function handle_actor_message(msg) {
|
||||
log.console(` FAIL ${entry.test}: ${entry.error.message}`)
|
||||
}
|
||||
|
||||
actor_test_results.push(entry)
|
||||
push(actor_test_results, entry)
|
||||
}
|
||||
|
||||
check_completion()
|
||||
@@ -462,19 +462,19 @@ function check_timeouts() {
|
||||
var entry = pending_actor_tests[i]
|
||||
var elapsed_ms = (now - entry.start_time) * 1000
|
||||
if (elapsed_ms > ACTOR_TEST_TIMEOUT) {
|
||||
timed_out.push(i)
|
||||
push(timed_out, i)
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < length(timed_out); i++) {
|
||||
var idx = timed_out[i]
|
||||
var entry = pending_actor_tests[idx]
|
||||
pending_actor_tests.splice(idx, 1)
|
||||
pending_actor_tests = array(array(pending_actor_tests, 0, idx), array(pending_actor_tests, idx + 1))
|
||||
|
||||
entry.status = "failed"
|
||||
entry.error = { message: "Test timed out" }
|
||||
entry.duration_ns = ACTOR_TEST_TIMEOUT * 1000000
|
||||
actor_test_results.push(entry)
|
||||
push(actor_test_results, entry)
|
||||
log.console(` TIMEOUT ${entry.test}`)
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ function finalize_results() {
|
||||
}
|
||||
if (!pkg_result) {
|
||||
pkg_result = { package: r.package, files: [], total: 0, passed: 0, failed: 0 }
|
||||
all_results.push(pkg_result)
|
||||
push(all_results, pkg_result)
|
||||
}
|
||||
|
||||
var file_result = null
|
||||
@@ -519,10 +519,10 @@ function finalize_results() {
|
||||
}
|
||||
if (!file_result) {
|
||||
file_result = { name: r.file, tests: [], passed: 0, failed: 0 }
|
||||
pkg_result.files.push(file_result)
|
||||
push(pkg_result.files, file_result)
|
||||
}
|
||||
|
||||
file_result.tests.push(r)
|
||||
push(file_result.tests, r)
|
||||
pkg_result.total++
|
||||
if (r.status == "passed") {
|
||||
pkg_result.passed++
|
||||
@@ -639,7 +639,7 @@ Total: ${totals.total}, Passed: ${totals.passed}, Failed: ${totals.failed}
|
||||
for (var j = 0; j < length(pkg_res.files); j++) {
|
||||
var f = pkg_res.files[j]
|
||||
for (var k = 0; k < length(f.tests); k++) {
|
||||
pkg_tests.push(f.tests[k])
|
||||
push(pkg_tests, f.tests[k])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user