Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add runCucumber function internally #1849

Merged
merged 47 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
671f9c5
super rough first pass at interface
davidjgoss Jul 8, 2021
86ffc97
style
davidjgoss Jul 8, 2021
73f1389
keep going
davidjgoss Jul 8, 2021
7d5e0a9
Merge branch 'main' into api-poc
davidjgoss Sep 19, 2021
0b3ab76
remove dummy usage
davidjgoss Sep 23, 2021
2986f70
export options interface
davidjgoss Sep 23, 2021
4765707
just enough to get cck passing
davidjgoss Sep 24, 2021
00137af
start to add some structure
davidjgoss Sep 24, 2021
f6f61b7
deal with i18n from commander
davidjgoss Sep 25, 2021
cf84823
use method to append to help output
davidjgoss Sep 25, 2021
ec7c43f
rename
davidjgoss Sep 25, 2021
7236c2c
dialect is defaulted inside gherkin
davidjgoss Sep 25, 2021
b31f728
fn to map formatters config
davidjgoss Sep 26, 2021
5db972a
111 failing
davidjgoss Sep 26, 2021
8c57baf
(104) honour more of the config
davidjgoss Sep 26, 2021
edb6332
(12) honour formatters config mostly
davidjgoss Sep 26, 2021
6e3a7f8
default environment stuff
davidjgoss Sep 26, 2021
894d4e3
(11) honour order config, some renaming
davidjgoss Sep 26, 2021
a3ecb11
honour preditable ids for now
davidjgoss Sep 28, 2021
8fec813
make publish work, refactor formatter init
davidjgoss Sep 29, 2021
7cd8d20
split out paths stuff, port tests over
davidjgoss Sep 29, 2021
9e6a161
parallel runtime
davidjgoss Sep 29, 2021
22f4a0e
merge main
davidjgoss Sep 29, 2021
96440a4
whoops fix cck
davidjgoss Sep 29, 2021
b298c60
simplify publish banner logic
davidjgoss Sep 30, 2021
acda914
strip some dead code
davidjgoss Sep 30, 2021
29eb7ee
unify runtime options interface
davidjgoss Oct 1, 2021
4523b77
decouple process.env
davidjgoss Oct 3, 2021
475ee6f
merge main
davidjgoss Oct 10, 2021
b39af57
Merge remote-tracking branch 'origin/main' into api-poc
davidjgoss Oct 10, 2021
792467c
move initializeFormatters to own file
davidjgoss Oct 16, 2021
bb09ea6
split out getSupportCodeLibrary
davidjgoss Oct 17, 2021
5214ad2
no need for this to be a map
davidjgoss Oct 17, 2021
0bd2773
change dir name
davidjgoss Oct 24, 2021
2e13805
merge main
davidjgoss Oct 30, 2021
f5a957a
Merge remote-tracking branch 'origin/main' into api-poc
davidjgoss Nov 6, 2021
00b7fde
revert interface
davidjgoss Nov 6, 2021
9f1b746
probably fix everything
davidjgoss Nov 6, 2021
418b6a4
move some types around
davidjgoss Nov 6, 2021
4478f1d
move props from pickles into sources
davidjgoss Nov 25, 2021
bf22d89
make runtime options optional!
davidjgoss Nov 25, 2021
39a14d6
Merge remote-tracking branch 'origin/main' into api-poc
davidjgoss Dec 4, 2021
f66c54d
Merge branch 'main' into api-poc
aurelien-reeves Dec 6, 2021
68fd6a8
Merge branch 'api-poc' of github.com:cucumber/cucumber-js into api-poc
davidjgoss Dec 9, 2021
9f97485
make an interface for the environment bits
davidjgoss Dec 9, 2021
5a76bfb
make a type for order
davidjgoss Dec 9, 2021
9db9f61
add test to cover defaults
davidjgoss Dec 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions compatibility/cck_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import glob from 'glob'
import fs from 'fs'
import path from 'path'
import { PassThrough, pipeline, Writable } from 'stream'
import { Cli } from '../src'
import toString from 'stream-to-string'
import {
ignorableKeys,
Expand All @@ -14,6 +13,8 @@ import {
import * as messages from '@cucumber/messages'
import * as messageStreams from '@cucumber/message-streams'
import util from 'util'
import { runCucumber } from '../src/run'
import { IRunConfiguration } from '../src/configuration'

const asyncPipeline = util.promisify(pipeline)
const PROJECT_PATH = path.join(__dirname, '..')
Expand All @@ -29,27 +30,28 @@ describe('Cucumber Compatibility Kit', () => {
const suiteName = match[1]
const extension = match[2]
it(`passes the cck suite for '${suiteName}'`, async () => {
const cliOptions = [
`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`,
'--require',
`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`,
'--profile',
'cck',
]
if (suiteName === 'retry') {
cliOptions.push('--retry', '2')
}
const args = [
'node',
path.join(PROJECT_PATH, 'bin', 'cucumber-js'),
].concat(cliOptions)
const stdout = new PassThrough()
const runConfiguration: IRunConfiguration = {
sources: {
paths: [`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`],
},
support: {
transpileWith: ['ts-node/register'],
paths: [`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`],
},
formats: {
stdout: 'message',
},
runtime: {
retry: suiteName === 'retry' ? 2 : 0,
},
}
try {
await new Cli({
argv: args,
await runCucumber(runConfiguration, {
cwd: PROJECT_PATH,
stdout,
}).run()
env: process.env,
})
} catch (ignored) {
console.error(ignored)
}
Expand Down
34 changes: 12 additions & 22 deletions cucumber.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
const feature = [
'--require-module ts-node/register',
'--require features/**/*.ts',
`--format progress-bar`,
'--format rerun:@rerun.txt',
'--format usage:usage.txt',
'--format message:messages.ndjson',
'--format html:html-formatter.html',
'--retry 2',
'--retry-tag-filter @flaky',
'--publish-quiet',
].join(' ')

const cck = [
'--require-module',
'ts-node/register',
'--format',
'message',
].join(' ')

module.exports = {
default: feature,
cck,
default: [
'--require-module ts-node/register',
'--require features/**/*.ts',
`--format progress-bar`,
'--format rerun:@rerun.txt',
'--format usage:usage.txt',
'--format message:messages.ndjson',
'--format html:html-formatter.html',
'--retry 2',
'--retry-tag-filter @flaky',
'--publish-quiet',
].join(' '),
}
1 change: 1 addition & 0 deletions features/i18n.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@spawn
Feature: internationalization

Scenario: view available languages
Expand Down
1 change: 1 addition & 0 deletions features/support/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class World {
argv: args,
cwd,
stdout,
env,
})
let error: any, stderr: string
try {
Expand Down
23 changes: 16 additions & 7 deletions src/cli/argv_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { Command } from 'commander'
import path from 'path'
import { dialects } from '@cucumber/gherkin'
import { SnippetInterface } from '../formatter/step_definition_snippet_builder/snippet_syntax'
import { getKeywords, getLanguages } from './i18n'
import Formatters from '../formatter/helpers/formatters'
import { PickleOrder } from './helpers'

// Using require instead of import so compiled typescript will have the desired folder structure
const { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires
Expand Down Expand Up @@ -31,7 +33,7 @@ export interface IParsedArgvOptions {
i18nLanguages: boolean
language: string
name: string[]
order: string
order: PickleOrder
parallel: number
profile: string[]
publish: boolean
Expand Down Expand Up @@ -216,14 +218,21 @@ const ArgvParser = {
{}
)

program.on('--help', () => {
/* eslint-disable no-console */
console.log(
' For more details please visit https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md\n'
)
/* eslint-enable no-console */
program.on('option:i18n-languages', () => {
console.log(getLanguages())
process.exit()
})

program.on('option:i18n-keywords', function (isoCode: string) {
console.log(getKeywords(isoCode))
process.exit()
})

program.addHelpText(
'afterAll',
'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'
)

program.parse(argv)
const options: IParsedArgvOptions = program.opts()
ArgvParser.validateRetryOptions(options)
Expand Down
Loading