Skip to content

Commit

Permalink
Merge branch 'mochajs:master' into configurable-max-diff-size
Browse files Browse the repository at this point in the history
  • Loading branch information
norla committed Feb 15, 2022
2 parents 8299390 + 509938d commit a1b68cd
Show file tree
Hide file tree
Showing 27 changed files with 4,757 additions and 3,476 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -530,5 +530,6 @@ Michal Dorner <dorner.michal@gmail.com>
Curtis Man <curtism@microsoft.com>
华 <1395348685z@gmail.com>
Andrei Rusu <beatfactor@users.noreply.github.com>
Quentin Barbe <forty@everteam.org>

# Generated by scripts/update-authors.js
114 changes: 67 additions & 47 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2011-2021 OpenJS Foundation and contributors, https://openjsf.org
Copyright (c) 2011-2022 OpenJS Foundation and contributors, https://openjsf.org

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -65,6 +65,6 @@ Finally, come [chat with the maintainers](https://gitter.im/mochajs/contributors

## License

Copyright 2011-2021 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/master/LICENSE).
Copyright 2011-2022 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/master/LICENSE).

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large)
4 changes: 2 additions & 2 deletions docs/_data/supporters.js
Expand Up @@ -18,7 +18,7 @@
'use strict';

const {loadImage} = require('canvas');
const {writeFile, mkdir, rmdir} = require('fs').promises;
const {writeFile, mkdir, rm} = require('fs').promises;
const {resolve} = require('path');
const debug = require('debug')('mocha:docs:data:supporters');
const needle = require('needle');
Expand Down Expand Up @@ -225,7 +225,7 @@ const getSupporters = async () => {
}
);

await rmdir(SUPPORTER_IMAGE_PATH, {recursive: true});
await rm(SUPPORTER_IMAGE_PATH, {recursive: true, force: true});
debug('blasted %s', SUPPORTER_IMAGE_PATH);
await mkdir(SUPPORTER_IMAGE_PATH, {recursive: true});
debug('created %s', SUPPORTER_IMAGE_PATH);
Expand Down
46 changes: 13 additions & 33 deletions docs/_includes/default.liquid
Expand Up @@ -25,38 +25,14 @@

<main id="content">{{ content }}</main>

<aside class="sponsorship">
<a
href="https://matomo.org/"
rel="external noopener"
title="Mocha is sponsored by Matomo"
>
<img src="images/matomo-logo.png?trim" loading="lazy" alt="Matomo logo" />
<div class="sponsorship">
<a href="https://matomo.org/" rel="external noopener" title="Mocha is sponsored by Matomo">
<img src="images/matomo-logo.png?trim" loading="lazy" width="100" alt="Matomo logo">
</a>
<a
title="Mocha is an OpenJS Foundation Project"
href="https://openjsf.org"
rel="external noopener"
>
<img
src="/images/openjsf-logo.svg"
loading="lazy"
width="300"
height="94"
alt="OpenJS Foundation Logo"
/>
<a href="https://wallabyjs.com" rel="external noopener" title="Mocha is sponsored by Wallaby" id="wallaby-logo">
<img src="https://wallabyjs.com/assets/img/logoWithText.svg" loading="lazy" width="140" alt="Wallaby logo">
</a>
<a
href="https://wallabyjs.com"
rel="external noopener"
title="Mocha is sponsored by Wallaby"
>
<figure id="wallaby-logo">
<img src="images/wallaby-logo.png" loading="lazy" alt="Wallaby logo" />
<figcaption>Wallaby</figcaption>
</figure>
</a>
</aside>
</div>

<footer>
<div id="copyright-notice">
Expand Down Expand Up @@ -100,6 +76,12 @@
</p>
</div>

<div class="openjsf-logo">
<a title="Mocha is an OpenJS Foundation Project" href="https://openjsf.org" rel="external noopener" >
<img src="/images/openjsf-logo.svg" loading="lazy" width="120" alt="OpenJS Foundation Logo">
</a>
</div>

<div id="external-links">
<ul id="openjsf-links">
<li>
Expand Down Expand Up @@ -148,9 +130,7 @@
</ul>
<div class="netlify-badge">
<a href="https://www.netlify.com">
<img
src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" loading="lazy"
/>
<img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" loading="lazy">
</a>
</div>
</div>
Expand Down
61 changes: 18 additions & 43 deletions docs/css/style.css
Expand Up @@ -45,7 +45,7 @@ header {
}

#content {
padding-bottom: 60px;
padding-bottom: 30px;
}

#_header h1 {
Expand Down Expand Up @@ -242,31 +242,6 @@ img.screenshot {
max-width: 100%;
}

.sponsorship a {
display: flex;
justify-content: center;
align-items: center;
}

.sponsorship a img {
display: block;
object-fit: cover;
width: 100%;
height: 100%;
}

.sponsorship {
display: flex;
justify-content: center;
margin-bottom: 60px;
align-items: center;
}

