Skip to content

Commit

Permalink
UTest 2 (#124)
Browse files Browse the repository at this point in the history
* Cleared out haxe_ver conditionals

* enable analyzer

* Require test cases to implement ITest

* Drop support for non-ITest instances

* [ci] setup github-actions with travix

* [nodejs] exit gracefully

* [ci] don't mklink python

* [ci] fix script

* Revert "[nodejs] exit gracefully"

This reverts commit 44faf6e.

* try with travix

* nope

* [ci] disable development Haxe for now

* [ci] don't fail early for now

* [ci][js] disable non-nodejs test

* [ci] how about this?

* [ci] disable faulty steps for now

* [ci] disable more steps

* modernized esception handling

* version change

* got rid of Dynamic

* fixes for Haxe 4.3.1 & 4.3.2

* modernized callback signature syntax

* added test case name filter to `Runner.addCases`

* added defines.json and meta.json

* ci setup for minified js

* moved closure-related code to js-minified-header

* [ci] less verbose

* typo

* removed Misc.isOfType

* ignoring tests with @:ignore meta

* [js] fixes for advansed js minification

* cleanup

* UTEST_IGNORE_DEPENDS

* cleanup

* [ci] throw unhandled exception in minified js instead of exit code 1

* minor

* [js][min] fix Assert.same for strings

* [ci] run PHP tests without travix

* [ci] don't test php with Haxe 4.1

* [ci] enable lua

* removed reference to neko.Web module
because it gets removed in Haxe 5

* [ci] enable hashlink

* [ci] update Haxe 4.3 to 4.3.3

* [ci] enable python

* Revert "[ci] enable python" because it's already enabled

This reverts commit 1009b82.

* [ci] disable hl tests

* [ci] disable lua for Haxe 4.3

* [ci] run lua on ubuntu only

* [ci] try 'latest' haxe

* [ci] fix

* [ci] don't run lua on the latest haxe

* Assert.similar (closes #126)

* leftovers of php.Web and neko.Web

* PosException does not exist in Haxe 4.1

* removed the last reference to neko.Web

* fix Assert.raises for ValueException

* TestAssert refactoring

* uninline some things to overcome lua limitation of 200 local vars

* test for Assert.similar

* changelog

* test Assert.similar
  • Loading branch information
RealyUniqueName authored Nov 30, 2023
1 parent a94f881 commit 424a718
Show file tree
Hide file tree
Showing 55 changed files with 1,119 additions and 1,224 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build

on:
push:
paths-ignore:
- '**/*.md'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
haxe:
- latest
- 4.3.3
- 4.2.5
- 4.1.5

steps:
- name: Show environment variables
shell: bash
run: env | sort

- name: Git Checkout
uses: actions/checkout@v2 #https://github.com/actions/checkout

- name: "Cache Haxelib Repository"
uses: actions/cache@v2
with:
path: $RUNNER_TOOL_CACHE/haxe/${{ matrix.haxe }}/x64/lib
key: ${{ runner.os }}-haxelib-${{ hashFiles('**/haxelib.json') }}
restore-keys: |
${{ runner.os }}-haxelib-
- name: Upgrade brew
if: runner.os == 'macOS'
env:
# https://docs.brew.sh/Manpage#environment
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
echo "::group::brew update" && brew update && echo "::endgroup::"
echo "::group::brew config" && brew config && echo "::endgroup::"
# workaround to prevent "/usr/local/... is not inside a keg" during "brew install mono"
rm /usr/local/bin/2to3
rm /usr/local/share/man/man1/*
rm /usr/local/share/man/man5/*
- name: Set up Python 3
uses: actions/setup-python@v2 # https://github.com/actions/setup-python
with:
python-version: 3.8

- name: Install Haxe ${{ matrix.haxe }}
uses: krdlab/setup-haxe@v1 # https://github.com/krdlab/setup-haxe
with:
haxe-version: ${{ matrix.haxe }}

- name: Install haxe libs
shell: bash
id: prerequisites
run: |
haxelib install travix
haxelib run travix install
##################################################
# Tests
##################################################
- name: Test [interp]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix interp
- name: Test [neko]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix neko
- name: Test [python]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix python
- name: Test [node]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix node
- name: Test [node advanced minification]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: |
haxelib install closure --quiet
haxe hxml/js-minified.hxml --js bin/test.js
node bin/test.js
# - name: Test [js]
# if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
# run: haxelib run travix js
# - name: Test [flash]
# if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
# run: haxelib run travix flash
- name: Test [java]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix java
- name: Test [cpp]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix cpp
- name: Test [cs]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
run: haxelib run travix cs
- name: Test [php]
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' && matrix.haxe != '4.1.5' }}
#disabled php tests for Haxe 4.1 because it's not fully compatible with php 8
run: |
# haxelib run travix php
haxe tests.hxml --php bin/php
php bin/php/index.php
- name: Test [lua]
#see https://github.com/back2dos/travix/pull/146
if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' && matrix.haxe != '4.3.3' && matrix.haxe != 'latest' && matrix.os == 'ubuntu-latest' }}
run: haxelib run travix lua
# - name: Test [hashlink]
# if: ${{ !cancelled() && steps.prerequisites.conclusion == 'success' }}
# run: haxelib run travix hl
33 changes: 0 additions & 33 deletions .sauce-browsers.json

This file was deleted.

33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v2.0.0
- Minimum supported Haxe version is 4.1 now.
- added `Assert.similar()` (see the doc to that method)
- changed various `Assert` methods to be type safe instead of accepting `Dynamic` arguments
- added UTEST_IGNORE_DEPENDS flag to ignore failed or missing dependencies (see README.md)
- added test case name filter to `Runner.addCases`
- support @:ignore meta (old @Ignored meta is still supported too)
- support advanced minification for JS target
- provided defines.json to get UTest compilation flags descriptions with `haxe -lib utest --help-user-defines` (requires Haxe 4.3)
- provided meta.json to get UTest metadata list with `haxe -lib utest --help-user-metas` (requires Haxe 4.3)

# v1.13.2
- Haxe 4.2.0 compatibility
- Diagnostics reporter to show clickable messages in VSCode ([#106](https://github.com/haxe-utest/utest/issues/106)
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@ class TestCase extends utest.Test {
}
```

## Ignore a test

To skip certain test or test case one can annotate them with `@:ignore` meta. The meta accpets an optional string argument to indicate the reason ignoring the test.
```haxe
class TestCase1 extends utest.Test {
@:ignore
function testSomethingNotReadyYet() {
//this test will not be executed
}
}
@:ignore('The functionality under test is not ready yet')
class TestCase2 extends utest.Test {
function testSomething {
//this test will not be executed
}
function testOtherThing {
//this test will not be executed
}
}
```



## Inter-test dependencies

It is possible to define how tests depend on each other with `@:depends` meta:
Expand Down Expand Up @@ -172,6 +197,10 @@ class TestCase2 extends utest.Test {
```
In this example tests from `some.pack.TestCase2` will be executed only if there were no failures in `some.pack.TestCase1`.

## Ignore dependencies

If for some reason you want to run a test regardless the outcome of the tests it depends on, you can use `-D UTEST_IGNORE_DEPENDS` define or set an environment variable with the same name.

## Running single test from a test suite.

Adding `-D UTEST_PATTERN=pattern` to the compilation flags makes UTest to run only tests which have names matching the `pattern`. The pattern could be a plain string or a regular expression without delimiters.
Expand Down
56 changes: 0 additions & 56 deletions appveyor.yml.disabled

This file was deleted.

19 changes: 19 additions & 0 deletions defines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"define": "UTEST_PATTERN",
"doc": "Only run tests which have names matching the `UTEST_PATTERN` value. The pattern could be a plain string or a regular expression without delimiters.",
"params": ["pattern"]
},
{
"define": "UTEST_PRINT_TESTS",
"doc": "Print test names in the process of tests execution."
},
{
"define": "UTEST_FAILURE_THROW",
"doc": "Throw an unhandled exception instead of adding a failure to the report."
},
{
"define": "UTEST_IGNORE_DEPENDS",
"doc": "Ignore @:depends meta and run annotated test regardless the outcome of the tests it depends on."
}
]
1 change: 0 additions & 1 deletion extraParams.hxml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--macro utest.utils.Macro.checkHaxe()
--macro utest.utils.Macro.importEnvSettings()
10 changes: 7 additions & 3 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"license": "MIT",
"tags": ["cross","unittesting"],
"description": "Unit Testing for Haxe",
"version": "1.13.2",
"version": "2.0.0-alpha",
"classPath": "src",
"releasenote": "Haxe 4.2 compatibility; diagnostics reporter to show clickable messages in VSCode; exit code for Adobe AIR application in PlainTextReport; better position reporting on async.done() calls",
"releasenote": "See CHANGELOG.md",
"contributors": ["fponticelli", "romanmikhailov", "RealyUniqueName"],
"dependencies": { }
"dependencies": { },
"documentation": {
"metadata": "meta.json",
"defines": "defines.json"
}
}
2 changes: 0 additions & 2 deletions hxml/appveyor.hxml

This file was deleted.

1 change: 1 addition & 0 deletions hxml/common.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
-main TestAll
-D utest
-dce full
-D analyzer-optimize

extraParams.hxml
10 changes: 10 additions & 0 deletions hxml/js-minified.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
hxml/common.hxml

#Because of this (until the fix is released): https://github.com/HaxeFoundation/haxe/issues/11327
-D js-enums-as-arrays

-lib closure
-D closure_advanced
-D closure_overwrite
-D closure_warning_level=QUIET
--macro includeFile('test/js-minified-header.js')
2 changes: 0 additions & 2 deletions hxml/travis.hxml

This file was deleted.

19 changes: 19 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"metadata": ":timeout",
"doc": "Change timeout (milliseconds) for asynchronous test methods.",
"params": ["ms"],
"targets": ["TClass", "TClassField"]
},
{
"metadata": ":depends",
"doc": "Prevents annotated test (or test case) from being executed if at least one of the tests in the list failed.",
"params": ["test1", "test2", "...", "testN"],
"targets": ["TClass", "TClassField"]
},
{
"metadata": ":ignore",
"doc": "Skip annotated test.",
"targets": ["TClass", "TClassField"]
}
]
Loading

0 comments on commit 424a718

Please sign in to comment.