Skip to content

Commit

Permalink
Merge branch 'dlang:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
apbryan authored Jan 25, 2024
2 parents 3e43d8d + ef0bf93 commit 4916797
Show file tree
Hide file tree
Showing 17 changed files with 464 additions and 155 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ on:
- github-actions

jobs:
single_checks:
name: "Single sanity check"
runs-on: ubuntu-latest
steps:
- name: Install latest DMD
uses: dlang-community/setup-dlang@v1
- name: Checkout
uses: actions/checkout@v3
- name: Run tests
run: |
# check for trailing whitespace
TRAILING_WS_COUNT=$(find . -type f -name '*.d' -exec grep -Hn "[[:blank:]]$" {} \; | wc -l)
if [ $TRAILING_WS_COUNT -ne 0 ]; then
echo "========================================"
find . -type f -name '*.d' -exec grep -Hn "[[:blank:]]$" {} \;
echo "========================================"
echo "The files above have trailing whitespace"
exit 1
fi
# check that the man page generation still works
dub --single -v scripts/man/gen_man.d
main:
name: Run
strategy:
Expand Down Expand Up @@ -78,14 +100,12 @@ jobs:
- name: '[POSIX] Test'
if: runner.os != 'Windows'
env:
COVERAGE: false
# The value doesn't matter as long as it's > 2.087
FRONTEND: 2.095.0
COVERAGE: true
run: |
dub build --compiler=${{ env.DC }}
if [[ ${{ matrix.do_test }} == 'true' ]]; then
dub run --compiler=${{ env.DC }} --single test/issue2051_running_unittests_from_dub_single_file_packages_fails.d
./scripts/ci/travis.sh
./scripts/ci/ci.sh
fi
- name: '[Windows] Test'
Expand All @@ -111,3 +131,6 @@ jobs:
test/run-unittest.sh
fi
shell: bash

- name: Codecov
uses: codecov/codecov-action@v3
21 changes: 21 additions & 0 deletions scripts/ci/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -v -e -o pipefail

vibe_ver=$(jq -r '.versions | .["vibe-d"]' < dub.selections.json)
dub fetch vibe-d@$vibe_ver # get optional dependency
dub test --compiler=${DC} -c library-nonet

export DMD="$(command -v $DMD)"

./build.d -preview=dip1000 -preview=in -w -g -debug

if [ "$COVERAGE" = true ]; then
# library-nonet fails to build with coverage (Issue 13742)
dub test --compiler=${DC} -b unittest-cov
./build.d -cov
else
./build.d
DUB=`pwd`/bin/dub DC=${DC} dub --single ./test/run-unittest.d
DUB=`pwd`/bin/dub DC=${DC} test/run-unittest.sh
fi
2 changes: 1 addition & 1 deletion scripts/ci/setup-ldc-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# sets up LDC for cross-compilation. Source this script, s.t. the new LDC is in PATH

# Make sure this version matches the version of LDC2 used in .travis.yml,
# Make sure this version matches the version of LDC2 used in the CI configuration
# otherwise the compiler and the lib used might mismatch.
LDC_VERSION="1.22.0"
ARCH=${ARCH:-32}
Expand Down
60 changes: 0 additions & 60 deletions scripts/ci/travis.sh

This file was deleted.

