10000 Explicitly ignore various unused results · yorickpeterse/clogs@a33f9d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Explicitly ignore various unused results
Browse files Browse the repository at this point in the history
Changelog: changed
  • Loading branch information
yorickpeterse committed Feb 18, 2025
1 parent 87da67e commit a33f9d3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/clogs/cli.inko
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ fn pub run[T: mut + Write](
Result.Error("the configuration file '${config_path}' already exists")
}
case Some('init') -> {
Config.default.save(config_path)
Result.Ok(nil)
Config.default.save(config_path).map_error(fn (e) {
'failed to generate the configuration file: ${e}'
})
}
case Some(val) -> {
match Version.parse(val) {
Expand Down
3 changes: 2 additions & 1 deletion src/main.inko
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type async Main {
case Error(e) -> {
# Until https://github.com/inko-lang/inko/issues/634 is implemented, we
# just unconditionally use colors.
Stderr.new.print('\e[31;1merror\e[0m: ${e}')
let _ = Stderr.new.print('\e[31;1merror\e[0m: ${e}')

exit(1)
}
}
Expand Down
28 changes: 16 additions & 12 deletions test/clogs/helpers.inko
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ fn write(path: ref Path, content: String) {

fn read(path: ref Path) -> String {
let buf = ByteArray.new
let _ = ReadOnlyFile.new(path.clone).then(fn (f) { f.read_all(buf) }).get

ReadOnlyFile.new(path.clone).then(fn (f) { f.read_all(buf) }).get
buf.into_string
}

Expand All @@ -24,8 +24,8 @@ fn with_file_path(id: Int, func: fn (ref Path)) {

fn with_directory(id: Int, func: fn (ref Path)) {
let path = env.temporary_directory.join('clogs-test-directory-${id}')
let _ = path.create_directory_all

path.create_directory_all
func.call(path)
path.remove_directory_all
}
Expand All @@ -38,35 +38,39 @@ fn with_repository(id: Int, func: fn (mut Repository, Array[String])) {
dir.create_directory_all.get

let repo = Repository.new(dir)

repo.run('init', []).get
let _ = repo.run('init', []).get

write(dir.join('a.txt'), 'a')
repo.run('add', ['a.txt']).get
repo.run('commit', ['--author', 'a <a@example.com>', '--message', 'Foo']).get

let _ = repo.run('add', ['a.txt']).get
let _ = repo
.run('commit', ['--author', 'a <a@example.com>', '--message', 'Foo'])
.get

write(dir.join('b.txt'), 'b')
repo.run('add', ['b.txt']).get
repo

let _ = repo.run('add', ['b.txt']).get
let _ = repo
.run(
'commit',
['--author', 'a <a@example.com>', '--message', 'Bar\n\nChangelog: added'],
)
.get

write(dir.join('c.txt'), 'c')
repo.run('add', ['c.txt']).get
repo

let _ = repo.run('add', ['c.txt']).get
let _ = repo
.run(
'commit',
['--author', 'a <a@example.com>', '--message', 'Baz\n\nChangelog: fixed'],
)
.get

repo.run('revert', ['HEAD', '--no-edit']).get
let _ = repo.run('revert', ['HEAD', '--no-edit']).get

# This is a bogus revert commit that should be ignored.
repo
let _ = repo
.run(
'commit',
[
Expand Down
11 changes: 8 additions & 3 deletions test/clogs/test_cli.inko
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ impl Write for Writer {
}

fn pub mut write_bytes(bytes: ref ByteArray) -> Result[Nil, Error] {
@buffer.copy_from(bytes, at: 0, size: bytes.size)
let _ = @buffer.copy_from(bytes, at: 0, size: bytes.size)

Result.Ok(nil)
}

Expand Down Expand Up @@ -124,7 +125,9 @@ fn pub tests(t: mut Tests) {

with_repository(t.id, fn (repo, _) {
Config.default.save(repo.path.join(CONFIG_FILE)).get
repo.run('tag', ['1.0.0']).get

let _ = repo.run('tag', ['1.0.0']).get

t.true(cli.run(['1.0.0'], repo.path, writer).ok?)

let changelog = read(repo.path.join('CHANGELOG.md'))
Expand Down Expand Up @@ -164,7 +167,9 @@ fn pub tests(t: mut Tests) {

with_directory(t.id, fn (path) {
Config.default.save(path.join(CONFIG_FILE)).get
Repository.new(path).run('init', []).get

let _ = Repository.new(path).run('init', []).get

t.true(cli.run(['1.0.0'], path, writer).error?)
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/clogs/test_git.inko
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fn pub tests(t: mut Tests) {

t.test('Repository.versions', fn (t) {
with_repository(t.id, fn (repo, _) {
repo.run('tag', ['v1.2.3'])
repo.run('tag', ['foo'])
let _ = repo.run('tag', ['v1.2.3'])
let _ = repo.run('tag', ['foo'])

t.equal(
repo.versions.ok.map(fn (i) { i.to_array }),
Expand Down

0 comments on commit a33f9d3

Please sign in to comment.
0