Commit Graph

6452 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
dd9696e294 Remove unnecessary external dependencies.
The main libcretonne crate should not have any external dependencies if
at all possible. Use simple substring matching instead of regular
expressions in the verifier tests to achieve this.

The tools crate no longer depends directly on glob and regex. It still
has an indirect dependency on regex through libfilecheck.
2016-09-16 16:34:50 -07:00
Jakob Stoklund Olesen
d2e5059ab9 Remove unnecessary external dependencies.
The main libcretonne crate should not have any external dependencies if
at all possible. Use simple substring matching instead of regular
expressions in the verifier tests to achieve this.

The tools crate no longer depends directly on glob and regex. It still
has an indirect dependency on regex through libfilecheck.
2016-09-16 16:34:50 -07:00
Jakob Stoklund Olesen
a98d6e5256 Add a 'test verifier' sub-test.
This test runs the verifier on each function and matches the resulting
verifier error against the "error:" annotation.

Move the existing verifier test into filetests/verifier/ and use the new
syntex.
2016-09-16 16:25:36 -07:00
Jakob Stoklund Olesen
b5b1ee23b5 Add a 'test verifier' sub-test.
This test runs the verifier on each function and matches the resulting
verifier error against the "error:" annotation.

Move the existing verifier test into filetests/verifier/ and use the new
syntex.
2016-09-16 16:25:36 -07:00
Jakob Stoklund Olesen
49202bf21b Add a location to verifier error messages.
The verifier reports the 'location' of an error message as a reference
to the entity that has a problem. This uses the 'AnyEntity' type to
refer to instructions/values/ebbs etc.

Also add an err! macro similar to the one used by the parser.
2016-09-16 15:35:37 -07:00
Jakob Stoklund Olesen
c3afc1f2be Add a location to verifier error messages.
The verifier reports the 'location' of an error message as a reference
to the entity that has a problem. This uses the 'AnyEntity' type to
refer to instructions/values/ebbs etc.

Also add an err! macro similar to the one used by the parser.
2016-09-16 15:35:37 -07:00
Jakob Stoklund Olesen
45559a21c1 Remove dead public functions from DominatorTree. 2016-09-16 15:17:19 -07:00
Jakob Stoklund Olesen
52aca982a1 Remove dead public functions from DominatorTree. 2016-09-16 15:17:19 -07:00
Jakob Stoklund Olesen
770285d5c6 Implement a domtree sub-test.
This test verifies the computed dominator tree against annotations.

Move the existing testcases into filetests/ with the new syntax.
2016-09-16 14:50:32 -07:00
Jakob Stoklund Olesen
4198b2dde5 Implement a domtree sub-test.
This test verifies the computed dominator tree against annotations.

Move the existing testcases into filetests/ with the new syntax.
2016-09-16 14:50:32 -07:00
Jakob Stoklund Olesen
ec6a9df08a Make the source map available as filecheck variables.
This makes it possible to refer to entities defined in the source file,
using the source names prefixed with $.

For example, $v20 refers to the value by that name in the sources, even
if it was renumbered to 'vx0' in the parsed file.
2016-09-16 12:59:05 -07:00
Jakob Stoklund Olesen
88218440a3 Make the source map available as filecheck variables.
This makes it possible to refer to entities defined in the source file,
using the source names prefixed with $.

For example, $v20 refers to the value by that name in the sources, even
if it was renumbered to 'vx0' in the parsed file.
2016-09-16 12:59:05 -07:00
Jakob Stoklund Olesen
3796be696f Add a SourceMap to libreader.
Give crate clients the possiblility of mapping source-level entity names
to proper entity references that are valid in the parsed function.
2016-09-16 12:14:23 -07:00
Jakob Stoklund Olesen
77264ead08 Add a SourceMap to libreader.
Give crate clients the possiblility of mapping source-level entity names
to proper entity references that are valid in the parsed function.
2016-09-16 12:14:23 -07:00
Jakob Stoklund Olesen
d5ed27cce6 Use Cow<str> for the values of filecheck variables.
Often, an implementation of VariableMap can return references to
internal strings, and Cow::Borrow() allows that without making any
copies.

We still want to allow VariableMap implementations to return owned
strings in case they have to manufacture variable values on demand. The
Cow::Owned() variant does exactly that.

Switch the internal VariableMap implementations over to Cows. It turns
out they can simply store references to substrings of the input test,
completely avoiding string allocation for script-defined variables.
2016-09-16 09:45:43 -07:00
Jakob Stoklund Olesen
ea748f7718 Use Cow<str> for the values of filecheck variables.
Often, an implementation of VariableMap can return references to
internal strings, and Cow::Borrow() allows that without making any
copies.

