Skip to content

add test harness for "run translated C" tests #4053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 5, 2020
Merged

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Jan 3, 2020

Adds a new kind of test that actually runs translated C code. This tests not only that translation succeeded, but that it produced viable, correct code.

Improvements that could be made, but not necessary to merge:

  • add a translate-c step into the std lib build.zig API
  • properly take advantage of the caching system
  • generalize the "run and compare output" step

@andrewrk andrewrk force-pushed the test-run-translated-c branch from 819ca3b to 695c8f7 Compare January 3, 2020 05:26
this will be used to provide a zig build step
 * `RunStep` moved to lib/std/build/run.zig and gains ability to compare
   output and exit code against expected values. Multiple redundant
   locations in the test harness code are replaced to use `RunStep`.
 * `WriteFileStep` moved to lib/std/build/write_file.zig and gains
   ability to write more than one file into the cache directory, for
   when the files need to be relative to each other. This makes
   usage of `WriteFileStep` no longer problematic when parallelizing
   zig build.
 * Added `CheckFileStep`, which can be used to validate that the output
   of another step produced a valid file. Multiple redundant locations
   in the test harness code are replaced to use `CheckFileStep`.
 * Added `TranslateCStep`. This exposes `zig translate-c` to the build
   system, which is likely to be rarely useful by most Zig users;
   however Zig's own test suite uses it both for translate-c tests and
   for run-translated-c tests.
 * Refactored ad-hoc code to handle source files coming from multiple
   kinds of sources, into `std.build.FileSource`.
 * Added `std.build.Builder.addExecutableFromWriteFileStep`.
 * Added `std.build.Builder.addExecutableSource`.
 * Added `std.build.Builder.addWriteFiles`.
 * Added `std.build.Builder.addTranslateC`.
 * Added `std.build.LibExeObjStep.addCSourceFileSource`.
 * Added `std.build.LibExeObjStep.addAssemblyFileFromWriteFileStep`.
 * Added `std.build.LibExeObjStep.addAssemblyFileSource`.
 * Exposed `std.fs.base64_encoder`.
@andrewrk
Copy link
Member Author

andrewrk commented Jan 5, 2020

I went ahead and put some legwork into making a bunch of the zig test suite ready to be parallelized. Only a few things remaining until that could be enabled

@daurnimator daurnimator added the translate-c C to Zig source translation feature (@cImport) label Jan 5, 2020
@andrewrk andrewrk merged commit a0ca349 into master Jan 5, 2020
@andrewrk andrewrk deleted the test-run-translated-c branch January 5, 2020 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
translate-c C to Zig source translation feature (@cImport)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants