[tink_unittest] Skip injecting AssertionBuffer because there is already an argument named "asserts"?

On one of my project, when I build the tests based on tink_unittest, I get the following warning (about 20 times):

Skip injecting AssertionBuffer because there is already an argument named "asserts"

The tests run fine, so it’s not blocking, just annoying to see a long list of warnings.
From what I’ve read, it probably occurs when the tink.SyntaxHub.use() macro is used several times (i.e. there is duplicate entries in my test.hxml file).

But my test.hxml file is quite simple and contains no duplicate entries:

--class-path src
--class-path test
--dce full
--define analyzer-optimize
--define real-position
--library tink_core:1.27.1
--library tink_spatial:git:
--library tink_sql:git:
--library tink_template:0.4.2
--library tink_unittest:0.7.0
--library tink_web:0.2.1
--macro tink.Template.addFlavor('html', '{{', '}}')
--main TestAll
--php .
--resource src/server/config.g.json@config.server.json
--cmd php test/index.php

I’ve checked the .haxelib folder: there is only one occurrence of the tink.SyntaxHub.use() macro (in the tink_syntaxhub package, v0.4.3). So I don’t understand why I have all these warnings.

My question: how can I determine (and fix) the source of these warnings?

Are you using the compilation server?

No. If I use the compilation server, the warnings appear on the first run, but not on subsequent ones.

You can also try to update your tink libraries to latest git version. Those on haxelib are quite old

Thanks @kevinresol, it worked… but the resolution was quite painful.
(Note: I’m using a bare install of Haxe on Windows, with Visual Studio Code as editor and PowerShell as command line, and my compilation target is currently PHP 8.0)

I started by replacing all libraries with the latest Git versions using haxelib: it did not work (i.e. tests OK but still the same warnings).

# Update the libraries
haxelib git tink_core
haxelib git tink_web

# Use the latest versions
--library tink_core:git:
--library tink_web:git:

So, I decided to give a try to lix package manager:

  • removed Haxe/Neko from my system path
  • removed the local .haxelib folder
  • installed lix
  • installed the dependencies with lix install gh:haxetink/<libname>
  • updated the Visual Studio Code settings because it tried to use haxe.exe instead of the haxe.cmd file generated by npm
  • ran the tests

I got an issue with the ansi dependency (used by the test reporter):

PHP Fatal error:  Uncaught Error: Call to undefined method Attribute::Off() in C:\projects\my_app\lib\ANSI.php:598
Stack trace:
#0 C:\projects\my_app\lib\ANSI.php(770): ANSI::__hx__init()

The Attribute::Off() method exists: I suppose I have this issue because I’m on PHP 8.0 and I use the composer autoloader in a custom index.php file instead of the one generated by the Haxe compiler. But that has never been a problem so far!

To fix this issue, I had to:

  • modify the ANSI::__hx__init() method
  • modify the BasicReporter::init() method (from the tink_testrunner package): removed the ANSICON hack.

And finally, everything was fine! Of course, I must apply the ansi fix everytime I run a new compilation… :sob:

(I finally prefer to have a simple setup that works with a lot of warnings rather than the actual end result)

Sounds like you’re missing the lix vscode extension?

Exactly :smile:

Confirmed: it’s an issue with PHP 8.0. In PHP 8, Attribute is a reserved class name due to the introduction of attributes.

// PHP 7:
var_dump(class_exists("Attribute")); // bool(false)

// PHP 8:
var_dump(class_exists("Attribute")); // bool(true)

So, currently tink_unittest is not compatible with PHP 8 due to the transitive ANSI dependency:

A very ugly fix is to add this line in your PHP entry script, before registering the autoloader:

file_put_contents("path/to/ANSI.php", '<?php class ANSI { static $available = false; }');

Perhaps it can be bandaid-fixed by @:native via addMetadata

This is what I saw in your fix (Patch ANSI for php8 compatibility (closes #21) · haxetink/tink_testrunner@45f7042 · GitHub). I still have a lot to learn about Haxe (…and Coconut/Tinkerbell :wink:).

1 Like