We still want to allow VariableMap implementations to return owned
strings in case they have to manufacture variable values on demand. The
Cow::Owned() variant does exactly that.

Switch the internal VariableMap implementations over to Cows. It turns
out they can simply store references to substrings of the input test,
completely avoiding string allocation for script-defined variables.
2016-09-16 09:45:43 -07:00
Jakob Stoklund Olesen
fb16762866 Print the number of tests run.
Don't let 'cton-util test' finish without printing anything.
2016-09-15 17:28:09 -07:00
Jakob Stoklund Olesen
8a9b34411a Print the number of tests run.
Don't let 'cton-util test' finish without printing anything.
2016-09-15 17:28:09 -07:00
Jakob Stoklund Olesen
5ac30b0075 Implement the 'test print-cfg' sub-test.
Move the CFG tests into the filetests directory.

Remove the tests directory, there are no more shell-driven tests left.
2016-09-15 17:21:56 -07:00
Jakob Stoklund Olesen
78a2e47d95 Implement the 'test print-cfg' sub-test.
Move the CFG tests into the filetests directory.

Remove the tests directory, there are no more shell-driven tests left.
2016-09-15 17:21:56 -07:00
Jakob Stoklund Olesen
1342a0fb71 Also use fmt::Write for the print-cfg command.
This prepares use for implementing a 'test print-cfg' sub-test.
2016-09-15 17:10:21 -07:00
Jakob Stoklund Olesen
1ed8e1206d Also use fmt::Write for the print-cfg command.
This prepares use for implementing a 'test print-cfg' sub-test.
2016-09-15 17:10:21 -07:00
Jakob Stoklund Olesen
edc4fff50c Ignore test commands in parse_functions().
No point in returning a syntax error if the file contains test commands.
2016-09-15 16:07:00 -07:00
Jakob Stoklund Olesen
5ade8dc36a Ignore test commands in parse_functions().
No point in returning a syntax error if the file contains test commands.
2016-09-15 16:07:00 -07:00
Jakob Stoklund Olesen
086bd601a2 Convert parser tests to filetests.
Create a new directory hierarchy under 'filetests' for all the tests
that are run by 'cton-util test'.

Convert the parser tests under 'tests/parser' to use 'test cat' and
filecheck directives.
2016-09-15 15:50:47 -07:00
Jakob Stoklund Olesen
0b7f87b14c Convert parser tests to filetests.
Create a new directory hierarchy under 'filetests' for all the tests
that are run by 'cton-util test'.

Convert the parser tests under 'tests/parser' to use 'test cat' and
filecheck directives.
2016-09-15 15:50:47 -07:00
Jakob Stoklund Olesen
524bf15428 Add a SubTest trait and filecheck utilities.
This trait serves as a shared interface for the different kinds of test
commands the 'cton-util test' understands.

Many tests produce output that is run through filecheck for validation.
Provide a simple run_filecheck() function to help with this.

Implement the 'test cat' sub-test which is probably the simplest
possible.
2016-09-15 15:50:47 -07:00
Jakob Stoklund Olesen
d221249e7f Add a SubTest trait and filecheck utilities.
This trait serves as a shared interface for the different kinds of test
commands the 'cton-util test' understands.

Many tests produce output that is run through filecheck for validation.
Provide a simple run_filecheck() function to help with this.

Implement the 'test cat' sub-test which is probably the simplest
possible.
2016-09-15 15:50:47 -07:00
Jakob Stoklund Olesen
b40a3495fe Use fmt::Write instead of io::Write in write.rs.
It is common to represent a function as a String, and previously that
required re-validating the UTF-8 in a Vec<u8>. The fmt::Write trait
writes UTF-8 directly into a String, so no extra checking is required.

This also means we can implement Display for Function which gives it a
to_string() method. This makes the function_to_string() method
redundant, so delete it.

The functions in the write module are no longer generally useful, so
make the module private. The Display trait on Function is all we need.
2016-09-15 14:15:27 -07:00
Jakob Stoklund Olesen
d16b57d540 Use fmt::Write instead of io::Write in write.rs.
It is common to represent a function as a String, and previously that
required re-validating the UTF-8 in a Vec<u8>. The fmt::Write trait
writes UTF-8 directly into a String, so no extra checking is required.

This also means we can implement Display for Function which gives it a
to_string() method. This makes the function_to_string() method
redundant, so delete it.

The functions in the write module are no longer generally useful, so
make the module private. The Display trait on Function is all we need.
2016-09-15 14:15:27 -07:00
Jakob Stoklund Olesen
0b8bf530b0 Make functions cloneable for testing.
It's not super fast to clone a function, but it is faster than
re-parsing the test case file it came from.

