Commit graph

44 commits

Author SHA1 Message Date
Dale Wijnand b0046c084d
Fix message order 2018-11-30 23:16:34 +00:00
Dale Wijnand 282f238d93
Include executable in JSON output. 2018-11-30 22:12:30 +00:00
Eric Huss 786848a07d Provide error for testing non-workspaces packages with dev-dependencies.
Considering in most cases it just won't work, might as well display
a better error message explaining why.
2018-10-19 18:04:36 -07:00
Eric Huss 3a1cad6f28 --all-targets fixes
- Fix: `cargo test --all-targets` was running lib tests three times.
- `--all-targets` help strings were wrong or misleading.
- Minor cleanup to add `Proposal` type to maybe make the code more readable.
2018-09-16 20:33:05 -07:00
Dale Wijnand ac600aed4d
Stop test --doc from silently ignoring other target selecting options 2018-09-16 21:33:43 +01:00
kennytm 4779dbfe85
Update the testsuite to include the explicit '--color' flags. 2018-09-12 11:59:08 +08:00
Zach Lute 89f43938fe Print file paths instead of file:// URLs.
This change ensures cargo will output file paths in the expected format
(C:\foo\... on Windows, /foo/... elsewhere). Previously it would output
file:// URLs instead.

To support this change, additional changes were made to the test suite
string processing such that [ROOT] is now replaced with the appropriate
file path root for the platform.

The CWD template was also updated to use [CWD] like other replacement
templates and to do the replacement on the expected value rather than
the actual value to avoid replacing things we don't expect with CWD.
2018-09-07 19:42:59 -07:00
Matthias Krüger 2cd9cce6e3 clippy: resolve all warnings about useless format!() 2018-09-03 11:38:29 +02:00
Dale Wijnand d5fc8dc3a7
Introduce the CWD macro in test output asserting
Avoids dealing with things like CWD changing.
2018-08-30 11:05:29 +02:00
Dale Wijnand 570fe8927d
Remove hamcrest existing_file() 2018-08-29 10:26:12 +02:00
Dale Wijnand a173fc0abe
Replace .exec_with_output() usage with .with_stdout_contains 2018-08-29 00:45:19 +02:00
Dale Wijnand 21d9c4ae89
Replace some bare ProcessBuilder usage with Execs 2018-08-28 23:05:39 +02:00
Dale Wijnand 2554afe764
Make Project::process return Execs 2018-08-28 22:38:26 +02:00
Dale Wijnand 85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand 035b5b9d5a
Remove an unrun "cargo build" ProcessBuilder 2018-08-28 08:27:59 +01:00
Dale Wijnand 0152f26405
Move .env/.masquerade_as_nightly_cargo to collapse some more p.cargo calls 2018-08-18 21:34:09 +01:00
Dale Wijnand 511d4bc503
Collapse multiline ProcessBuilder::arg calls in tests
.. by calling this a bunch of times:

    fastmod --multiline '\.cargo\("([^"]+)"\).[ ]+\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/
2018-08-18 15:12:54 +01:00
Dale Wijnand af4f1392f7
Collapse ProcessBuilder::arg calls in tests
.. with mutliple calls of:

    fastmod --accept-all '\.cargo\("([^"]+)"\)\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/

until no changes are left.
2018-08-18 15:05:45 +01:00
Eric Huss 771fec3cff Change target filters in workspaces.
This changes it so that filters like `--bin`, `--test`, `--example`,
`--bench`, `--lib` will work in a workspace.  Today, these filters
require that they match *every* package in a workspace which makes
them not very useful.  This change makes it so that they only must
match at least one package.
2018-08-07 13:05:22 -07:00
Dale Wijnand 16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
bors 5badfb1acb Auto merge of #5854 - dwijnand:args-split_whitespace, r=alexcrichton
Cleanup tests by using single string commands, split on whitespaces

Refs #5742
2018-08-02 22:12:33 +00:00
Dale Wijnand 2fe2ea9e71
Use p.cargo's ability to split on whitespace more 2018-08-02 15:18:44 +01:00
Dale Wijnand 05400b8018
Drop the [/] test output macro 2018-08-02 10:18:48 +01:00
Arseniy Pendryak 5dcc4f1794 Add edition field into target object in metadata as well 2018-08-01 02:24:49 +03:00
Eric Huss dd6c6102a1 Fix test --doc with incompatible lib types.
When I recently changed the doctest handling, I forgot to check the lib type in
the `test --doc` scenario.

