Explorar el Código

'sdist create' -> 'pkg create'

default_compile_flags
vector-of-bool hace 3 años
padre
commit
3323ec90b6
Se han modificado 14 ficheros con 40 adiciones y 71 borrados
  1. +1
    -1
      src/dds/cli/cmd/pkg_create.cpp
  2. +3
    -10
      src/dds/cli/dispatch_main.cpp
  3. +18
    -29
      src/dds/cli/options.cpp
  4. +1
    -13
      src/dds/cli/options.hpp
  5. +0
    -0
      tests/projects/simple/include/header.h
  6. +0
    -0
      tests/projects/simple/include/header.hpp
  7. +0
    -0
      tests/projects/simple/library.jsonc
  8. +0
    -0
      tests/projects/simple/other-file.txt
  9. +0
    -0
      tests/projects/simple/package.json5
  10. +0
    -0
      tests/projects/simple/src/foo.cpp
  11. +1
    -1
      tests/test_basics.py
  12. +13
    -14
      tests/test_pkg.py
  13. +2
    -2
      tools/dds_ci/testing/fixtures.py
  14. +1
    -1
      tools/mkrepo.py

src/dds/cli/cmd/sdist_create.cpp → src/dds/cli/cmd/pkg_create.cpp Ver fichero

@@ -12,7 +12,7 @@ using namespace fansi::literals;

