Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/pkg/assets/install3/gold/test.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Nothing to install.
==================
OK
[pkg, install]
4 changes: 4 additions & 0 deletions tests/pkg/assets/install3/main.toit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2021 Toitware ApS. All rights reserved.

main:
print "nothing to do"
Empty file.
50 changes: 50 additions & 0 deletions tests/pkg/assets/install4/gold/test-0.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
OK
[pkg, init]
==================
// No package installed yet.
==================
exec main.toit

STDERR---
main.toit:5:8: error: Package for prefix 'pkg4-pre' not found
import pkg4-pre.pkg4
^~~~~~~~
main.toit:8:14: error: Unresolved identifier: 'identify'
print pkg4.identify
^~~~~~~~
Compilation failed
Exit Code: 1
==================
exec main2.toit

STDERR---
main2.toit:5:8: error: Package for prefix 'pkg1' not found
import pkg1
^~~~
main2.toit:8:14: error: Unresolved identifier: 'identify'
print pkg1.identify
^~~~~~~~
Compilation failed
Exit Code: 1
==================
// Install pkg4 for 'main.toit', creating/updating a lock file.
==================
OK
[pkg, install, pkg4, --prefix=pkg4_pre]
Package '[email protected]' installed with prefix 'pkg4'.
==================
// main.toit should work now.
==================
exec main.toit
pkg4-4.9.9
Exit Code: 0
==================
OK
[pkg, install, pkg1]
Package '[email protected]' installed with prefix 'pkg1'.
==================
// main2.toit should also work now.
==================
exec main2.toit
pkg1-1.0.0pkg2-2.4.2pkg3-3.1.2
Exit Code: 0
50 changes: 50 additions & 0 deletions tests/pkg/assets/install4/gold/test-1.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
OK
[pkg, init]
==================
// No package installed yet.
==================
exec main.toit

STDERR---
main.toit:5:8: error: Package for prefix 'pkg4-pre' not found
import pkg4-pre.pkg4
^~~~~~~~
main.toit:8:14: error: Unresolved identifier: 'identify'
print pkg4.identify
^~~~~~~~
Compilation failed
Exit Code: 1
==================
exec main2.toit

STDERR---
main2.toit:5:8: error: Package for prefix 'pkg1' not found
import pkg1
^~~~
main2.toit:8:14: error: Unresolved identifier: 'identify'
print pkg1.identify
^~~~~~~~
Compilation failed
Exit Code: 1
==================
// Install pkg4 for 'main.toit', creating/updating a lock file.
==================
OK
[pkg, install, pkg4, --prefix=pkg4_pre]
Package '[email protected]' installed with prefix 'pkg4'.
==================
// main.toit should work now.
==================
exec main.toit
pkg4-4.9.9
Exit Code: 0
==================
OK
[pkg, install, pkg1]
Package '[email protected]' installed with prefix 'pkg1'.
==================
// main2.toit should also work now.
==================
exec main2.toit
pkg1-1.0.0pkg2-2.4.2pkg3-3.1.2
Exit Code: 0
8 changes: 8 additions & 0 deletions tests/pkg/assets/install4/main.toit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (C) 2025 Toit contributors.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the tests/LICENSE file.

import pkg4-pre.pkg4

main:
print pkg4.identify
8 changes: 8 additions & 0 deletions tests/pkg/assets/install4/main2.toit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (C) 2025 Toit contributors.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the tests/LICENSE file.

import pkg1

main:
print pkg1.identify
14 changes: 14 additions & 0 deletions tests/pkg/install3-gold-test.toit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (C) 2025 Toit contributors.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the tests/LICENSE file.

import .gold-tester

main args:
with-gold-tester args: test it

test tester/GoldTester:
tester.gold "test" [
["// Nothing to install."],
["pkg", "install"],
]
32 changes: 32 additions & 0 deletions tests/pkg/install4-gold-test.toit
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2025 Toit contributors.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the tests/LICENSE file.

import host.file

import .gold-tester

main args:
with-gold-tester args --with-git-pkg-registry: | tester/GoldTester |
2.repeat: | iteration/int |
test tester iteration

test tester/GoldTester iteration/int:
if iteration == 1:
// Second round remove the package and lock file.
file.delete "$tester.working-dir/package.yaml"
file.delete "$tester.working-dir/package.lock"

tester.gold "test-$iteration" [
["pkg", "init"], // So we don't accidentally use a /tmp/package.yaml.
["// No package installed yet."],
["exec", "main.toit"],
["exec", "main2.toit"],
["// Install pkg4 for 'main.toit', creating/updating a lock file."],
["pkg", "install", "pkg4", "--prefix=pkg4_pre"],
["// main.toit should work now."],
["exec", "main.toit"],
["pkg", "install", "pkg1"],
["// main2.toit should also work now."],
["exec", "main2.toit"],
]
5 changes: 1 addition & 4 deletions tools/pkg/commands/install.toit
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ class InstallCommand extends PkgProjectCommand:

execute:
if not package:
if recompute:
project.install --recompute=recompute --registries=registries
else:
project.install
project.install --recompute=recompute --registries=registries
else if not local:
execute-remote
else:
Expand Down
10 changes: 4 additions & 6 deletions tools/pkg/project/project.toit
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ class Project:
solve_ --update-everything --registries=registries
save

install --recompute/True --registries/Registries -> none:
solve_ --no-update-everything --registries=registries
save
lock-file.install

install --recompute/bool=false -> none:
install --recompute/bool --registries/Registries -> none:
if recompute or not lock-file:
solve_ --no-update-everything --registries=registries
save
lock-file.install

clean -> none:
Expand Down
Loading