1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-03 17:01:21 +00:00
Commit graph

82 commits

Author SHA1 Message Date
Matthew Kilgore 1f49cee3d1 Add the ability to compile tests from base folder 2023-04-25 09:48:08 -04:00
Samuel Gomes f72aaa7c3c Update tests 2023-03-19 04:12:46 +05:30
Matthew Kilgore fac5375ea6 Fix DECLARE LIBRARY against stripped .so file
.so files can be stripped such that they contain no "regular" symbol
table but do still contain the "dynamic" symbol table, this is pretty
typical for .so files. QB64-PE is supposed to check both tables when
linking against a .so file, but a bug in ab0c2b18 meant that the second
run of nm with the -D flag to check the dynamic symbol table no longer
happens. The fix is to introduce a new output file for the dynamic run
so that they are handled separately in terms of caching the result.

A new test .so file that only contains a dynamic symbol table was added
to avoid this in the future.

Fixes: #301
2023-02-19 02:10:51 -05:00
Matthew Kilgore df70f7e708 The -o flag should not strip extensions except for .exe
Current the -o flag will strip any "extension" on the provided filename,
which is fairly problimatic on Linux and Mac OS since those executes do
not have other extensions and names like "foobar.v1" will get the ".v1"
stripped off. This can happen on Windows as well if you leave off the
.exe (QB64-PE will add it for you, but also strip off the existing
extension).

