summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-06-16 15:31:50 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-06-16 15:31:50 +0800
commit0bde28a46eca5752f178c097047dabf73a250f5d (patch)
tree88216efe905d7b3d29b3af05d5c0ec28f650a2ab
parent7a758b499cd4b243d211ad16c758f1fd8795afc6 (diff)
downloadmrust-0bde28a46eca5752f178c097047dabf73a250f5d.tar.gz
Minicargo - Support for main unit test targets
-rw-r--r--tools/minicargo/build.cpp2
-rw-r--r--tools/minicargo/manifest.cpp13
2 files changed, 13 insertions, 2 deletions
diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp
index 64558103..10c7f754 100644
--- a/tools/minicargo/build.cpp
+++ b/tools/minicargo/build.cpp
@@ -666,7 +666,7 @@ Builder::Builder(const BuildOptions& opts, size_t total_targets):
case PackageTarget::Type::Test:
if(crate_type)
*crate_type = "bin";
- outfile /= ::format(target.m_name, "-test", EXESUF);
+ outfile /= ::format(target.m_name, EXESUF);
break;
default:
throw ::std::runtime_error("Unknown target type being built");
diff --git a/tools/minicargo/manifest.cpp b/tools/minicargo/manifest.cpp
index 2a1493c8..28839d8b 100644
--- a/tools/minicargo/manifest.cpp
+++ b/tools/minicargo/manifest.cpp
@@ -353,7 +353,18 @@ PackageManifest PackageManifest::load_from_toml(const ::std::string& path)
}
}
- // TODO: if there's a lib target, add a test target using the same path
+ // If there's a lib target, add a test target using the same path
+ {
+ auto it = ::std::find_if(rv.m_targets.begin(), rv.m_targets.end(), [&](const auto& t) { return t.m_type == PackageTarget::Type::Lib; });
+ if( it != rv.m_targets.end() )
+ {
+ auto path = it->m_path;
+ auto name = it->m_name + "-test";
+ rv.m_targets.push_back(PackageTarget { PackageTarget::Type::Test });
+ rv.m_targets.back().m_name = name;
+ rv.m_targets.back().m_path = path;
+ }
+ }
for(const auto& dep : rv.m_dependencies)
{