.sponsorship a {
padding: 0 40px;
text-decoration: none;
}

footer {
background-color: #eee;
border-top: 1px solid #ddd;
Expand Down Expand Up @@ -309,12 +284,29 @@ footer {
content: ' | ';
}

.openjsf-logo {
margin-bottom: 10px;
}

#external-links .netlify-badge {
position: absolute;
right: 0;
bottom: 0;
}

.sponsorship {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30px;
}

.sponsorship a {
display: inline-block;
margin-right: 15px;
margin-left: 15px;
}

.dl-inline dt,
.dl-inline dd {
display: inline;
Expand All @@ -335,23 +327,6 @@ blockquote {
padding: 10px;
}

figure#wallaby-logo {
vertical-align: top;
display: inline-block;
text-align: center;
}
figure#wallaby-logo figcaption {
margin-top: 10px;
display: block;
font-family: 'Open Sans', -apple-system, system-ui, 'Segoe UI', Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
color: #2c2c2c;
-webkit-font-smoothing: antialiased;
}

table {
width: 100%;
}
Expand Down
6 changes: 6 additions & 0 deletions docs/index.md
Expand Up @@ -1389,6 +1389,12 @@ Free-tier cloud CI services may not provide a suitable multi-core container or V

It's unlikely (but not impossible) to see a performance gain from a [job count](#-jobs-count-j-count) _greater than_ the number of available CPU cores. That said, _play around with the job count_--there's no one-size-fits all, and the unique characteristics of your tests will determine the optimal number of jobs; it may even be that fewer is faster!

### Parallel Mode Worker IDs

> _New in v9.2.0_
Each process launched by parallel mode is assigned a unique id, from 0 for the first process to be launched, to N-1 for the Nth process. This worker id may be accessed in tests via the environment variable `MOCHA_WORKER_ID`. It can be used for example to assign a different database, service port, etc for each test process.

## Root Hook Plugins

> _New in v8.0.0_
Expand Down
18 changes: 17 additions & 1 deletion lib/nodejs/buffered-worker-pool.js
Expand Up @@ -75,7 +75,23 @@ class BufferedWorkerPool {
process.execArgv.join(' ')
);

this.options = {...WORKER_POOL_DEFAULT_OPTS, opts, maxWorkers};
let counter = 0;
const onCreateWorker = ({forkOpts}) => {
return {
forkOpts: {
...forkOpts,
// adds an incremental id to all workers, which can be useful to allocate resources for each process
env: {...process.env, MOCHA_WORKER_ID: counter++}
}
};
};

this.options = {
...WORKER_POOL_DEFAULT_OPTS,
...opts,
maxWorkers,
onCreateWorker
};
this._pool = workerpool.pool(WORKER_PATH, this.options);
}

Expand Down
21 changes: 18 additions & 3 deletions lib/nodejs/esm-utils.js
Expand Up @@ -53,15 +53,30 @@ exports.requireOrImport = hasStableEsmImplementation
err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
) {
try {
// Importing a file usually works, but the resolution of `import` is the ESM
// resolution algorithm, and not the CJS resolution algorithm. So in this case
// if we fail, we may have failed because we tried the ESM resolution and failed
// So we try to `require` it
return require(file);
} catch (requireErr) {
if (requireErr.code === 'ERR_REQUIRE_ESM') {
// This happens when the test file is a JS file, but via type:module is actually ESM,
if (
requireErr.code === 'ERR_REQUIRE_ESM' ||
(requireErr instanceof SyntaxError &&
requireErr
.toString()
.includes('Cannot use import statement outside a module'))
) {
// ERR_REQUIRE_ESM happens when the test file is a JS file, but via type:module is actually ESM,
// AND has an import to a file that doesn't exist.
// This throws an `ERR_MODULE_NOT_FOUND` // error above,
// This throws an `ERR_MODULE_NOT_FOUND` error above,
// and when we try to `require` it here, it throws an `ERR_REQUIRE_ESM`.
// What we want to do is throw the original error (the `ERR_MODULE_NOT_FOUND`),
// and not the `ERR_REQUIRE_ESM` error, which is a red herring.
//
// SyntaxError happens when in an edge case: when we're using an ESM loader that loads
// a `test.ts` file (i.e. unrecognized extension), and that file includes an unknown
// import (which thows an ERR_MODULE_NOT_FOUND). require-ing it will throw the
// syntax error, because we cannot require a file that has import-s.
throw err;
} else {
throw requireErr;
Expand Down
4 changes: 2 additions & 2 deletions netlify.toml
Expand Up @@ -14,8 +14,8 @@

[build.environment]
DEBUG = "mocha:docs*"
NODE_VERSION = "12"
RUBY_VERSION = "2.7.1"
NODE_VERSION = "16"
RUBY_VERSION = "2.7.2"

[context.deploy-preview]
command = "npm start docs"
Expand Down

0 comments on commit a1b68cd

Please sign in to comment.