namespace dds::cli::cmd {

int sdist_create(const options& opts) {
int pkg_create(const options& opts) {
dds::sdist_params params{
.project_dir = opts.project_dir,
.dest_path = {},

+ 3
- 10
src/dds/cli/dispatch_main.cpp Ver fichero

@@ -16,6 +16,7 @@ using command = int(const options&);
command build_deps;
command build;
command compile_file;
command pkg_create;
command pkg_get;
command pkg_import;
command pkg_ls;
@@ -29,7 +30,6 @@ command repoman_import;
command repoman_init;
command repoman_ls;
command repoman_remove;
command sdist_create;

} // namespace cmd

@@ -39,20 +39,13 @@ int dispatch_main(const options& opts) noexcept {
switch (opts.subcommand) {
case subcommand::build:
return cmd::build(opts);
case subcommand::sdist: {
DDS_E_SCOPE(opts.sdist.subcommand);
switch (opts.sdist.subcommand) {
case sdist_subcommand::create:
return cmd::sdist_create(opts);
case sdist_subcommand::_none_:;
}
neo::unreachable();
}
case subcommand::pkg: {
DDS_E_SCOPE(opts.pkg.subcommand);
switch (opts.pkg.subcommand) {
case pkg_subcommand::ls:
return cmd::pkg_ls(opts);
case pkg_subcommand::create:
return cmd::pkg_create(opts);
case pkg_subcommand::get:
return cmd::pkg_get(opts);
case pkg_subcommand::import:

+ 18
- 29
src/dds/cli/options.cpp Ver fichero

@@ -144,10 +144,6 @@ struct setup {
.name = "pkg",
.help = "Manage packages and package remotes",
}));
setup_sdist_cmd(group.add_parser({
.name = "sdist",
.help = "Work with source distribution packages",
}));
setup_repoman_cmd(group.add_parser({
.name = "repoman",
.help = "Manage a dds package repository",
@@ -236,18 +232,22 @@ struct setup {
.valname = "<pkg-subcommand>",
.action = put_into(opts.pkg.subcommand),
});
setup_pkg_init_db_cmd(pkg_group.add_parser({
.name = "init-db",
.help = "Initialize a new package database file (Path specified with '--pkg-db-path')",
}));
pkg_group.add_parser({
.name = "ls",
.help = "List locally available packages",
});
setup_pkg_create_cmd(pkg_group.add_parser({
.name = "create",
.help = "Create a source distribution archive of a project",
}));
setup_pkg_get_cmd(pkg_group.add_parser({
.name = "get",
.help = "Obtain a copy of a package from a remote",
}));
setup_pkg_init_db_cmd(pkg_group.add_parser({
.name = "init-db",
.help = "Initialize a new package database file (Path specified with '--pkg-db-path')",
}));
setup_pkg_import_cmd(pkg_group.add_parser({
.name = "import",
.help = "Import a source distribution archive into the local package cache",
@@ -262,6 +262,16 @@ struct setup {
}));
}

void setup_pkg_create_cmd(argument_parser& pkg_create_cmd) {
pkg_create_cmd.add_argument(project_arg.dup()).help
= "Path to the project for which to create a source distribution.\n"
"Default is the current working directory.";
pkg_create_cmd.add_argument(out_arg.dup()).help
= "Destination path for the source distributioon archive";
pkg_create_cmd.add_argument(if_exists_arg.dup()).help
= "What to do if the destination names an existing file";
}

void setup_pkg_get_cmd(argument_parser& pkg_get_cmd) {
pkg_get_cmd.add_argument({
.valname = "<pkg-id>",
@@ -357,27 +367,6 @@ struct setup {
});
}

void setup_sdist_cmd(argument_parser& sdist_cmd) noexcept {
auto& sdist_grp = sdist_cmd.add_subparsers({
.valname = "<sdist-subcommand>",
.action = put_into(opts.sdist.subcommand),
});
setup_sdist_create_cmd(sdist_grp.add_parser({
.name = "create",
.help = "Create a source distribution from a project tree",
}));
}

void setup_sdist_create_cmd(argument_parser& sdist_create_cmd) {
sdist_create_cmd.add_argument(project_arg.dup()).help
= "Path to the project for which to create a source distribution.\n"
"Default is the current working directory.";
sdist_create_cmd.add_argument(out_arg.dup()).help
= "Destination path for the source distributnion archive";
sdist_create_cmd.add_argument(if_exists_arg.dup()).help
= "What to do if the destination names an existing file";
}

void setup_repoman_cmd(argument_parser& repoman_cmd) {
auto& grp = repoman_cmd.add_subparsers({
.valname = "<repoman-subcommand>",

+ 1
- 13
src/dds/cli/options.hpp Ver fichero

@@ -25,18 +25,9 @@ enum class subcommand {
compile_file,
build_deps,
pkg,
sdist,
repoman,
};

/**
* @brief 'dds sdist' subcommands
*/
enum class sdist_subcommand {
_none_,
create,
};

/**
* @brief 'dds pkg' subcommands
*/
@@ -44,6 +35,7 @@ enum class pkg_subcommand {
_none_,
ls,
get,
create,
import,
repo,
search,
@@ -225,10 +217,6 @@ struct options {
} search;
} pkg;

struct {
sdist_subcommand subcommand;
} sdist;

/**
* @brief Parameters for 'dds repoman'
*/

tests/projects/sdist/include/header.h → tests/projects/simple/include/header.h Ver fichero


tests/projects/sdist/include/header.hpp → tests/projects/simple/include/header.hpp Ver fichero


tests/projects/sdist/library.jsonc → tests/projects/simple/library.jsonc Ver fichero


tests/projects/sdist/other-file.txt → tests/projects/simple/other-file.txt Ver fichero


tests/projects/sdist/package.json5 → tests/projects/simple/package.json5 Ver fichero


tests/projects/sdist/src/foo.cpp → tests/projects/simple/src/foo.cpp Ver fichero


+ 1
- 1
tests/test_basics.py Ver fichero

@@ -81,6 +81,6 @@ def test_empty_with_pkg_json(tmp_project: Project) -> None:

def test_empty_sdist_create(tmp_project: Project) -> None:
tmp_project.package_json = TEST_PACKAGE
tmp_project.sdist_create()
tmp_project.pkg_create()
assert tmp_project.build_root.joinpath('test-pkg@0.2.2.tar.gz').is_file(), \
'The expected sdist tarball was not generated'

tests/test_sdist.py → tests/test_pkg.py Ver fichero

@@ -11,31 +11,31 @@ from dds_ci.testing import ProjectOpener, Project, error

@pytest.fixture()
def test_project(project_opener: ProjectOpener) -> Project:
return project_opener.open('projects/sdist')
return project_opener.open('projects/simple')


def test_create_sdist(test_project: Project, tmp_path: Path) -> None:
def test_create_pkg(test_project: Project, tmp_path: Path) -> None:
# Create in the default location
test_project.sdist_create()
test_project.pkg_create()
sd_dir = test_project.build_root / 'foo@1.2.3.tar.gz'
assert sd_dir.is_file(), 'Did not create an sdist in the default location'
# Create in a different location
dest = tmp_path / 'dummy.tar.gz'
test_project.sdist_create(dest=dest)
test_project.pkg_create(dest=dest)
assert dest.is_file(), 'Did not create an sdist in the new location'


@pytest.fixture()
def test_sdist(test_project: Project) -> Tuple[Path, Project]:
def _test_pkg(test_project: Project) -> Tuple[Path, Project]:
repo_content_path = test_project.dds.repo_dir / 'foo@1.2.3'
assert not repo_content_path.is_dir()
test_project.sdist_create()
test_project.pkg_create()
assert not repo_content_path.is_dir()
return test_project.build_root / 'foo@1.2.3.tar.gz', test_project


def test_import_sdist_archive(test_sdist: Tuple[Path, Project]) -> None:
sdist, project = test_sdist
def test_import_sdist_archive(_test_pkg: Tuple[Path, Project]) -> None:
sdist, project = _test_pkg
repo_content_path = project.dds.repo_dir / 'foo@1.2.3'
project.dds.pkg_import(sdist)
assert repo_content_path.is_dir(), \
@@ -47,8 +47,8 @@ def test_import_sdist_archive(test_sdist: Tuple[Path, Project]) -> None:
'Non-package content appeared in the package cache'


def test_import_sdist_stdin(test_sdist: Tuple[Path, Project]) -> None:
sdist, project = test_sdist
def test_import_sdist_stdin(_test_pkg: Tuple[Path, Project]) -> None:
sdist, project = _test_pkg
repo_content_path = project.dds.repo_dir / 'foo@1.2.3'
pipe = subprocess.Popen(
list(proc.flatten_cmd([
@@ -70,7 +70,6 @@ def test_import_sdist_stdin(test_sdist: Tuple[Path, Project]) -> None:

rc = pipe.wait()
assert rc == 0, 'Subprocess failed'
# project.dds.pkg_import(sdist)
assert repo_content_path.is_dir(), \
'The package did not appear in the local cache'
assert repo_content_path.joinpath('library.jsonc').is_file(), \
@@ -82,16 +81,16 @@ def test_import_sdist_stdin(test_sdist: Tuple[Path, Project]) -> None:

def test_sdist_invalid_project(tmp_project: Project) -> None:
with error.expect_error_marker('no-package-json5'):
tmp_project.sdist_create()
tmp_project.pkg_create()


@pytest.mark.skipif(platform.system() != 'Linux', reason='We know this fails on Linux')
def test_sdist_unreadable_dir(dds: DDSWrapper) -> None:
with error.expect_error_marker('failed-package-json5-scan'):
dds.run(['sdist', 'create', '--project=/root'])
dds.run(['pkg', 'create', '--project=/root'])


def test_sdist_invalid_json5(tmp_project: Project) -> None:
tmp_project.write('package.json5', 'bogus json5')
with error.expect_error_marker('package-json5-parse-error'):
tmp_project.sdist_create()
tmp_project.pkg_create()

+ 2
- 2
tools/dds_ci/testing/fixtures.py Ver fichero

@@ -86,10 +86,10 @@ class Project:
with tc_mod.fixup_toolchain(toolchain or tc_mod.get_default_test_toolchain()) as tc:
self.dds.compile_file(paths, toolchain=tc, out=self.build_root, project_dir=self.root)

def sdist_create(self, *, dest: Optional[Pathish] = None) -> None:
def pkg_create(self, *, dest: Optional[Pathish] = None) -> None:
self.build_root.mkdir(exist_ok=True, parents=True)
self.dds.run([
'sdist',
'pkg',
'create',
self.project_dir_arg,
f'--out={dest}' if dest else (),

+ 1
- 1
tools/mkrepo.py Ver fichero

@@ -371,7 +371,7 @@ def http_dl_unpack(url: str) -> Iterator[Path]:
def spec_as_local_tgz(dds_exe: Path, spec: SpecPackage) -> Iterator[Path]:
with spec.remote.make_local_dir(spec.name, spec.version) as clone_dir:
out_tgz = clone_dir / 'sdist.tgz'
check_call([str(dds_exe), 'sdist', 'create', f'--project={clone_dir}', f'--out={out_tgz}'])
check_call([str(dds_exe), 'pkg', 'create', f'--project={clone_dir}', f'--out={out_tgz}'])
yield out_tgz



Cargando…
Cancelar
Guardar