Skip to content

Commit

Permalink
Add digger test command
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Apr 18, 2016
1 parent b6fb3dd commit 8223097
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ Digger Changelog
Digger v2.5 (WIP)
------------------------

* Internal changes for improved reliability
* Add `digger test` command, to run tests for
working tree state
* Add ability to revert a branch or pull request.
The syntax is to prefix the branch or PR with a `-`
(minus sign).
Example: `digger build "master + -phobos#1234"`
* Add ability to specify commit SHA1 instead of a
branch or PR number. Example:
`digger build "master + -dmd/0123456789abcdef0123456789abcdef01234567"`
* Internal changes for improved reliability

Digger v2.4 (2015-10-05)
------------------------
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ You can find binaries on the [GitHub releases](https://github.com/CyberShadow/Di
# perform incremental build (after changing a few source files)
$ digger rebuild

# run tests
$ digger test

Run `digger` with no arguments for detailed usage help.

##### Installing
Expand Down
2 changes: 1 addition & 1 deletion ae
Submodule ae updated 1 files
+97 −15 sys/d/manager.d
7 changes: 7 additions & 0 deletions custom.d
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ void incrementalBuild(BuildConfig buildConfig)
prepareResult();
}

/// Run tests.
void runTests(BuildConfig buildConfig)
{
d.config.build = buildConfig;
d.test();
}

/// Implements transient persistence for the current customization state.
struct DCustomizer
{
Expand Down
21 changes: 14 additions & 7 deletions digger.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import repo;
// http://d.puremagic.com/issues/show_bug.cgi?id=7016
version(Windows) static import ae.sys.windows;

alias BuildOptions = TypeTuple!(
alias BuildOptions(string action, string pastAction) = TypeTuple!(
Switch!(hiddenOption, 0, "64"),
Option!(string, "Select model (32 or 64).\nOn this system, the default is " ~ BuildConfig.components.common.defaultModel, null, 0, "model"),
Option!(string[], "Do not build a component (that would otherwise be built by default). List of default components: " ~ DManager.defaultComponents.join(", "), "COMPONENT", 0, "without"),
Option!(string[], "Specify an additional D component to build. List of available additional components: " ~ DManager.additionalComponents.join(", "), "COMPONENT", 0, "with"),
Option!(string[], "Do not " ~ action ~ " a component (that would otherwise be " ~ pastAction ~ " by default). List of default components: " ~ DManager.defaultComponents.join(", "), "COMPONENT", 0, "without"),
Option!(string[], "Specify an additional D component to " ~ action ~ ". List of available additional components: " ~ DManager.additionalComponents.join(", "), "COMPONENT", 0, "with"),
Option!(string[], `Additional make parameters, e.g. "-j8" or "HOST_CC=g++48"`, "ARG", 0, "makeArgs"),
Switch!("Bootstrap the compiler (build from C++ source code) instead of downloading a pre-built binary package", 0, "bootstrap"),
Switch!(hiddenOption, 0, "use-vc"),
Expand All @@ -42,7 +42,7 @@ alias BuildOptions = TypeTuple!(
alias Spec = Parameter!(string, "D ref (branch / tag / point in time) to build, plus any additional forks or pull requests. Example:\n"
"\"master @ 3 weeks ago + dmd#123 + You/dmd/awesome-feature\"");

BuildConfig parseBuildOptions(BuildOptions options)
BuildConfig parseBuildOptions(T...)(T options) // T == BuildOptions!action
{
BuildConfig buildConfig;
if (options[0])
Expand All @@ -63,19 +63,26 @@ struct Digger
{
static:
@(`Build D from source code`)
int build(BuildOptions options, Spec spec = "master")
int build(BuildOptions!("build", "built") options, Spec spec = "master")
{
buildCustom(spec, parseBuildOptions(options));
return 0;
}

@(`Incrementally rebuild the current D checkout`)
int rebuild(BuildOptions options)
int rebuild(BuildOptions!("rebuild", "rebuilt") options)
{
incrementalBuild(parseBuildOptions(options));
return 0;
}

@(`Run tests for enabled components`)
int test(BuildOptions!("test", "tested") options)
{
runTests(parseBuildOptions(options));
return 0;
}

@(`Install Digger's build result on top of an existing stable DMD installation`)
int install(
Switch!("Do not prompt", 'y') yes,
Expand Down Expand Up @@ -138,7 +145,7 @@ static:

// hidden actions

int buildAll(BuildOptions options, string spec = "master")
int buildAll(BuildOptions!("build", "built") options, string spec = "master")
{
.buildAll(spec, parseBuildOptions(options));
return 0;
Expand Down
9 changes: 9 additions & 0 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ rdmd --build-only -cov -debug -g -of./digger ../digger.d
./digger --config-file ./digger.ini build --make-args=-j"$CPUCOUNT" "master @ 2016-01-01 00:00:00"
work/result/bin/dmd -run issue15914.d

# Run tests

pushd work/repo/ # Clean everything to test correct test dependencies
git submodule foreach git reset --hard
git submodule foreach git clean -fdx
popd

./digger --config-file ./digger.ini test --without=dmd --make-args=-j"$CPUCOUNT" # Without DMD as that takes too long and is too fragile

# Caching

./digger --config-file ./digger.ini --offline build --make-args=-j"$CPUCOUNT" "master @ 2016-01-01 00:00:00" 2>&1 | tee digger.log
Expand Down

1 comment on commit 8223097

@PetarKirov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Please sign in to comment.