Some tests want to mutate the function, and there may be other tests in
the same script that need the original function.
2016-09-15 08:43:43 -07:00
Jakob Stoklund Olesen
6ffca9ec99 Make functions cloneable for testing.
It's not super fast to clone a function, but it is faster than
re-parsing the test case file it came from.

Some tests want to mutate the function, and there may be other tests in
the same script that need the original function.
2016-09-15 08:43:43 -07:00
Jakob Stoklund Olesen
7e98985ea6 Break DetailedFunction into a tuple.
Use (Function, Details) in place of the aggregrate DetailedFunction.
It turns out that some tests want to clone and manipulate the function
while the details never change.
2016-09-15 08:34:06 -07:00
Jakob Stoklund Olesen
2901a85a36 Break DetailedFunction into a tuple.
Use (Function, Details) in place of the aggregrate DetailedFunction.
It turns out that some tests want to clone and manipulate the function
while the details never change.
2016-09-15 08:34:06 -07:00
Jakob Stoklund Olesen
03170927dd Add a job queue and begin loading test files.
This code looks overly complicated because it is anticipating running
jobs in a thread pool.

The test files are loaded and parsed, but not actually executed yet.
Errors are reported back to the test runner.
2016-09-14 15:23:50 -07:00
Jakob Stoklund Olesen
a24ca56c0d Add a job queue and begin loading test files.
This code looks overly complicated because it is anticipating running
jobs in a thread pool.

The test files are loaded and parsed, but not actually executed yet.
Errors are reported back to the test runner.
2016-09-14 15:23:50 -07:00
Jakob Stoklund Olesen
99c04383c8 Add a utility read_to_string() function. 2016-09-14 13:24:17 -07:00
Jakob Stoklund Olesen
480054a094 Add a utility read_to_string() function. 2016-09-14 13:24:17 -07:00
Jakob Stoklund Olesen
ddadf2e7c1 Add scaffolding for a 'cton-util test' command.
This command accepts files and directories containing test cases to run.
Recursively searches for test files in any directory it is passed.

Actually running tests is not yet implemented.
2016-09-14 13:24:15 -07:00
Jakob Stoklund Olesen
4521afd474 Add scaffolding for a 'cton-util test' command.
This command accepts files and directories containing test cases to run.
Recursively searches for test files in any directory it is passed.

Actually running tests is not yet implemented.
2016-09-14 13:24:15 -07:00
Jakob Stoklund Olesen
538b773e6d Parse test commands in a .cton file.
The top-level parse_test() function now parses test commands in the
preamble of a .cton file.
2016-09-14 09:10:32 -07:00
Jakob Stoklund Olesen
a544c0e171 Parse test commands in a .cton file.
The top-level parse_test() function now parses test commands in the
preamble of a .cton file.
2016-09-14 09:10:32 -07:00
Jakob Stoklund Olesen
21ad1d1e2d Add a public rest_of_line() function to lexer.
This is used to grap the tail of a 'test' line which doesn't use the
same tokens as a normal .cton file.
2016-09-13 16:50:10 -07:00
Jakob Stoklund Olesen
55a89c2167 Add a public rest_of_line() function to lexer.
This is used to grap the tail of a 'test' line which doesn't use the
same tokens as a normal .cton file.
2016-09-13 16:50:10 -07:00
Jakob Stoklund Olesen
4e3f0fc41d Collect comments while parsing functions.
The result from parsing a function is now a DetailedFunction which
includes all comments that can be associated with an entity.

Comments before the first function are ignored, everything else is
associated with the preceeding entity.

The parse_functions() function still returns plain functions.
2016-09-13 16:15:42 -07:00
Jakob Stoklund Olesen
dedc44be69 Collect comments while parsing functions.
The result from parsing a function is now a DetailedFunction which
includes all comments that can be associated with an entity.

Comments before the first function are ignored, everything else is
associated with the preceeding entity.

The parse_functions() function still returns plain functions.
2016-09-13 16:15:42 -07:00
Jakob Stoklund Olesen
458ecebe8f Add a next_key() method to primary entity maps.
It is sometimes useful to know the entity reference number that will be
assigned to the next thing added to a map.
2016-09-13 16:14:46 -07:00
Jakob Stoklund Olesen
525c69bbe8 Add a next_key() method to primary entity maps.
It is sometimes useful to know the entity reference number that will be
assigned to the next thing added to a map.
2016-09-13 16:14:46 -07:00
Jakob Stoklund Olesen
1b6623f068 Add a representation of a parsed test case file.
The new exported function `parse_test()` will produce it eventually.
2016-09-13 16:14:29 -07:00
Jakob Stoklund Olesen
4fd15f98ed Add a representation of a parsed test case file.
The new exported function `parse_test()` will produce it eventually.
2016-09-13 16:14:29 -07:00