Skip to content

Commit

Permalink
[HULUROKU-7877] Replace brs package with @rokucommunity/brs version 0…
Browse files Browse the repository at this point in the history
….45.2 (#141)

* Switch brs package to @rokucommunity/brs version 0.45.2

* @rokucommunity/brs is both a dev and peer dependency

* Replace @rokucommunity/brs version with 0.47.2

* Correction to TAP formatting - must trim positive integers

* Fix array comparisons in file-match test

---------

Co-authored-by: Greg Jenkins <[email protected]>
  • Loading branch information
gregomite and Greg Jenkins authored Jan 30, 2025
1 parent 43b8605 commit 1a16845
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 99 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
"yargs": "^13.2.4"
},
"devDependencies": {
"@rokucommunity/brs": "0.47.2",
"@types/glob": "^7.1.3",
"@types/jest": "^26.0.21",
"@types/long": "^4.0.1",
"@types/memory-fs": "^0.3.2",
"@types/xmldoc": "^1.1.5",
"brs": "^0.43.0",
"docsify-cli": "^4.4.2",
"doctoc": "^1.4.0",
"husky": "^4.2.5",
Expand All @@ -73,7 +73,7 @@
"typescript": "^3.9.7"
},
"peerDependencies": {
"brs": "^0.43.0"
"@rokucommunity/brs": "^0.47.2"
},
"lint-staged": {
"./README.md": "doctoc",
Expand Down
11 changes: 7 additions & 4 deletions resources/tap/tap.brs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,32 @@ end sub
' Prints a TAP testing plan in the form of "1..${numberOfTests}"
' @param {integer} numberOfTests - the number of test cases being run
sub __tap_plan(numberOfTests as integer)
print m.getIndent() "1.." numberOfTests
print m.getIndent() "1.." numberOfTests.toStr().trim()
end sub

' Prints a "test case passed" message to the TAP stream
' @param {integer} index - the zero-based index of the test that passed
' @param {string} rawTitle - the unsanitized title of the test that passed
sub __tap_pass(index as integer, rawTitle as string)
print m.getIndent() "ok " index + 1 " - " m.formatTitle(rawTitle)
index += 1
print m.getIndent() "ok " index.toStr().trim() " - " m.formatTitle(rawTitle)
end sub

' Prints a "test case skipped" message to the TAP stream
' @param {integer} index - the zero-based index of the test that was skipped
' @param {string} rawTitle - the unsanitized title of the test that was skipped
sub __tap_skip(index as integer, rawTitle as string)
print m.getIndent() "ok " index + 1 " - " m.formatTitle(rawTitle) " # skip"
index += 1
print m.getIndent() "ok " index.toStr().trim() " - " m.formatTitle(rawTitle) " # skip"
end sub

' Prints a "test case failed" message to the TAP stream
' @param {integer} index - the zero-based index of the test that failed
' @param {string} rawTitle - the unsanitized title of the test that failed
' @param {assocarray} [metadata] - blob of data to be printed in an indented YAML block
sub __tap_fail(index as integer, rawTitle as string, metadata = invalid as object)
print m.getIndent() "not ok " index + 1 " - " m.formatTitle(rawTitle)
index += 1
print m.getIndent() "not ok " index.toStr().trim() " - " m.formatTitle(rawTitle)
if metadata <> invalid then
m.printExtras(metadata)
end if
Expand Down
2 changes: 1 addition & 1 deletion src/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext } from "istanbul-lib-report";
import { create as createReport, ReportOptions } from "istanbul-reports";
import { createCoverageMap } from "istanbul-lib-coverage";
import { getCoverageResults } from "brs";
import { getCoverageResults } from "@rokucommunity/brs";

/*
* Generates coverage reports using the given list of reporters.
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { types, ExecuteWithScope, createExecuteWithScope } from "brs";
import {
types,
ExecuteWithScope,
createExecuteWithScope,
} from "@rokucommunity/brs";
import fastGlob from "fast-glob";
import * as path from "path";
import * as c from "ansi-colors";
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/JestReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
createFailureMessage,
} from "./utils";
import type { Config } from "@jest/types";
import { BrsError } from "brs/types/Error";
import { BrsError } from "@rokucommunity/brs/types/Error";

function isBrsError(error: Error | BrsError): error is BrsError {
let maybeBrsError = error as BrsError;
Expand Down
2 changes: 1 addition & 1 deletion src/runner/JestRunner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config } from "@jest/types";
import { ExecuteWithScope, types as BrsTypes } from "brs";
import { ExecuteWithScope, types as BrsTypes } from "@rokucommunity/brs";
import { JestReporter } from "../reporter/JestReporter";
import { TestRunner } from "./TestRunner";

Expand Down
2 changes: 1 addition & 1 deletion src/runner/TestRunner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { types as BrsTypes, ExecuteWithScope } from "brs";
import { types as BrsTypes, ExecuteWithScope } from "@rokucommunity/brs";
import { formatInterpreterError } from "../util";

export class TestRunner {
Expand Down
2 changes: 1 addition & 1 deletion test/reporter/jest-reporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PassThrough } from "stream";
import { JestReporter } from "../../src/reporter/JestReporter";
import * as Reporters from "@jest/reporters";
import * as TestResult from "@jest/test-result";
import { BrsError } from "brs/types/Error";
import { BrsError } from "@rokucommunity/brs/types/Error";

jest.mock("@jest/reporters");
let ReportersMock = Reporters as jest.Mocked<typeof Reporters>;
Expand Down
64 changes: 37 additions & 27 deletions test/runner/file-match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ describe("globMatchFiles", () => {

it("Finds all .test.brs files when not given patterns", async () => {
let results = await wrappedGlobMatchFiles([]);
expect(results).toEqual([
"fly-you-fools.test.brs",
"bar/bar-suffix.test.brs",
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
]);
expect(results).toEqual(
expect.arrayContaining([
"fly-you-fools.test.brs",
"bar/bar-suffix.test.brs",
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
])
);
});

it("Partially matches on filename suffix when given a .brs extension", async () => {
let results = await wrappedGlobMatchFiles(["bar.test.brs"]);
expect(results).toEqual([
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
]);
expect(results).toEqual(
expect.arrayContaining([
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
])
);
});

it("Can handle a full path to a file", async () => {
Expand All @@ -44,20 +48,24 @@ describe("globMatchFiles", () => {

it("Can handle asterisks in pattern", async () => {
let results = await wrappedGlobMatchFiles(["bar*.test.brs"]);
expect(results).toEqual([
"bar/bar-suffix.test.brs",
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
]);
expect(results).toEqual(
expect.arrayContaining([
"bar/bar-suffix.test.brs",
"bar/bar.test.brs",
"bar/prefix-bar.test.brs",
])
);
});

it("Looks for both partial directory and file matches when not given a .brs extension", async () => {
let results = await wrappedGlobMatchFiles(["foo"]);
expect(results).toEqual([
"fly-you-fools.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
]);
expect(results).toEqual(
expect.arrayContaining([
"fly-you-fools.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
])
);
});

it("Excludes files when handling directories", async () => {
Expand All @@ -72,10 +80,12 @@ describe("globMatchFiles", () => {

it("Handles multiple patterns", async () => {
let results = await wrappedGlobMatchFiles(["main", "prefix"]);
expect(results).toEqual([
"bar/prefix-bar.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
]);
expect(results).toEqual(
expect.arrayContaining([
"bar/prefix-bar.test.brs",
"foo/main.test.brs",
"foo2/main.test.brs",
])
);
});
});
Loading

0 comments on commit 1a16845

Please sign in to comment.