-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2696: Segfault with bad dub.sdl
This was a null pointer being passed down. However, while looking at the code, it was obvious that similar bugs would trigger for subpackages (as the code was not handling `null` packages either), so test cases for those have been added.
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******************************************************************************* | ||
Tests that don't fit in existing categories | ||
*******************************************************************************/ | ||
|
||
module dub.test.others; | ||
|
||
version (unittest): | ||
|
||
import std.algorithm; | ||
import std.format; | ||
import dub.test.base; | ||
|
||
// https://github.com/dlang/dub/issues/2696 | ||
unittest | ||
{ | ||
const ValidURL = `git+https://example.com/dlang/dub`; | ||
// Taken from a commit in the dub repository | ||
const ValidHash = "54339dff7ce9ec24eda550f8055354f712f15800"; | ||
const Template = `{"name": "%s", "dependencies": { | ||
"dep1": { "repository": "%s", "version": "%s" }}}`; | ||
|
||
scope dub = new TestDub(); | ||
dub.packageManager.addTestSCMPackage( | ||
Repository(ValidURL, ValidHash), | ||
// Note: SCM package are always marked as using `~master` | ||
dub.makeTestPackage(`{ "name": "dep1" }`, Version(`~master`)), | ||
); | ||
|
||
// Invalid URL, valid hash | ||
const a = Template.format("a", "git+https://nope.nope", ValidHash); | ||
try | ||
dub.loadPackage(dub.addTestPackage(a, Version("1.0.0"))); | ||
catch (Exception exc) | ||
assert(exc.message.canFind("Unable to fetch")); | ||
|
||
// Valid URL, invalid hash | ||
const b = Template.format("b", ValidURL, "invalid"); | ||
try | ||
dub.loadPackage(dub.addTestPackage(b, Version("1.0.0"))); | ||
catch (Exception exc) | ||
assert(exc.message.canFind("Unable to fetch")); | ||
|
||
// Valid URL, valid hash | ||
const c = Template.format("c", ValidURL, ValidHash); | ||
dub.loadPackage(dub.addTestPackage(c, Version("1.0.0"))); | ||
assert(dub.project.hasAllDependencies()); | ||
assert(dub.project.getDependency("dep1", true), "Missing 'dep1' dependency"); | ||
} |