I also added the package name to a nearby error message, since it can be
confusing in a workspace setting.
2018-07-25 22:40:46 -07:00
Dale Wijnand ca7d9ee292
Declare one-line files on one line, in test projects 2018-07-25 09:58:50 +01:00
Dale Wijnand ab19c48358
Dedup a bunch more manifest 2018-07-25 00:43:30 +01:00
Dale Wijnand 081e7930d2
Drop now unnecessary basic manifests 2018-07-24 16:33:55 +01:00
Dale Wijnand 43b42d6f4c
Reorganise the testsuite crate module hierarchy
* Collapse the nested cargotest::support module into the cargotest
  module (merge the mod.rs's)
* Rename the cargotest module to support
* Nest the top-level hamcrest module into support
2018-07-22 08:46:44 +01:00
Dale Wijnand f8c9928cc1
Rework some test projects to use the "foo" default
Generally that means either switching "foo" and "bar" around (reversing
the arrow), or it means push "foo" to "bar" (and sometimes "bar" to
"baz", etc..) to free up "foo".

For trivia that leaves 80/1222 outliers, therefore 93.4% of test
project use the default. :)
2018-07-21 19:40:45 +01:00
Dale Wijnand 7fe2fbc8a3
Remove the argument from the project test support function
By rewriting the tests, with rerast (https://github.com/google/rerast),
to use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
        project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
        replace!(project("foo") => project_foo());
        replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests
2018-07-20 13:31:50 +01:00
Alex Crichton f9d4927b26 Partially revert dep changes in #5651
Some logic which was tweaked around the dependencies of build script targets was
tweaked slightly in a way that causes cargo to stack overflow by accientally
adding a dependency loop. This commit implements one of the strategies discussed
in #5711 to fix this situation.

The problem here is that when calculating the deps of a build script we need the
build scripts of *other* packages, but the exact profile is somewhat difficult
to guess at the moment we're generating our build script unit. To solve this the
dependencies towards other build scripts' executions is added in a different
pass after all other units have been assembled. At this point we should know for
sure that all build script executions are in the dependency graph, and we just
need to add a few more edges.

Closes #5708
2018-07-13 10:54:22 -07:00
Eric Huss 1a715aaec9 Ignore <tab> in libtest output.
rust-lang/rust#50387 is changing the output from libtest which affected a few Cargo tests.
2018-05-14 22:02:34 -07:00
Eric Huss dffc5baeb2 Partially revert change to testing examples.
Fixes #5437

I don't think changing the behavior was quite the correct thing to do.  This new behavior is very similar to the old with a few small differences:

```
cargo test
    ORGINAL: Only builds examples.
    NEW: Builds all examples.  Any example with `test` set is tested.

cargo test --tests
    ORIGINAL: Runs all examples as tests.
    NEW: Only runs examples as tests if `test` is set.

cargo test --examples
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)

cargo test --example foo
    ORIGINAL: Runs the given example as a test.
    NEW: (SAME)

cargo test --all-targets
    ORIGINAL: Runs all examples as tests.
    NEW: (SAME)
```
2018-05-02 20:17:53 -07:00
Aleksey Kladov d369f97c19 Revert "Enable new behavior of --feature"
This reverts commit 038eec5cb3.
2018-04-28 17:28:39 +03:00
Eric Huss b9181ef3b5 Add some more tests. 2018-04-27 13:42:30 -07:00
Eric Huss ec7be849e3 Some test cleanup for profiles. 2018-04-27 13:42:30 -07:00
Eric Huss 575d6e819c Profile Overrides (RFC #2282 Part 1) 2018-04-27 13:22:00 -07:00
Aleksey Kladov 038eec5cb3 Enable new behavior of --feature 2018-04-19 00:34:45 +03:00
Aleksey Kladov e5971b935c Slightly improve ergonomics of writing Cargo tests 2018-03-17 00:08:23 +03:00
Aleksey Kladov b0c181d91c Prettify rustfmted single-line strings 2018-03-14 17:48:44 -07:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Eric Huss c61efd8c39 Fix test error hint in a workspace.
This adds "-p NAME" to the hint on how to re-run a test when it fails if it is
inside a workspace.

Fixes #5053
2018-02-25 16:51:48 -08:00
André Rocha c2ff988c9f Reorganize integration tests as one crate with many modules. Issue #4867. 2018-02-21 13:33:51 -05:00
Renamed from tests/test.rs (Browse further)