6 changes: 3 additions & 3 deletions scripts/man/gen_man.d
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ dependencies \- both downloading them and linking them into the application.`);
manFile.mode == ManWriter.Mode.markdown ? "\n\n" : "\n"
));
}
}
}



writeln(manFile.header("COMMON OPTIONS"));
manFile.writeArgs("-", args);
Expand Down
19 changes: 10 additions & 9 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -1005,14 +1005,15 @@ class InitCommand : Command {

static string input(string caption, string default_value)
{
writef("%s [%s]: ", caption.color(Mode.bold), default_value);
stdout.flush();
import dub.internal.colorize;
cwritef("%s [%s]: ", caption.color(Mode.bold), default_value);
auto inp = readln();
return inp.length > 1 ? inp[0 .. $-1] : default_value;
}

static string select(string caption, bool free_choice, string default_value, const string[] options...)
{
import dub.internal.colorize.cwrite;
assert(options.length);
import std.math : floor, log10;
auto ndigits = (size_t val) => log10(cast(double) val).floor.to!uint + 1;
Expand All @@ -1035,17 +1036,17 @@ class InitCommand : Command {
auto user_to_idx = (size_t i) => cast(uint)i - 1;

assert(default_idx >= 0);
writeln((free_choice ? "Select or enter " : "Select ").color(Mode.bold), caption.color(Mode.bold), ":".color(Mode.bold));
cwriteln((free_choice ? "Select or enter " : "Select ").color(Mode.bold), caption.color(Mode.bold), ":".color(Mode.bold));
foreach (i, option; options_matrix)
{
if (i != 0 && (i % num_columns) == 0) writeln();
if (i != 0 && (i % num_columns) == 0) cwriteln();
if (!option.length)
continue;
auto user_id = idx_to_user(option);
writef("%*u)".color(Color.cyan, Mode.bold) ~ " %s", ndigits(options.length), user_id,
cwritef("%*u)".color(Color.cyan, Mode.bold) ~ " %s", ndigits(options.length), user_id,
leftJustifier(option, max_width));
}
writeln();
cwriteln();
immutable default_choice = (default_idx + 1).to!string;
while (true)
{
Expand Down Expand Up @@ -2313,15 +2314,15 @@ class RemoveCommand : FetchRemoveCommand {
if (!m_version.empty) { // remove then --version removed
enforceUsage(!package_id.canFindVersionSplitter, "Double version spec not allowed.");
logWarn("The '--version' parameter was deprecated, use %s@%s. Please update your scripts.", package_id, m_version);
dub.remove(package_id, m_version, location);
dub.remove(PackageName(package_id), m_version, location);
} else {
const parts = UserPackageDesc.fromString(package_id);
const explicit = package_id.canFindVersionSplitter;
if (m_nonInteractive || explicit || parts.range != VersionRange.Any) {
const str = parts.range.matchesAny() ? "*" : parts.range.toString();
dub.remove(parts.name, str, location);
dub.remove(PackageName(parts.name), str, location);
} else {
dub.remove(package_id, location, &resolveVersion);
dub.remove(PackageName(package_id), location, &resolveVersion);
}
}
return 0;
Expand Down
50 changes: 30 additions & 20 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,6 @@ class Dub {
Package fetch(in PackageName name, in VersionRange range, FetchOptions options,
PlacementLocation location, string reason = "")
{
auto basePackageName = name.main;
Json pinfo;
PackageSupplier supplier;
foreach(ps; m_packageSuppliers){
Expand All @@ -994,7 +993,7 @@ class Dub {
if (existing && existing.version_ != ver)
logInfo("A new version for %s is available (%s -> %s). Run \"%s\" to switch.",
name.toString().color(Mode.bold), existing, ver,
text("dub upgrade ", name).color(Mode.bold));
text("dub upgrade ", name.main).color(Mode.bold));
return null;
}

Expand Down Expand Up @@ -1023,7 +1022,7 @@ class Dub {
{
import std.zip : ZipException;

auto path = getTempFile(basePackageName.toString(), ".zip");
auto path = getTempFile(name.main.toString(), ".zip");
supplier.fetchPackage(path, name.main, range, (options & FetchOptions.usePrerelease) != 0); // Q: continue on fail?
scope(exit) removeFile(path);
logDiagnostic("Placing to %s...", location.toString());
Expand Down Expand Up @@ -1071,15 +1070,17 @@ class Dub {
is set to `RemoveVersionWildcard`.
Params:
package_id = Name of the package to be removed
name = Name of the package to be removed
location = Specifies the location to look for the given package
name/version.
resolve_version = Callback to select package version.
*/
void remove(string package_id, PlacementLocation location,
scope size_t delegate(in Package[] packages) resolve_version)
void remove(in PackageName name, PlacementLocation location,
scope size_t delegate(in Package[] packages) resolve_version)
{
enforce(!package_id.empty);
enforce(name.main.toString().length);
enforce(!name.sub.length, "Cannot remove subpackage %s, remove %s instead"
.format(name, name.main));
if (location == PlacementLocation.local) {
logInfo("To remove a locally placed package, make sure you don't have any data"
~ "\nleft in it's directory and then simply remove the whole directory.");
Expand All @@ -1089,16 +1090,13 @@ class Dub {
Package[] packages;

// Retrieve packages to be removed.
foreach(pack; m_packageManager.getPackageIterator(package_id))
foreach(pack; m_packageManager.getPackageIterator(name.toString()))
if (m_packageManager.isManagedPackage(pack))
packages ~= pack;

// Check validity of packages to be removed.
if(packages.empty) {
throw new Exception("Cannot find package to remove. ("
~ "id: '" ~ package_id ~ "', location: '" ~ to!string(location) ~ "'"
~ ")");
}
enforce(!packages.empty, "Cannot find package '%s' to remove at %s location"
.format(name, location.toString()));

// Sort package list in ascending version order
packages.sort!((a, b) => a.version_ < b.version_);
Expand All @@ -1114,12 +1112,19 @@ class Dub {
try {
remove(pack);
} catch (Exception e) {
logError("Failed to remove %s %s: %s", package_id, pack, e.msg);
logError("Failed to remove %s %s: %s", name, pack, e.msg);
logInfo("Continuing with other packages (if any).");
}
}
}

deprecated("Use `remove(PackageName, PlacementLocation, delegate)`")
void remove(string name, PlacementLocation location,
scope size_t delegate(in Package[] packages) resolve_version)
{
this.remove(PackageName(name), location, resolve_version);
}

/// Compatibility overload. Use the version without a `force_remove` argument instead.
deprecated("Use the overload without the 3rd argument (`force_remove`) instead")
void remove(string package_id, PlacementLocation location, bool force_remove,
Expand All @@ -1131,30 +1136,35 @@ class Dub {
/** Removes a specific version of a package.
Params:
package_id = Name of the package to be removed
name = Name of the package to be removed
version_ = Identifying a version or a wild card. If an empty string
is passed, the package will be removed from the location, if
there is only one version retrieved. This will throw an
exception, if there are multiple versions retrieved.
location = Specifies the location to look for the given package
name/version.
*/
void remove(string package_id, string version_, PlacementLocation location)
void remove(in PackageName name, string version_, PlacementLocation location)
{
remove(package_id, location, (in packages) {
remove(name, location, (in packages) {
if (version_ == RemoveVersionWildcard || version_.empty)
return packages.length;

foreach (i, p; packages) {
if (p.version_ == Version(version_))
return i;
}
throw new Exception("Cannot find package to remove. ("
~ "id: '" ~ package_id ~ "', version: '" ~ version_ ~ "', location: '" ~ to!string(location) ~ "'"
~ ")");
throw new Exception("Cannot find package '%s@%s' to remove at %s location"
.format(name, version_, location.toString()));
});
}

deprecated("Use `remove(PackageName, string, PlacementLocation)`")
void remove(string name, string version_, PlacementLocation location)
{
this.remove(PackageName(name), version_, location);
}

/// Compatibility overload. Use the version without a `force_remove` argument instead.
deprecated("Use the overload without force_remove instead")
void remove(string package_id, string version_, PlacementLocation location, bool force_remove)
Expand Down
2 changes: 1 addition & 1 deletion source/dub/internal/tinyendian.d
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ auto fixUTFByteOrder(ubyte[] array) @safe @nogc pure nothrow
static immutable Endian[5] bomEndian = [ endian,
Endian.littleEndian,
Endian.bigEndian,
Endian.littleEndian,
Endian.littleEndian,
Endian.bigEndian ];

// Documented in function ddoc.
Expand Down
2 changes: 1 addition & 1 deletion source/dub/internal/vibecompat/inet/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct NativePath {
}

/// Constructs a path object from a list of PathEntry objects.
this(immutable(PathEntry)[] nodes, bool absolute)
this(immutable(PathEntry)[] nodes, bool absolute = false)
{
m_nodes = nodes;
m_absolute = absolute;
Expand Down
Loading

0 comments on commit 4916797

Please sign in to comment.