QB64-PE stripping off the ".exe" when provided that on Linux and Mac OS
might actually be useful behavior people are relying on (so that they
don't need to provide different names when compiling on Linux/Mac OS) so
we are preserving that and still removing the extension if it is exactly
"EXE", otherwise we now leave it in place.

Fixes: #297
2023-02-18 14:50:31 -05:00
Matthew Kilgore e810229d11 Fix _RGB32() optional arguments
The new optional arguments for functions broke _RGB32() because it uses
some custom flags ('overloaded' and 'minargs' on the id Type) to control
its parameter passing. You are allowed passing any number from 1 to 4 args
to `func__rgb32` and there are 4 overloaded C++ functions that will get
picked from. This is different from how this typically would work, with
all 4 parameters always passed and an extra argument to specify the
parameters that were passed.

Rather than change `func__rgb32` I simply adjusted the optional argument
logic to account for the flags used by `_RGB32()` - if the `overloaded`
flag is set, then we don't need to add extra `NULL` parameters for any
parameter that wasn't specified in the argument list. Instead we simply
don't emit anything for those.
2023-02-13 00:25:51 -05:00
Matthew Kilgore 0836cf31eb Format source, apply Option _Explicit in tests 2023-02-12 22:38:50 -05:00
Matthew Kilgore 83533dc319 Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.

Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.

The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.

Fixes: #303
2023-02-12 22:38:50 -05:00
Matthew Kilgore d4ed371681 Stopped timers don't trigger on TIMER ON
If a timer expires while stopped, it should trigger when TIMER ON is
run. Instead, on QB64 it triggers randomly after the TIMER ON happens.

The basic issue is that `qbevent` needs to be set to trigger the timer,
but TIMER ON doesn't do that. The regular timer logic that does that
already set it when the timer expired while sleeping, so it won't set it
again. The simplest solution is to just alway set qbevent = 1 when TIMER
ON is done. It's slightly less efficent but doesn't hurt to set it even
when there are no timers that expired.

Fixes: #293
2023-02-12 21:27:25 -05:00
Matthew Kilgore f995f38e38 Using Sleep with Console programs does not trigger timers
The command Sleep is supposed to allow timers to trigger while the
program is sleeping on the delay. This is achieved in QB64 by having
commands that do delays manually call evnt() to trigger events if they
come up (of which timers are one).

Sleep has a custom implementation for console programs on Windows which
doesn't do this, so I redid the logic so that it calls evnt() at regular
intervals while waiting for input. Additionally, due to now calling
evnt() we also need to check if we should exit sleep early due to an
evnt() firing.

Fixes: #294
2023-02-12 21:27:25 -05:00
Matthew Kilgore f21ce09e2d Replace time() with std::chrono, fix startup delay
Currently main() includes logic that is intended to sync time() with
GetTicks() for the purpose of using GetTicks() to get millisecond
accuracy with time(), which only has second accuracy. Unfortunately, the
'syncing' up of these time sources results in an average of a half
second delay in starting a QB64-PE program.

This logic is easly replaced with std::chrono, which provides a real
time clock which is also millisecond accurate. That removes the need to
use time() and GetTicks() together to get millisecond accuracy, and
means the delay syncing them is no longer necessary.

I also separated most of the "delay" and "time" related functions into
datetime.cpp, and included the new std::chrono code into that file.

Since I needed to call some of the rounding functions in datetime.cpp I
also moved that stuff out into its own .cpp and header files to clean
things up a bit.

Fixes: #282
2023-01-08 20:24:25 -05:00
Samuel Gomes 845931bf39 Fix all test failures 2023-01-06 18:31:27 +05:30
Samuel Gomes e5b5a86b96 Update test to inlcude invalid parameters for _NEWSND 2023-01-06 12:39:44 +05:30
Samuel Gomes 6c72deafc1 Improve _SNDOPEN test and supress printfs in Hively replayer code 2023-01-01 23:14:05 +05:30
Samuel Gomes 061bf6af3d Rename _NEWSOUND to _SNDNEW to align with _SND* APIs 2022-12-31 12:00:38 +05:30
Samuel Gomes 1179d3c084 Update sndopen_mem_test to not use any file I/O 2022-12-31 07:47:20 +05:30
Samuel Gomes b2723cf057 Fix path for file in test for *nix 2022-12-31 05:40:39 +05:30
Samuel Gomes 31257262a8 Add tests for _NEWSOUND and _SNDOPEN 2022-12-31 04:22:42 +05:30
Matthew Kilgore 3e03cef652 Install Xvfb on Linux build agent
Xvfb is being used to give us an X server implementation on the Linux
build agents. A running X server is necessary for graphics to function
(which we have so far avoided testing).
2022-11-29 20:04:53 -05:00
Matthew Kilgore a79c943d36 Add GLUT initialization tests
These tests cover all the commands that generally interact with GLUT.
The ensure that these functions can be used at the very beginning of a
program with no issues. Additionally they verify the behavior of these
functions in the presence of `$SCREENHIDE`, and also `_ScreenHide`.
2022-11-29 20:04:53 -05:00
Matthew Kilgore 11a5b8be8e _OpenClient() should return zero on connection failure, not error 2022-11-20 18:44:24 -05:00
Matthew Kilgore 445408d95b _StatusCode() should give the correct error on invalid handle type
Passing a handle of the invalid type (Ex. TCP) to _StatusCode should
give error 52, but it gies error 9.
2022-11-20 04:38:03 -05:00
Matthew Kilgore 12c9c35db5 Add _StatusCode command for HTTP handles
The _StatusCode command returns the status code on the HTTP response
when given a HTTP handle from _OpenClient().
2022-11-20 04:04:02 -05:00
Matthew Kilgore 610c914d36 compile_tests.sh does not display compilelog.txt
Due to a typo, compile_tests.sh was not displaying the compilelog.txt
contents on a test failure.
2022-11-19 15:13:26 -05:00
Matthew Kilgore e8ebf56a2f Add basic http tests
These tests cover basic HTTP functionality via _OPENCLIENT(), and also
that it fails to work without `$Unstable:Http` in place.
2022-11-19 15:13:26 -05:00
Matthew Kilgore 45d52271da Add libqb_http API for HTTP connections
This adds the libqb_http API, which is designed to support HTTP and
HTTPS usage from QB64-PE source.

The design consists of a single thread which services all the HTTP(s)
connections. There are then various libqb_http APIs exposed that allow
interacting with this thread to create a new connection, query
connection status, read data, or close the connection.

Internally the thread makes use of the curl_multi interface to allow a
single thread to service multiple HTTP(s) connections in parallel. This
means you can _OPENCLIENT() multiple HTTP connection in a row and all of
them will be serviced at the same time in whatever order data is
available.

HTTP is optional and selected via a Makefile setting. A stub is swapped
in if HTTP support is not used, which avoids need to add another build
flag to libqb.cpp.
2022-11-19 15:13:26 -05:00
Matthew Kilgore d8a3ec75fd Run tests with -O2
Since we do allow users to use optimization, it's worth running our
tests with it to verify at least those work.
2022-11-19 01:55:20 -05:00
Samuel Gomes 0dd825e5f3 Add -static-libgcc -static-libstdc++ to TEST_CFLAGS-$(win) 2022-11-14 12:15:51 +05:30
Matthew Kilgore c5e2be53f9 Swap bmp test images for png
Functionally it doesn't matter what kind of images we store for the
tests, as _LOADIMAGE() will open them exactly the same. png however has
the advantages of being substantially smaller, and also viewable
directly on GitHub in PRs, making them easier to review.
2022-11-09 21:56:44 -05:00
Matthew Kilgore 8005e62402 Add PAINT tile image-based tests 2022-11-08 01:02:22 -05:00
Matthew Kilgore 37f2ecd4ce Fix setup_osx.command script when run from a different directory
I broke this by accident in 5031de2, likely by misreading the $0.  What
the line was intended to do was change to the directory the script is
located in when the script starts, this allows the script to be started
from any location.

Typically this isn't necessary functionality, but for Mac OS it's
important because if you double-click the script (the typical way to run
it) it is started from the user's home directory. Due to this I also
updated the Mac OS distribution test to run the script in this way so
that it's closer to how a user will run it.

Fixes: #218
2022-10-27 23:26:07 -04:00
Samuel Gomes 7e533a2473 Update test license files 2022-10-25 07:28:35 +05:30
Matt Kilgore 1fa5b8af10
Merge branch 'main' into generate-license-file 2022-10-02 16:25:57 -04:00
Matthew Kilgore d876f1bb22 Add license tests
This adds logic for testing the new license generation functionality.
This is done by having the expected license for a variety of
tests that use different dependencies, and then comparing that against
the license QB64-PE actually produces when compiling these test files.

Note that because the actual used dependencies changes depending upon
the OS, we have separate expected licenses for each of Linux, Windows,
and Mac OS. This required some build changes to accomidate, in addition
to the testing logic changes themselves.
2022-10-01 15:08:01 -04:00
Matthew Kilgore b4d6f52909 Add testsuite of built-in Types 2022-10-01 14:18:53 -04:00
Matthew Kilgore 21b7d60f44 Fix -o to be relative to _STARTDIR$ when source file is
In 094a8c82 we added the ability to compile a source file relative to
_STARTDIR$ instead of the location of the qb64pe executable. This change
fixes `-o` so that it is also treated as relative to _STARTDIR$ when the
provided source file is.

Note that this is not a real behavior change because if the provided
source file is relative to the qb64pe executable then `-o` will be as
well, which matches the previous behavior. The cases where it is made
relative to _STARTDIR$ all produced errors until 094a8c82 was done, so
there was no previous defined behavior.
2022-10-01 04:24:54 -04:00
Matthew Kilgore 094a8c82b2 Fix compiling bas files relative to the CWD
Fix was pulled from QB64Official/qb64#17 by Cory Smith, I just added
tests around it.

Most (all?) compilers allow you to run the compiler from a separate
directory than the compiler itself is located in and compile source
files relative to that directory. QB64-PE however does not allow that,
for a variety of reasons it always search for the provided source file
relative to the location of the QB64-PE compiler rather than the CWD it
was run from. This is pretty unexpected behavior in a lot of cases, and
also doesn't give very helpful error messages either.

This change has us check if the source file exists at the given CWD
location, and if it does we will prepend the CWD to produce the correct
path to the file.

To test that this behavior works as expected I modified
`compile_test.sh` to compile from within the test directories using a
relative path directly to the test file, this fails with current QB64-PE
versions because it can't find the source file.

Additionally, I was unsure of whether this would impact the behavior of
`'$include`, so I added some tests around include that uses various
combinations of paths relative to QB64-PE and relative to the source
file being compiled, and they all find the files as expected so I think
it's fine.
2022-09-30 17:13:43 -04:00
Matthew Kilgore a7cd7884a9 Add CONST tests 2022-09-30 11:23:34 -04:00
Matthew Kilgore c93da8db72 Add tests for SOUND and PLAY "MB"
These tests were intended to be added by #171, but the Linux build was
having problems. The issues with the build have since been resolved so
the tests are getting added back in.

Fixes: #173
2022-09-17 03:06:24 -04:00
Matthew Kilgore 870e67a99b Add $CONSOLE:ONLY and libz tests
libz tests were missing, I added one to test the libz dependency.

Additionally $CONSOLE:ONLY creates many weird interactions and is
currently broken in some cases. This adds tests for all the dependencies
that can work with $CONSOLE:ONLY to verify that they compile correctly.
2022-09-17 03:06:24 -04:00
Matthew Kilgore 2deac87b60 Fix Linux build agent audio problems
It's still not entirely clear what the underlying issue is, but the ALSA
device provided by pulseaudio stops working after so many tests use it.
I've tried various approaches, but simply restarting pulseaudio after
every test is a bruteforce but successful solution. In practice it also
doesn't have any noticeable performance penalty, so it seems like a file
solution.

The `CI_TESTING` environment variable is used to avoid restarting
pulseaudio if the tests aren't being run in the CI environment (we don't
want to restart your pulseaudio instance if you're running them locally!)
2022-09-17 02:41:22 -04:00
Matthew Kilgore cebcb11646 Fix compiling source files with single quotes in name
Using single quotes in a file name wasn't working because the Makefile
was using single quotes itself to quote the filename when providing it
to the compiler. The Makefile was switched to use double quotes instead,
which work just as well but are allowed to contain single quotes inside
of them.

Since double quotes are a legal character to have in a file name on
Linux and Mac OS, I added extra logic to start escaping double quote
characters.

I added a test to verify that we can compile source files with single
quotes in the name. I could not add a test for double quotes since such
files cannot exist on Windows and thsu cannot easily be added to the
repository.
2022-09-09 09:59:43 -04:00
Matthew Kilgore dcc181244c Add test of MIDI unsupported with OpenAL 2022-09-04 23:35:14 -04:00
Matthew Kilgore adb52f4f04 Add support for custom flags on QB64 tests 2022-09-04 23:35:14 -04:00
Matthew Kilgore 2b3403745c Add initial MIDI language support
This adds MIDI support to the language as a new unstable feature. There
are two new metacommands that come with this:

$Unstable: Midi
$MidiSoundFont: [Default|"filename"]

The $Unstable command is required to be able to use any of the other
commands, and just signifies that this is not a full part of the
language yet and may change in breaking ways before the API is
finalized.

The $MidiSoundFont command enables MIDI support in the compiled program,
and also specifies what sound font to use to play MIDI files. "Default"
will make use of the soundfont placed at
'./internal/support/default_soundfont.sf2', and otherwise a filename can
be specified to use any soundfont wanted.

In either case, the selected sound font is compiled into the executable
and then loaded at runtime.

Fixes: #115
2022-09-04 23:35:14 -04:00
Matthew Kilgore 65db95c876 Add support for error tests
This adds support for tests of the error output of QB64-PE. The tests
are in the form of a `.bas` file that does not compile, and a `.err`
file containing the expected output of QB64-PE when producing an error
for that file.

Additionally the `compile_tests` now support multiple tests in a single
folder, via using multiple `.bas` files with different names.
2022-09-04 22:43:30 -04:00
Samuel Gomes 4d4692314e Update rotation test to include more cases 2022-09-02 10:15:07 +05:30
Samuel Gomes adf838cd81 Update _ROL & _ROR test and output 2022-09-01 18:09:47 +05:30
Samuel Gomes a7a4d837ea Added test for _ROL & _ROR 2022-09-01 17:28:12 +05:30
Roland Heyder 2ec897b75d Step 10: Update remaining stuff
- checks all remaining occurrences of the term 'qb64', some remain untouched, some are renamed according to context
- also added new logo for README.md
- this step does finalize the 'Phoenix Edition' re-branding
2022-08-12 02:54:12 +02:00
Roland Heyder e68582b6f2 Step 7: Rename qb64.exe to qb64pe.exe
- Includes related LNX/OSX files
- Excludes mentions in the help (*.txt) files
2022-08-11 18:07:57 +02:00