Skip to content

Commit b08c226

Browse files
nodejs-github-botaduh95
authored andcommitted
test: update test426-fixtures to fae1fa49815813088c433e8486e330e8d953a44
PR-URL: #66815 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b6e024a commit b08c226

17 files changed

Lines changed: 1065 additions & 7 deletions
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Validate tests and build npm package
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
with:
19+
# Fetch all to count number of commits and compute pkg version
20+
fetch-depth: 0
21+
- uses: actions/setup-node@v6
22+
with:
23+
node-version: lts/*
24+
cache: npm
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Build npm package
28+
run: node scripts/build-npm-package.js
29+
- name: Check that JSON files match their TypeScript types
30+
run: node scripts/check-types.js
31+
- name: Pack npm package
32+
run: mkdir -p dist && npm pack ./npm-package --pack-destination dist
33+
- name: Upload package tarball
34+
uses: actions/upload-artifact@v7
35+
with:
36+
name: npm-package
37+
path: dist/*.tgz
38+
if-no-files-found: error
39+
retention-days: 7
40+
41+
publish:
42+
name: Publish to npm
43+
needs: build
44+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'tc39/source-map-tests'
45+
runs-on: ubuntu-latest
46+
permissions:
47+
contents: read
48+
id-token: write # for npm trusted publishing
49+
concurrency:
50+
group: npm-publish
51+
cancel-in-progress: false
52+
steps:
53+
- uses: actions/checkout@v6
54+
with:
55+
fetch-depth: 0
56+
- uses: actions/setup-node@v6
57+
with:
58+
node-version: lts/*
59+
registry-url: https://registry.npmjs.org
60+
- name: Build npm package
61+
run: node scripts/build-npm-package.js
62+
- name: Publish
63+
run: |
64+
name=$(node -p "require('./npm-package/package.json').name")
65+
version=$(node -p "require('./npm-package/package.json').version")
66+
if [ -n "$(npm view "$name@$version" version 2>/dev/null)" ]; then
67+
echo "$name@$version is already published, skipping."
68+
else
69+
npm publish ./npm-package --access public
70+
fi

‎test/fixtures/test426/.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
npm-package/*
2+
!npm-package/README.md
3+
!npm-package/package.template.json
4+
!npm-package/types/
5+
node_modules/
6+
.tmp/

‎test/fixtures/test426/README.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,42 @@ More information about running Chrome Devtools without building Chromium can be
5858

5959
Follow the [running Node.js tests guide](https://github.com/nodejs/node/blob/main/BUILDING.md#running-tests) to build Node.js and run tests locally.
6060
Read more about running the source map tests at [here](https://github.com/nodejs/node/tree/main/test/test426).
61+
62+
## npm package
63+
64+
The test cases are published to npm as [`@tc39/source-map-tests`](https://www.npmjs.com/package/@tc39/source-map-tests), so that source map implementations can run them in their own test suites. A new version is published for every commit to `main`.
65+
66+
```sh
67+
npm install --save-dev --save-exact @tc39/source-map-tests
68+
```
69+
70+
### Usage
71+
72+
`@tc39/source-map-tests/suites.json` lists the test suites:
73+
74+
```json
75+
{
76+
"suites": [
77+
{ "kind": "interpreting", "file": "interpreting/source-map-spec.json" },
78+
{ "kind": "decoding", "file": "decoding/scopes.json" }
79+
]
80+
}
81+
```
82+
83+
There are two types of test suites: `interpreting` and `decoding`:
84+
- **interpreting** provided a source map to apply to a generated file, together with some actions to perform through it to check that it has been applied correctly.
85+
- **decoding** suites check that a source map is correctly decoded into a [Decoded Source Map Record](https://tc39.es/ecma426/#decoded-source-map-record).
86+
87+
### TypeScript
88+
89+
The package's root exports the types of the JSON files:
90+
91+
```ts
92+
import type { InterpretingSuite, DecodingSuite, TestAction } from "@tc39/source-map-tests";
93+
```
94+
95+
With TypeScript 7.1 or later, you can load type definitions for the various suites by adding `"types": ["@tc39/source-map-tests"]` to your `tsconfig.json`. Imported JSON modules then will be typed appropriately:
96+
```ts
97+
import spec from "@tc39/source-map-tests/interpreting/source-map-spec.json" with { type: "json" };
98+
spec.tests[0].testActions; // TestAction[]
99+
```

‎test/fixtures/test426/decoding/debug-id/debug-id-index-section.map‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"sections": [{
55
"offset": {
66
"line": 0,
7-
"column": 0,
7+
"column": 0
88
},
99
"map": {
1010
"version": 3,
@@ -16,7 +16,7 @@
1616
}, {
1717
"offset": {
1818
"line": 1,
19-
"column": 0,
19+
"column": 0
2020
},
2121
"map": {
2222
"version": 3,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"file": "app.js",
33
"sources": [],
4-
"mappings": [],
4+
"mappings": []
55
}

‎test/fixtures/test426/decoding/debug-id/debug-id-index.map‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"sections": [{
66
"offset": {
77
"line": 0,
8-
"column": 0,
8+
"column": 0
99
},
1010
"map": {
1111
"version": 3,
@@ -17,7 +17,7 @@
1717
}, {
1818
"offset": {
1919
"line": 1,
20-
"column": 0,
20+
"column": 0
2121
},
2222
"map": {
2323
"version": 3,

‎test/fixtures/test426/decoding/debug-id/debug-id.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
/// <reference path="../source-map-record.d.ts" />
33

44
interface SourceMapRecord {
5-
debugId: string|null;
5+
debugId?: string|null;
66
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# @tc39/source-map-tests
2+
3+
Cross-implementation test cases for the [ECMA-426 source map specification](https://tc39.es/ecma426/).
4+
5+
See the [tc39/source-map-tests README](https://github.com/tc39/source-map-tests#npm-package) for the package contents and usage.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@tc39/source-map-tests",
3+
"version": "X.X.X",
4+
"description": "Cross-implementation test cases for the ECMA-426 source map specification",
5+
"license": "BSD-3-Clause",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/tc39/source-map-tests.git"
9+
},
10+
"homepage": "https://github.com/tc39/source-map-tests#readme",
11+
"bugs": "https://github.com/tc39/source-map-tests/issues",
12+
"keywords": [
13+
"source-map",
14+
"sourcemap",
15+
"ecma-426",
16+
"test-suite",
17+
"tests"
18+
],
19+
"files": [
20+
"suites.json",
21+
"interpreting/",
22+
"decoding/",
23+
"types/",
24+
"LICENSE.md"
25+
]
26+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference path="./modules.d.ts" />
2+
export * from "./types.js";

0 commit comments

Comments
 (0)