Skip to content

Commit

Permalink
fix semicolon with multiple binops 2 (#198)
Browse files Browse the repository at this point in the history
* fixed binop semicolon handling

* updated CHANGELOG

* moved tests and coverage to utest and instrument

re-enabled Haxe nightly

* added utest to Haxe 3.4.7 build

* no coverage runs for 4.0.5

* skip checkstyle tests for nightly
  • Loading branch information
AlexHaxe authored Sep 19, 2020
1 parent 0a43102 commit e69af1f
Show file tree
Hide file tree
Showing 24 changed files with 306 additions and 282 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/tokentree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
haxe-version: ['3.4.7', '4.0.5', '4.1.4']
# haxe-version: ['3.4.7', '4.0.5', '4.1.4', 'nightly']
haxe-version: ['3.4.7', '4.0.5', '4.1.4', 'nightly']
steps:
- uses: actions/checkout@v1
- name: Use Node.js 10
Expand Down Expand Up @@ -58,16 +57,21 @@ jobs:
- name: Setup tokentree dev for checkstyle
run: |
(cd checkstyle/haxe_libraries; echo "-cp ../src" > tokentree.hxml)
- name: Run Neko tests
- name: Run Neko tests (without coverage)
if: matrix.haxe-version == '3.4.7'
run: npx haxe test.hxml -D codecov_json
- name: Run eval tests
if: matrix.haxe-version != '3.4.7'
run: npx haxe test.hxml -D codecov_json
run: npx haxe test3.hxml
- name: Run eval tests (without coverage)
if: matrix.haxe-version == '4.0.5'
run: npx haxe test3.hxml
- name: Run eval tests (with coverage)
if: (matrix.haxe-version != '3.4.7' && matrix.haxe-version != '4.0.5')
run: npx haxe test.hxml
- name: Build and test checkstyle
if: matrix.haxe-version != 'nightly'
run: (cd checkstyle && npx haxe buildAll.hxml && rm -f coverage.json)
- name: Run Node version with --check
if: matrix.haxe-version != 'nightly'
run: npx neko checkstyle/run.n -s src -s test
- name: Upload results to codecov
if: success() && (matrix.haxe-version == '4.1.4' || matrix.haxe-version == '3.4.7')
if: success() && (matrix.haxe-version == '4.1.4')
run: bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
- npm install
- if [[ "$HAXE_VERSION" == "haxe347" ]]; then mv haxe_libraries haxe4_libraries; mv haxe3_libraries haxe_libraries; fi
- if [[ "$HAXE_VERSION" == "haxe347" ]]; then npx lix download haxe 3.4.7; npx lix use haxe 3.4.7; fi
- if [[ "$HAXE_VERSION" == "haxe4" ]]; then npx lix download haxe 4.1.2; npx lix use haxe 4.1.2; fi
- if [[ "$HAXE_VERSION" == "haxe4" ]]; then npx lix download haxe 4.1.4; npx lix use haxe 4.1.4; fi
- if [[ "$HAXE_VERSION" == "nightly" ]]; then npx lix download haxe nightly; npx lix use haxe nightly; fi
- npx lix download
- npx haxe -version
Expand All @@ -24,13 +24,14 @@ install:
- (cd checkstyle; npm install)
- if [[ "$HAXE_VERSION" == "haxe347" ]]; then (cd checkstyle && mv haxe_libraries haxe4_libraries && mv haxe3_libraries haxe_libraries;); fi
- if [[ "$HAXE_VERSION" == "haxe347" ]]; then (cd checkstyle && npx lix download haxe 3.4.7 && npx lix use haxe 3.4.7); fi
- if [[ "$HAXE_VERSION" == "haxe4" ]]; then (cd checkstyle && npx lix download haxe 4.1.2 && npx lix use haxe 4.1.2); fi
- if [[ "$HAXE_VERSION" == "haxe4" ]]; then (cd checkstyle && npx lix download haxe 4.1.4 && npx lix use haxe 4.1.4); fi
- if [[ "$HAXE_VERSION" == "nightly" ]]; then (cd checkstyle && npx lix download haxe nightly && npx lix use haxe nightly); fi
- (cd checkstyle; npx lix download)
- (cd checkstyle/haxe_libraries; echo "-cp ../src" > tokentree.hxml)

script:
- npx haxe test.hxml -D codecov_json
- if [[ "$HAXE_VERSION" == "haxe347" ]]; then (npx haxe test3.hxml); fi
- if [[ "$HAXE_VERSION" != "haxe347" ]]; then (npx haxe test.hxml); fi
- (cd checkstyle && npx haxe buildAll.hxml && rm -f coverage.json)
- neko checkstyle/run.n -s src -s test

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Fixed negative const / Binop(OpSub) detection ([#189](https://github.com/HaxeCheckstyle/tokentree/issues/189))
- Fixed final with multiple vars ([#191](https://github.com/HaxeCheckstyle/tokentree/issues/191))
- Fixed is operator ([#194](https://github.com/HaxeCheckstyle/tokentree/issues/194))
- Fixed semicolon with multiple binops ([#197](https://github.com/HaxeCheckstyle/tokentree/issues/197))
- Fixed semicolon with multiple binops ([#197](https://github.com/HaxeCheckstyle/tokentree/issues/197) + [#198](https://github.com/HaxeCheckstyle/tokentree/issues/198))
- Refactored enums to use CamelCase ([#191](https://github.com/HaxeCheckstyle/tokentree/issues/191))
- Refactored to reduce usage of Type.enumEq ([#195](https://github.com/HaxeCheckstyle/tokentree/issues/195) + [#196](https://github.com/HaxeCheckstyle/tokentree/issues/196))
- Removed `is` operator ([#195](https://github.com/HaxeCheckstyle/tokentree/issues/195))
Expand Down
1 change: 1 addition & 0 deletions buildToken.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-lib hxparse
-lib haxeparser
-lib safety
-lib utest

-debug

Expand Down
5 changes: 5 additions & 0 deletions haxe3_libraries/utest.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @install: lix --silent download "haxelib:/utest#1.13.1" into utest/1.13.1/haxelib
-cp ${HAXE_LIBCACHE}/utest/1.13.1/haxelib/src
-D utest=1.13.1
--macro utest.utils.Macro.checkHaxe()
--macro utest.utils.Macro.importEnvSettings()
4 changes: 4 additions & 0 deletions haxe_libraries/instrument.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @install: lix --silent download "haxelib:/instrument#1.1.0" into instrument/1.1.0/haxelib
-lib safety
-cp ${HAXE_LIBCACHE}/instrument/1.1.0/haxelib/src
-D instrument=1.1.0
5 changes: 5 additions & 0 deletions haxe_libraries/utest.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @install: lix --silent download "haxelib:/utest#1.13.1" into utest/1.13.1/haxelib
-cp ${HAXE_LIBCACHE}/utest/1.13.1/haxelib/src
-D utest=1.13.1
--macro utest.utils.Macro.checkHaxe()
--macro utest.utils.Macro.importEnvSettings()
2 changes: 1 addition & 1 deletion src/tokentree/walk/WalkStatement.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WalkStatement {
var semicolon:TokenTree = stream.consumeToken();

var lastChild:Null<TokenTree> = switch (parent.tok) {
case Binop(_): parent.parent.getLastChild();
case Binop(OpAdd) | Binop(OpSub) | Binop(OpBoolAnd) | Binop(OpBoolOr): parent.parent.getLastChild();
default: parent.getLastChild();
}

Expand Down
17 changes: 15 additions & 2 deletions test.hxml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
-cp src
-cp test

-lib haxeparser
-lib mcover
-lib munit
-lib utest
-lib instrument

-D unittest
-x TestMain
--macro mcover.MCover.coverage(['tokentree'], ['src'], [])

-D coverage-console-summary-reporter
#-D coverage-console-file-summary-reporter
-D coverage-console-package-summary-reporter
-D coverage-lcov-reporter
-D coverage-codecov-reporter

--macro instrument.Instrumentation.coverage(['tokentree'], ['src'], [])
# --macro instrument.Instrumentation.profiling(['tokentree'], ['src'], [])
# -D profiler-console-detail-reporter
# -D debug_instrumentation

# --macro nullSafety('tokentree')
69 changes: 29 additions & 40 deletions test/TestMain.hx
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
import haxe.EntryPoint;
import massive.munit.TestRunner;
import mcover.coverage.munit.client.MCoverPrintClient;
#if codecov_json
import mcover.coverage.client.CodecovJsonPrintClient;
#else
import mcover.coverage.client.LcovPrintClient;
#end
import mcover.coverage.MCoverage;
import tokentree.TokenTreeBuilderParsingTest;
import tokentree.TokenTreeBuilderTest;
import tokentree.utils.FieldUtilsTest;
import tokentree.utils.TokenTreeCheckUtilsTest;
import tokentree.verify.VerifyTokenTreeTest;
import tokentree.walk.WalkFileTest;
import tokentree.walk.WalkIfTest;
import tokentree.walk.WalkWhileTest;
import utest.Runner;
import utest.ui.Report;

using StringTools;

class TestMain {
public function new() {
var suites:Array<Class<massive.munit.TestSuite>> = [TestSuite];
static function main():Void {
var tests:Array<ITest> = [
new FieldUtilsTest(),
new TokenTreeCheckUtilsTest(),
new TokenTreeBuilderTest(),
new TokenTreeBuilderParsingTest(),
new VerifyTokenTreeTest(),
new WalkIfTest(),
new WalkWhileTest(),
new WalkFileTest()
];
var runner:Runner = new Runner();

var client:MCoverPrintClient = new MCoverPrintClient();
#if codecov_json
MCoverage.getLogger().addClient(new CodecovJsonPrintClient());
#else
MCoverage.getLogger().addClient(new LcovPrintClient("Formatter Unittests"));
#end
var runner:TestRunner = new TestRunner(client);
runner.completionHandler = completionHandler;
#if (neko || cpp || hl)
EntryPoint.addThread(function() {
while (true) Sys.sleep(1.0);
#if instrument
runner.onComplete.add(_ -> {
instrument.coverage.Coverage.endCoverage();
});
#end
runner.run(suites);
EntryPoint.run();
}

function completionHandler(success:Bool) {
#if eval
if (!success) {
Sys.exit(1);
}
#else
Sys.exit(success ? 0 : 1);
#end
}

static function main() {
new TestMain();
Report.create(runner);
for (test in tests) runner.addCase(test);
runner.run();
}
}

typedef LineCoverageResult = Dynamic;
}
23 changes: 0 additions & 23 deletions test/TestSuite.hx

This file was deleted.

2 changes: 2 additions & 0 deletions test/import.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import utest.Assert;
import utest.ITest;
5 changes: 3 additions & 2 deletions test/tokentree/TokenTreeBuilderParsingTest.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package tokentree;

import haxe.PosInfos;
import massive.munit.Assert;

class TokenTreeBuilderParsingTest {
class TokenTreeBuilderParsingTest implements ITest {
public function new() {}

@Test
public function testIssues() {
assertCodeParses(ISSUE_76);
Expand Down
10 changes: 5 additions & 5 deletions test/tokentree/TokenTreeBuilderTest.hx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package tokentree;

import haxe.PosInfos;
import haxeparser.Data.TokenDef;
import massive.munit.Assert;
import tokentree.TokenTreeBuilder.TokenTreeEntryPoint;
import tokentree.walk.WalkAt;
import tokentree.walk.WalkIf;
import tokentree.walk.WalkPackageImport;
import tokentree.TokenTreeBuilder.TokenTreeEntryPoint;

class TokenTreeBuilderTest {
class TokenTreeBuilderTest implements ITest {
public function new() {}

function assertTokenEquals(testCase:TokenTreeBuilderTests, actual:String, ?pos:PosInfos) {
Assert.areEqual((testCase : String), actual, pos);
Assert.equals((testCase : String), actual, pos);
}

@Test
Expand Down
11 changes: 6 additions & 5 deletions test/tokentree/utils/FieldUtilsTest.hx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package tokentree.utils;

import haxe.PosInfos;
import tokentree.TokenTree.FilterResult;
import tokentree.utils.FieldUtils.TokenFieldType;
import haxe.PosInfos;
import massive.munit.Assert;

class FieldUtilsTest {
class FieldUtilsTest implements ITest {
public function new() {}

@Test
@:nullSafety(Off)
public function testProperties() {
Expand All @@ -18,8 +19,8 @@ class FieldUtilsTest {
default: GoDeeper;
}
});
Assert.areEqual(1, allBr.length);
Assert.areEqual(7 + 1, allBr[0].children.length);
Assert.equals(1, allBr.length);
Assert.equals(7 + 1, allBr[0].children.length);

checkFieldType(Var("_haxelibRepo", Private, true, false, false, false), FieldUtils.getFieldType(allBr[0].children[0], Private));
checkFieldType(Var("_haxelibRepo", Public, true, false, false, false), FieldUtils.getFieldType(allBr[0].children[0], Public));
Expand Down
Loading

0 comments on commit e69af1f

Please sign in to comment.