Skip to content

Commit

Permalink
Build: Use qunit/ during development instead of dist/
Browse files Browse the repository at this point in the history
Use the same directory structure for the build artefact during
releases and during development.

Since the release file path is used by published npm and bower
packages, keep that as-is, and rename the internal development
target from dist/ to qunit/.

After this, contributors and maintainers will want to delete any
dist/ directory they might have, to avoid accidental linting or
publishing.
  • Loading branch information
Krinkle authored Feb 21, 2021
1 parent 3539ce1 commit d80a986
Show file tree
Hide file tree
Showing 51 changed files with 125 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"__codeorigin/**",
"coverage/**",
"docs/_site/**",
"dist/**",
"lib/**",
"qunit/**",
"temp/**"
],
"overrides": [
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/.nyc_output
/__codeorigin
/coverage
/dist
/node_modules
/browserstack-run.pid
/qunit
/temp
/docs/_site/
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function( grunt ) {

"src-css": {
src: "src/qunit.css",
dest: "dist/qunit.css"
dest: "qunit/qunit.css"
}
},
eslint: {
Expand Down
5 changes: 0 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ This guide walks you through the QUnit release.
npm run build
```
* Rename `dist/` to `qunit/`:
```
mv dist/ qunit/
```
* Review the changes to the package and library files, compared to the previous release.
```
node build/review-package.js @LAST_VERSION
Expand Down
4 changes: 2 additions & 2 deletions build/tasks/test-on-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function( grunt ) {
}

// Refresh the QUnit global to be used in other tests
global.QUnit = requireFresh( "../../dist/qunit" );
global.QUnit = requireFresh( "../../qunit/qunit.js" );

done( !totals.failed );
} );
Expand All @@ -33,7 +33,7 @@ module.exports = function( grunt ) {

// Resolve current QUnit path and remove it from the require cache
// to avoid stacking the QUnit logs.
var QUnit = requireFresh( "../../dist/qunit" );
var QUnit = requireFresh( "../../qunit/qunit.js" );

// Expose QUnit to the global scope to be seen on the other tests.
global.QUnit = QUnit;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@
"authors": "grunt authors",
"coverage": "npm run build:coverage && npm run coverage:_cli && npm run coverage:_main && nyc report",
"coverage:_cli": "nyc --use-spawn-wrap --silent bin/qunit.js test/cli/*.js",
"coverage:_main": "nyc instrument --in-place dist/ && grunt connect:nolivereload qunit",
"coverage:_main": "nyc instrument --in-place qunit/ && grunt connect:nolivereload qunit",
"coveralls": "npm run coverage && cat coverage/lcov.info | coveralls"
},
"nyc": {
"include": [
"bin/**",
"dist/**",
"qunit/**",
"src/**"
],
"reporter": [
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isCoverage = process.env.BUILD_TARGET === "coverage";
module.exports = {
input: "src/qunit.js",
output: {
file: "dist/qunit.js",
file: "qunit/qunit.js",
sourcemap: isCoverage,
format: "iife",
exports: "none",
Expand Down
43 changes: 28 additions & 15 deletions src/cli/require-qunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
module.exports = function requireQUnit( resolve = require.resolve ) {
try {

// First we attempt to find QUnit relative to the current working directory.
// For:
//
// - QUnit is installed as local dependency and invoked normally
// within the current project, e.g. via `npm test`, `npm run …`,
// or `node_modules/.bin/qunit`.
// The below will lead to the same package directory that
// the CLI command belonged to.
//
// - QUnit is installed both as local dependency in the current project,
// and also globally installed via npm by the end-user.
// If the user (accidentally) ran the CLI command from their global
// install, then we prefer to stil use the qunit library file from the
// current project's dependency.
// eslint-disable-next-line node/no-missing-require
const localQUnitPath = resolve( "qunit", {

Expand All @@ -14,24 +26,25 @@ module.exports = function requireQUnit( resolve = require.resolve ) {
delete require.cache[ localQUnitPath ];
return require( localQUnitPath );
} catch ( e ) {
try {
if ( e.code === "MODULE_NOT_FOUND" ) {

// Second, we use the globally installed QUnit
// eslint-disable-next-line node/no-unpublished-require, node/no-missing-require
// For:
//
// - QUnit is installed globally via npm by the end-user, and the
// the user ran this global CLI command in a project directory that
// does not have a qunit dependency installed.
// Use the library file relative to the global CLI command in that case.
//
// - We are running a local command from within the source directory
// of the QUnit project itself (e.g. qunit Git repository).
// Use the library file relative to this command, within the source directory.
//
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
delete require.cache[ resolve( "../../qunit/qunit" ) ];
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
return require( "../../qunit/qunit" );
} catch ( e ) {
if ( e.code === "MODULE_NOT_FOUND" ) {

// Finally, we use the local development version of QUnit
// eslint-disable-next-line node/no-unpublished-require, node/no-missing-require
delete require.cache[ resolve( "../../dist/qunit" ) ];
// eslint-disable-next-line node/no-missing-require, node/no-unpublished-require
return require( "../../dist/qunit" );
}

throw e;
}

throw e;
}
};
4 changes: 2 additions & 2 deletions test/amd.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>QUnit AMD Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../node_modules/requirejs/require.js"></script>
</head>
<body>
Expand All @@ -13,7 +13,7 @@

require.config( {
paths: {
qunit: "../dist/qunit"
qunit: "../qunit/qunit"
}
} );

Expand Down
4 changes: 2 additions & 2 deletions test/autostart.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<head>
<meta charset="UTF-8">
<title>QUnit Autostart Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<link rel="stylesheet" href="../qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<script src="../dist/qunit.js"></script>
<script src="../qunit/qunit.js"></script>
<script>
window.times = {};

Expand Down
4 changes: 2 additions & 2 deletions test/callbacks-promises.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Callbacks Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="callbacks-promises.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/callbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Callbacks Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="callbacks.js"></script>
</head>
<body>
Expand Down
23 changes: 5 additions & 18 deletions test/cli/require-qunit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,30 @@ QUnit.module( "requireQUnit", function( hooks ) {
process.chdir( cwd );
} );

QUnit.test( "finds QUnit in the current working directory", function( assert ) {
QUnit.test( "finds QUnit package in the current working directory", function( assert ) {
const requireQUnit = require( "../../src/cli/require-qunit" );
process.chdir( path.join( __dirname, "./fixtures/require-from-cwd" ) );

assert.propEqual( requireQUnit(), { version: "from-cwd" } );
} );

QUnit.test( "finds globally installed QUnit", function( assert ) {
// For development mode invoked locally,
// or for global install without local dependency installed.
QUnit.test( "finds relative self", function( assert ) {
const globalQUnit = {
"version": "from-global"
};
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"qunit": null,
"../../dist/qunit": null,
"../../qunit/qunit": globalQUnit
} );
assert.strictEqual( requireQUnit( resolveStub ), globalQUnit );
} );

QUnit.test( "finds development mode QUnit", function( assert ) {
const devQUnit = {
"version": "from-dist"
};
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"qunit": null,
"../../qunit/qunit": null,
"../../dist/qunit": devQUnit
} );

assert.strictEqual( requireQUnit( resolveStub ), devQUnit );
} );

QUnit.test( "throws error if none of the modules are found", function( assert ) {
const requireQUnit = proxyquire( "../../src/cli/require-qunit", {
"qunit": null,
"../../qunit/qunit": null,
"../../dist/qunit": null
"../../qunit/qunit": null
} );

assert.throws( requireQUnit, /Cannot find module/ );
Expand Down
4 changes: 2 additions & 2 deletions test/events-filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>Events Filters</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="events-filters.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/events-in-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Events During Tests</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="events-in-test.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Events Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="events.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/headless.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Headless Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="main/test.js"></script>
<script src="main/deepEqual.js"></script>
<script>
Expand Down
4 changes: 2 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Main Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="main/test.js"></script>
<script src="main/assert.js"></script>
<script src="main/assert/step.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions test/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Logs Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="logs.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion test/main/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
assert.true( /(\/|\\)test(\/|\\)main(\/|\\)stack\.js/.test( stack ) );

stack = QUnit.stack( 2 );
assert.true( /(\/|\\)dist(\/|\\)qunit\.js/.test( stack ), "can use offset argument to return a different stacktrace line" );
assert.true( /(\/|\\)qunit(\/|\\)qunit\.js/.test( stack ), "can use offset argument to return a different stacktrace line" );
assert.false( /\/test\/main\/stack\.js/.test( stack ), "stack with offset argument" );
} );
}() );
4 changes: 2 additions & 2 deletions test/module-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit Module Filter Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="module-filter.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/module-skip.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit module Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="module-skip.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/module-todo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit module Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="module-todo.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/moduleId.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit ModuleId Test Suite</title>
<link rel="stylesheet" href="../dist/qunit.css">
<script src="../dist/qunit.js"></script>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="moduleId.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion test/mozjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable lines-around-comment */
/* global loadRelativeToScript */

loadRelativeToScript( "../dist/qunit.js" );
loadRelativeToScript( "../qunit/qunit.js" );

QUnit.on( "runStart", () => {
print( "Running tests..." );
Expand Down
4 changes: 2 additions & 2 deletions test/onerror/inside-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit onerror tests</title>
<link rel="stylesheet" href="../../dist/qunit.css">
<script src="../../dist/qunit.js"></script>
<link rel="stylesheet" href="../../qunit/qunit.css">
<script src="../../qunit/qunit.js"></script>
<script src="./inside-test.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions test/onerror/outside-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>QUnit onerror tests</title>
<link rel="stylesheet" href="../../dist/qunit.css">
<script src="../../dist/qunit.js"></script>
<link rel="stylesheet" href="../../qunit/qunit.css">
<script src="../../qunit/qunit.js"></script>
<script src="./outside-test.js"></script>
</head>
<body>
Expand Down
Loading

0 comments on commit d80a986

Please sign in to comment.