Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@haibun/core

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haibun/core - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

build/lib/getDefaultWorld.d.ts

4

build/lib/contexts.d.ts

@@ -1,2 +0,2 @@

import { WorkspaceBuilder } from './defs';
import { TTag, WorkspaceBuilder } from './defs';
export declare class Context {

@@ -25,3 +25,3 @@ values: {

export declare class WorldContext extends Context {
constructor(tag: string, initial?: {
constructor(tag: TTag, initial?: {
[name: string]: string;

@@ -28,0 +28,0 @@ });

@@ -57,3 +57,3 @@ import { DomainContext, WorkspaceContext, WorldContext } from './contexts';

export declare type TWorld = {
tag: string;
tag: TTag;
shared: WorldContext;

@@ -86,2 +86,9 @@ runtime: TRuntime;

};
export declare type TTag = {
sequence: number;
loop: number;
member: number;
params?: any;
trace?: boolean;
};
export declare type TVStep = {

@@ -118,3 +125,4 @@ source: TFeature;

close?(): void;
nextFeature?(ctx: string): void;
nextFeature?(): void;
onFailure?(result: TStepResult): void;
}

@@ -121,0 +129,0 @@ export interface IStepper extends IExtension {

@@ -1,2 +0,2 @@

import { TStepResult } from '../defs';
import { TStepResult, TTag } from '../defs';
export declare type TLogLevel = 'none' | 'debug' | 'log' | 'info' | 'warn' | 'error';

@@ -13,3 +13,3 @@ export declare const TEST_RESULT: {

topic?: TMessageTopic;
tag?: string;
tag?: TTag;
};

@@ -16,0 +16,0 @@ export declare type TMessageTopic = TExecutorTopic;

@@ -0,1 +1,2 @@

import { TTag } from './defs';
import { ILogger, ILogOutput, TLogLevel, TMessageContext } from './interfaces/logger';

@@ -22,3 +23,3 @@ export declare const LOGGER_LOG: {

output: ILogOutput;
tag: string;
tag: TTag;
};

@@ -34,3 +35,3 @@ declare type TConf = TLevel | TOutputEnv;

static shouldLogLevel(level: number, name: TLogLevel): boolean;
static shouldLogFollow(match: string, tag: string): boolean;
static shouldLogFollow(match: string, tag: TTag): boolean;
out(level: TLogLevel, args: any, messageContext?: TMessageContext): void;

@@ -43,4 +44,3 @@ debug: (args: any, mctx?: TMessageContext | undefined) => void;

}
export declare const loggerTag: (loop: number, member: number, env: any) => string;
export {};
//# sourceMappingURL=Logger.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loggerTag = exports.LOGGER_LEVELS = exports.LOGGER_NONE = exports.LOGGER_LOG = void 0;
exports.LOGGER_LEVELS = exports.LOGGER_NONE = exports.LOGGER_LOG = void 0;
const util_1 = require("./util");
exports.LOGGER_LOG = { level: 'log' };

@@ -42,3 +43,3 @@ exports.LOGGER_NONE = { level: 'none' };

}
const res = new RegExp(match).test(tag);
const res = new RegExp(match).test(`${tag.sequence}`);
return res;

@@ -59,3 +60,3 @@ }

}
const tag = messageContext?.tag ? ` ${messageContext.tag}` : '';
const tag = messageContext?.tag ? util_1.descTag(messageContext.tag) : '';
console[level].call(console, `${ln}${tag}: `.padStart(WIDTH), args, level.padStart(6));

@@ -65,4 +66,2 @@ }

exports.default = Logger;
const loggerTag = (loop, member, env) => `@-l${loop}-m${member}-s${env}`;
exports.loggerTag = loggerTag;
//# sourceMappingURL=Logger.js.map

@@ -24,2 +24,3 @@ "use strict";

const Logger_1 = __importStar(require("./Logger"));
const TestSteps_1 = require("./TestSteps");
describe('log levels', () => {

@@ -37,10 +38,2 @@ test('logs none with none', () => {

});
describe('log follow', () => {
test('logs follow', () => {
expect(Logger_1.default.shouldLogFollow('-m[1-3]', Logger_1.loggerTag(1, 2, {}))).toBe(true);
});
test('log does not follow', () => {
expect(Logger_1.default.shouldLogFollow('-m[1-3]', Logger_1.loggerTag(1, 5, {}))).toBe(false);
});
});
describe('logger with subscriber', () => {

@@ -68,3 +61,3 @@ test('subscriber receives topic', (done) => {

};
const dlogger = new Logger_1.default({ output, tag: 'current' });
const dlogger = new Logger_1.default({ output, tag: TestSteps_1.getDefaultTag(0) });
dlogger.log('test');

@@ -71,0 +64,0 @@ });

@@ -8,2 +8,3 @@ "use strict";

const TestSteps_1 = require("./TestSteps");
const TestSteps_2 = require("./TestSteps");
const features_1 = require("./features");

@@ -81,7 +82,7 @@ describe('namedMatches', () => {

const steppers = [new TestStepper()];
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_1.getDefaultWorld(0);
const resolver = new Resolver_1.Resolver(steppers, '', world);
world.shared.set('exact', 'res');
test('gets var', async () => {
const features = TestSteps_1.asExpandedFeatures([features_1.withNameType('l1', 'is `exact`')]);
const features = TestSteps_2.asExpandedFeatures([features_1.withNameType('l1', 'is `exact`')]);
const res = await resolver.resolveSteps(features);

@@ -88,0 +89,0 @@ const { vsteps } = res[0];

@@ -8,2 +8,3 @@ "use strict";

const util_1 = require("./util");
const TestSteps_2 = require("./TestSteps");
const TTYPE = 'page';

@@ -24,3 +25,3 @@ const CCONTROL = 'control';

test: {
gwta: 'Pull the {what: control}',
gwta: `See the {what: ${CCONTROL}} ${CCONTROL}`,
action: async (named) => {

@@ -43,3 +44,3 @@ return util_1.actionOK();

has: {
gwta: 'Has a {what} control',
gwta: `Has a {what: ${CCONTROL}} control`,
action: async ({ what }, vstep) => {

@@ -55,5 +56,5 @@ const value = 'xxx';

};
describe.only('domain object', () => {
describe('domain object', () => {
it('missing domain object', async () => {
const { result } = await TestSteps_1.testWithDefaults([{ path: '/features/test.feature', content: `\nPull the lever\n` }], [TestStepsWithDomain]);
const { result } = await TestSteps_1.testWithDefaults([{ path: '/features/test.feature', content: `\nHas a foobar control\n` }], [TestStepsRequiresDomain]);
expect(result.ok).toBe(false);

@@ -66,8 +67,7 @@ expect(result.failure.error.message.startsWith(`missing required domain "${TTYPE}"`)).toBe(true);

const key = '/backgrounds/p1';
const { world } = util_1.getDefaultWorld();
const features = TestSteps_1.asFeatures([{ path: '/features/test.feature', content: `Backgrounds: p1.${TTYPE}\n\nOn the /backgrounds/p1 ${TTYPE}\nPull the lever\n` }]);
const { world } = TestSteps_2.getDefaultWorld(0);
const features = TestSteps_1.asFeatures([{ path: '/features/test.feature', content: `Backgrounds: p1.${TTYPE}\n\nOn the /backgrounds/p1 ${TTYPE}\nSee the page control\n` }]);
const backgrounds = TestSteps_1.asFeatures([{ path: `/backgrounds/p1.${TTYPE}.feature`, content: 'Has a lever control' }]);
const { result } = await run_1.runWith({ specl, features, backgrounds, addSteppers: [TestStepsRequiresDomain, TestStepsWithDomain], world });
expect(result.ok).toBe(true);
// expect(result.results![0].stepResults[0].actionResults[0].topics).toEqual('http://localhost:8123/p1');
expect(world.shared.getCurrent(TTYPE)).toEqual(key);

@@ -74,0 +74,0 @@ const page = domain_1.getDomain(TTYPE, world).shared.get(key);

@@ -62,7 +62,13 @@ "use strict";

const executor = new Executor_1.Executor(steppers, world);
const result = await executor.execute(mappedValidatedSteps);
if (!result.ok) {
const message = result.results[0].stepResults.find(s => !s.ok)?.actionResults[0].message;
result.failure = { stage: 'Execute', error: { message, details: { errors: result.results?.filter((r) => !r.ok).map((r) => r.path) } } };
let result;
try {
result = await executor.execute(mappedValidatedSteps);
if (!result.ok) {
const message = result.results[0].stepResults.find(s => !s.ok)?.actionResults[0].message;
result.failure = { stage: 'Execute', error: { message, details: { errors: result.results?.filter((r) => !r.ok).map((r) => r.path) } } };
}
}
catch (e) {
result = { ok: false, failure: e };
}
return { result, steppers };

@@ -69,0 +75,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const contexts_1 = require("./contexts");
const run_1 = require("./run");
const TestSteps_1 = require("./TestSteps");
const util_1 = require("./util");
const TestSteps_2 = require("./TestSteps");
describe('run self-contained', () => {

@@ -11,3 +11,3 @@ it('Backgrounds', async () => {

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(true);

@@ -26,3 +26,3 @@ expect(result.results.length).toBe(1);

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(true);

@@ -41,3 +41,3 @@ expect(result.results.length).toBe(1);

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(false);

@@ -52,3 +52,3 @@ expect(result.failure?.stage).toBe('Resolve');

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(false);

@@ -62,3 +62,3 @@ expect(result.failure?.stage).toBe('Execute');

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(false);

@@ -73,3 +73,3 @@ expect(result.results?.length).toBe(2);

const specl = util_1.getOptionsOrDefault(base);
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_2.getDefaultWorld(0);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], world });

@@ -84,5 +84,4 @@ expect(result.ok).toBe(true);

it('handles exception', async () => {
const base = process.cwd() + '/test/projects/specl/handles-exception';
const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const feature = { path: '/features/test.feature', content: `When I throw an exception\nThen the test should pass` };
const { result } = await TestSteps_1.testWithDefaults([feature], [TestSteps_1.TestSteps]);
expect(result.ok).toBe(false);

@@ -96,3 +95,3 @@ expect(result.results?.length).toBe(1);

const specl = util_1.getOptionsOrDefault(base);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...util_1.getDefaultWorld() });
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], ...TestSteps_2.getDefaultWorld(0) });
expect(result.ok).toBe(true);

@@ -105,3 +104,3 @@ expect(result.results?.length).toBe(1);

const base = process.cwd() + '/test/projects/haibun/stepper-options';
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_2.getDefaultWorld(0);
const specl = util_1.getOptionsOrDefault(base);

@@ -117,10 +116,8 @@ const { protoOptions: protoConfig } = util_1.processEnv({ [TestSteps_1.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS]: 'true' }, {});

it('builds with finalizer', async () => {
const base = process.cwd() + '/test/projects/haibun/build';
const specl = util_1.getOptionsOrDefault(base);
const shared = new contexts_1.WorldContext(`build test`);
const { result } = await run_1.run({ specl, base, addSteppers: [TestSteps_1.TestSteps], world: { ...util_1.getDefaultWorld().world, shared } });
const feature = { path: '/features/test.feature', content: `builds with finalizer` };
const { result, world } = await TestSteps_1.testWithDefaults([feature], [TestSteps_1.TestSteps]);
expect(result.ok).toBe(true);
expect(shared.get('done')).toEqual('ok');
expect(world.shared.get('done')).toEqual('ok');
});
});
//# sourceMappingURL=run.test.js.map

@@ -36,2 +36,12 @@ import { IStepper, IExtensionConstructor, TWorld, TVStep, TProtoOptions, TOptions } from './defs';

}[]) => any[];
export declare function getDefaultWorld(sequence: number): {
world: TWorld;
};
export declare function getDefaultTag(sequence: number, desc?: string | undefined): {
sequence: number;
loop: number;
member: number;
params: any;
trace: boolean;
};
//# sourceMappingURL=TestSteps.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.asExpandedFeatures = exports.asFeatures = exports.testRun = exports.testWithDefaults = exports.getTestEnv = exports.TestStepsWithOptions = exports.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS = exports.TestStepsWithDomain = exports.TestSteps = void 0;
exports.getDefaultTag = exports.getDefaultWorld = exports.asExpandedFeatures = exports.asFeatures = exports.testRun = exports.testWithDefaults = exports.getTestEnv = exports.TestStepsWithOptions = exports.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS = exports.TestStepsWithDomain = exports.TestSteps = void 0;
const Resolver_1 = require("../phases/Resolver");
const run_1 = require("./run");
const util_1 = require("./util");
const contexts_1 = require("./contexts");
const features_1 = require("./features");
const domain_1 = require("./domain");
const Logger_1 = __importStar(require("./Logger"));
const TestSteps = class TestSteps {

@@ -105,3 +126,3 @@ constructor(world) {

const specl = util_1.getOptionsOrDefault();
const { world } = util_1.getDefaultWorld();
const { world } = getDefaultWorld(0);
if (options) {

@@ -132,2 +153,19 @@ world.options = options;

exports.asExpandedFeatures = asExpandedFeatures;
function getDefaultWorld(sequence) {
return {
world: {
tag: { sequence: 0, loop: 0, member: 0 },
shared: new contexts_1.WorldContext(getDefaultTag(sequence)),
logger: new Logger_1.default(process.env.HAIBUN_LOG_LEVEL ? { level: process.env.HAIBUN_LOG_LEVEL } : Logger_1.LOGGER_NONE),
runtime: {},
options: {},
domains: [],
},
};
}
exports.getDefaultWorld = getDefaultWorld;
function getDefaultTag(sequence, desc = undefined) {
return util_1.getRunTag(sequence, 0, 0, desc ? { desc } : undefined, false);
}
exports.getDefaultTag = getDefaultTag;
//# sourceMappingURL=TestSteps.js.map
import { WorldContext } from './contexts';
import { IStepper, IExtensionConstructor, IHasOptions, TFeature, TNotOKActionResult, TOKActionResult, TOptionValue, TResult, TSpecl, TWorld, TOptions, TProtoOptions, TRuntime, TActionResultTopics, TActionResult, TFound } from './defs';
import { IStepper, IExtensionConstructor, IHasOptions, TFeature, TNotOKActionResult, TOKActionResult, TOptionValue, TResult, TSpecl, TWorld, TOptions, TProtoOptions, TRuntime, TActionResultTopics, TActionResult, TFound, TTag } from './defs';
export declare function use(module: string): Promise<any>;

@@ -28,5 +28,2 @@ export declare function resultOutput(type: string | undefined, result: TResult, shared: WorldContext): Promise<any>;

export declare const sleep: (ms: number) => Promise<unknown>;
export declare function getDefaultWorld(): {
world: TWorld;
};
declare type TEnv = {

@@ -47,3 +44,13 @@ [name: string]: string | undefined;

export declare function applyResShouldContinue(world: any, res: Partial<TActionResult>, vstep: TFound): boolean;
export declare function getCaptureDir(tag: TTag, app: string, fn?: string): string;
export declare const getRunTag: (sequence: number, loop: number, member: number, params: any, trace: boolean) => {
sequence: number;
loop: number;
member: number;
params: any;
trace: boolean;
};
export declare const getIntOrError: (val: any) => number;
export declare const descTag: (tag: TTag) => string;
export {};
//# sourceMappingURL=util.d.ts.map

@@ -25,9 +25,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.applyResShouldContinue = exports.getFromRuntime = exports.getStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.applyExtraOptions = exports.applyEnvCollections = exports.processEnv = exports.getDefaultWorld = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0;
exports.descTag = exports.getIntOrError = exports.getRunTag = exports.getCaptureDir = exports.applyResShouldContinue = exports.getFromRuntime = exports.getStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.applyExtraOptions = exports.applyEnvCollections = exports.processEnv = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0;
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
const contexts_1 = require("./contexts");
const defs_1 = require("./defs");
const features_1 = require("./features");
const Logger_1 = __importStar(require("./Logger"));
// FIXME tired of wrestling with ts/import issues

@@ -115,3 +113,3 @@ async function use(module) {

}
else if ((!type || file.endsWith(`.${type}`)) && (!filter || file.match(filter))) {
else if ((!type || file.endsWith(`.${type}`)) && !!(!filter || here.match(filter))) {
all.push(features_1.withNameType(here, fs_1.readFileSync(here, 'utf-8')));

@@ -172,15 +170,2 @@ }

exports.sleep = sleep;
function getDefaultWorld() {
return {
world: {
tag: '_default',
shared: new contexts_1.WorldContext('default'),
logger: new Logger_1.default(process.env.HAIBUN_LOG_LEVEL ? { level: process.env.HAIBUN_LOG_LEVEL } : Logger_1.LOGGER_NONE),
runtime: {},
options: {},
domains: [],
},
};
}
exports.getDefaultWorld = getDefaultWorld;
function processEnv(env, options) {

@@ -211,2 +196,5 @@ const protoOptions = { options: { ...options, env: {} }, extraOptions: {} };

}
else if (opt === 'TRACE') {
protoOptions.options.trace = true;
}
else if (opt === 'CLI') {

@@ -334,2 +322,29 @@ protoOptions.options.cli = true;

exports.applyResShouldContinue = applyResShouldContinue;
function getCaptureDir(tag, app, fn) {
const dir = [process.cwd(), 'capture', tag.sequence, app].join('/');
if (!fs_1.existsSync(dir)) {
try {
fs_1.mkdirSync(dir, { recursive: true });
}
catch (e) {
throw Error(`creating ${dir}: ${e}`);
}
}
if (fn) {
return `${dir}/${fn}`;
}
return dir;
}
exports.getCaptureDir = getCaptureDir;
const getRunTag = (sequence, loop, member, params, trace) => ({ sequence, loop, member, params, trace });
exports.getRunTag = getRunTag;
const getIntOrError = (val) => {
if (val.match(/[^\d+]/)) {
throw Error(`${val} is not an integer`);
}
return parseInt(val, 10);
};
exports.getIntOrError = getIntOrError;
const descTag = (tag) => ` @${tag.sequence} (${tag.loop}x${tag.member})`;
exports.descTag = descTag;
//# sourceMappingURL=util.js.map

@@ -24,7 +24,7 @@ "use strict";

const TestSteps_1 = require("./TestSteps");
const util_1 = require("./util");
const TestSteps_2 = require("./TestSteps");
const features_1 = require("./features");
describe('output', () => {
it('resultOutput default', async () => {
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_2.getDefaultWorld(0);
const { result } = await TestSteps_1.testRun('/test/projects/specl/out-default', [TestSteps_1.TestSteps], world);

@@ -71,3 +71,3 @@ expect(result.ok).toBe(false);

it('finds stepper options', async () => {
const steppers = await util.getSteppers({ steppers: [], addSteppers: [TestSteps_1.TestStepsWithOptions], ...util_1.getDefaultWorld() });
const steppers = await util.getSteppers({ steppers: [], addSteppers: [TestSteps_1.TestStepsWithOptions], ...TestSteps_2.getDefaultWorld(0) });
const conc = util.getStepperOptions(TestSteps_1.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS, 'true', steppers);

@@ -77,5 +77,5 @@ expect(conc).toBeDefined();

it('fills extra', async () => {
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_2.getDefaultWorld(0);
const specl = { ...util.getDefaultOptions(), extraOptions: { [TestSteps_1.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS]: 'true' } };
const steppers = await util.getSteppers({ steppers: [], addSteppers: [TestSteps_1.TestStepsWithOptions], ...util_1.getDefaultWorld() });
const steppers = await util.getSteppers({ steppers: [], addSteppers: [TestSteps_1.TestStepsWithOptions], ...TestSteps_2.getDefaultWorld(0) });
util.applyExtraOptions(specl, steppers, world);

@@ -85,3 +85,3 @@ expect(world.options[TestSteps_1.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS]).toBe(42);

it('throws for unfilled extra', async () => {
const { world } = util_1.getDefaultWorld();
const { world } = TestSteps_2.getDefaultWorld(0);
const specl = { ...util.getDefaultOptions(), extraOptions: { HAIBUN_NE: 'true' } };

@@ -88,0 +88,0 @@ expect(() => util.applyExtraOptions(specl, [], world)).toThrow();

@@ -8,3 +8,3 @@ "use strict";

const defs_1 = require("../lib/defs");
const util_1 = require("../lib/util");
const TestSteps_1 = require("../lib/TestSteps");
const Builder_1 = __importDefault(require("./Builder"));

@@ -36,3 +36,3 @@ const feature = (result) => ({

};
const builder = new Builder_1.default(util_1.getDefaultWorld().world);
const builder = new Builder_1.default(TestSteps_1.getDefaultWorld(0).world);
// expect(async () => await builder.build([feature(throws)])).rejects.toThrow('fails');

@@ -42,3 +42,3 @@ });

const throws = async () => defs_1.OK;
const builder = new Builder_1.default(util_1.getDefaultWorld().world);
const builder = new Builder_1.default(TestSteps_1.getDefaultWorld(0).world);
// const res = await builder.build([feature(throws)]);

@@ -51,3 +51,3 @@ // expect(res).toBe(OK);

const workspace = new contexts_1.WorkspaceContext(`test builder finalizes`);
const builder = new Builder_1.default(util_1.getDefaultWorld().world, workspace);
const builder = new Builder_1.default(TestSteps_1.getDefaultWorld(0).world, workspace);
// await builder.build([feature(finalizes)]);

@@ -54,0 +54,0 @@ // expect(workspace['passes.feature'].done).toBe(true);

@@ -9,5 +9,6 @@ import { IStepper, TVStep, TResolvedFeature, TResult, TStepResult, TFeatureResult, TWorld } from '../lib/defs';

static doFeatureStep(vstep: TVStep, world: TWorld): Promise<TStepResult>;
nextFeature(tag: string): Promise<void>;
onFailure(result: TStepResult): Promise<void>;
nextFeature(): Promise<void>;
close(): Promise<void>;
}
//# sourceMappingURL=Executor.d.ts.map

@@ -22,3 +22,3 @@ "use strict";

featureResults.push(featureResult);
await this.nextFeature(this.world.tag);
await this.nextFeature();
}

@@ -39,2 +39,5 @@ await this.close();

ok = ok && result.ok;
if (!result.ok) {
await this.onFailure(result);
}
const topics = result.actionResults.reduce((all, a) => ({ ...all, ...a.topics }), {});

@@ -74,7 +77,15 @@ this.world.logger.log(ok, { topic: { stage: 'Executor', seq, result } });

}
async nextFeature(tag) {
async onFailure(result) {
for (const s of this.steppers) {
if (s.onFailure) {
this.world.logger.debug(`onFailure ${s.constructor.name}`);
await s.onFailure(result);
}
}
}
async nextFeature() {
for (const s of this.steppers) {
if (s.nextFeature) {
this.world.logger.info(`closing ${s.constructor.name}`);
await s.nextFeature(tag);
this.world.logger.debug(`nextFeature ${s.constructor.name}`);
await s.nextFeature();
}

@@ -86,3 +97,3 @@ }

if (s.close) {
this.world.logger.info(`closing ${s.constructor.name}`);
this.world.logger.debug(`closing ${s.constructor.name}`);
await s.close();

@@ -89,0 +100,0 @@ }

@@ -5,3 +5,3 @@ "use strict";

const TestSteps_1 = require("../lib/TestSteps");
const util_1 = require("../lib/util");
const TestSteps_2 = require("../lib/TestSteps");
const Resolver_1 = require("./Resolver");

@@ -33,3 +33,3 @@ describe('validate map steps', () => {

const getResolver = () => new Resolver_1.Resolver(steppers, '', {
...util_1.getDefaultWorld().world,
...TestSteps_2.getDefaultWorld(0).world,
});

@@ -36,0 +36,0 @@ describe('exact', () => {

@@ -5,6 +5,6 @@ "use strict";

const TestSteps_1 = require("../lib/TestSteps");
const util_1 = require("../lib/util");
const TestSteps_2 = require("../lib/TestSteps");
describe('haibun', () => {
it('finds prose', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['haibun'], 'A sentence.', util_1.getDefaultWorld().world);
const { world, vstep } = await TestSteps_1.getTestEnv(['haibun'], 'A sentence.', TestSteps_2.getDefaultWorld(0).world);
const res = await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -11,0 +11,0 @@ expect(res.ok).toBe(true);

@@ -5,3 +5,3 @@ "use strict";

const TestSteps_1 = require("../lib/TestSteps");
const util_1 = require("../lib/util");
const TestSteps_2 = require("../lib/TestSteps");
const vars_1 = require("./vars");

@@ -11,3 +11,3 @@ const contexts_1 = require("../lib/contexts");

it('assigns', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], 'set x to y', util_1.getDefaultWorld().world);
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], 'set x to y', TestSteps_2.getDefaultWorld(0).world);
await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -17,3 +17,3 @@ expect(world.shared.get('x')).toBe('y');

it('assigns empty', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], 'set empty "x" to y', util_1.getDefaultWorld().world);
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], 'set empty "x" to y', TestSteps_2.getDefaultWorld(0).world);
await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -24,4 +24,4 @@ expect(world.shared.get('x')).toBe('y');

const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], 'set empty "x" to newValue', {
...util_1.getDefaultWorld().world,
shared: new contexts_1.WorldContext('test vars empty does not overwrite', { x: 'notY' }),
...TestSteps_2.getDefaultWorld(0).world,
shared: new contexts_1.WorldContext(TestSteps_1.getDefaultTag(0, 'test vars empty does not overwrite'), { x: 'notY' }),
});

@@ -33,3 +33,3 @@ const res = await Executor_1.Executor.doFeatureStep(vstep, world);

it('is not set', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set', { ...util_1.getDefaultWorld().world });
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set', { ...TestSteps_2.getDefaultWorld(0).world });
const res = await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -39,3 +39,3 @@ expect(res.ok).toBe(false);

it('is set', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set', { ...util_1.getDefaultWorld().world, shared: new contexts_1.WorldContext('is set', { 'x 1': '1' }) });
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set', { ...TestSteps_2.getDefaultWorld(0).world, shared: new contexts_1.WorldContext(TestSteps_1.getDefaultTag(0, 'is set'), { 'x 1': '1' }) });
const res = await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -45,3 +45,3 @@ expect(res.ok).toBe(true);

it('is set with or', async () => {
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set or do something', { ...util_1.getDefaultWorld().world });
const { world, vstep } = await TestSteps_1.getTestEnv(['vars'], '"x 1" is set or do something', { ...TestSteps_2.getDefaultWorld(0).world });
const res = await Executor_1.Executor.doFeatureStep(vstep, world);

@@ -48,0 +48,0 @@ expect(res.ok).toBe(false);

{
"name": "@haibun/core",
"version": "1.0.6",
"version": "1.0.7",
"description": "",

@@ -5,0 +5,0 @@ "author": "",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc