Skip to content

Commit

Permalink
Merge pull request #6893 from roc-lang/basic-cli-12-update
Browse files Browse the repository at this point in the history
DO NOT MERGE YET update to basic-cli 0.12
  • Loading branch information
Anton-4 authored Jul 15, 2024
2 parents cf06d2b + 3a36d84 commit 7a288dd
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 142 deletions.
4 changes: 2 additions & 2 deletions crates/cli/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ mod tests {
use std::io::Write;
use tempfile::{tempdir, TempDir};

const FORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
const FORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
import pf.Task
main =
Stdout.line! "I'm a Roc application!""#;

const UNFORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
const UNFORMATTED_ROC: &str = r#"app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
Expand Down
66 changes: 0 additions & 66 deletions crates/cli/tests/cli/argsBROKEN.roc

This file was deleted.

2 changes: 1 addition & 1 deletion crates/cli/tests/cli/combine-tasks.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import pf.Task exposing [Task]
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/countdown.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdin
import pf.Stdout
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/echo.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdin
import pf.Stdout
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/env.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import pf.Stderr
Expand Down
17 changes: 9 additions & 8 deletions crates/cli/tests/cli/fileBROKEN.roc
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import pf.Task exposing [Task]
import pf.File
import pf.Path
import pf.Env
import pf.Dir

main : Task {} [Exit I32 Str]_
main =
path = Path.fromStr "out.txt"
pathStr = "out.txt"

task =
cwd = Env.cwd!
Stdout.line! "cwd: $(Path.display cwd)"
dirEntries = Dir.list! cwd
cwdPath = Env.cwd!
cwdStr = Path.display cwdPath
Stdout.line! "Current working directory: $(cwdStr)"

dirEntries = Path.listDir! cwdPath
contentsStr = Str.joinWith (List.map dirEntries Path.display) "\n "
Stdout.line! "Directory contents:\n $(contentsStr)\n"
Stdout.line! "Writing a string to out.txt"
File.writeUtf8! path "a string!"
contents = File.readUtf8! path
File.writeUtf8! pathStr "a string!"
contents = File.readUtf8! pathStr
Stdout.line! "I read the file back. Its contents: \"$(contents)\""

when Task.result! task is
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/form.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdin
import pf.Stdout
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/http-get.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Http
import pf.Task exposing [Task]
Expand Down
7 changes: 4 additions & 3 deletions crates/cli/tests/cli/ingested-file-bytes-no-ann.roc
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import "ingested-file.roc" as license
import "test-file.txt" as testFile

main =
license
# Due to the functions we apply on testFile, it will be inferred as a List U8.
testFile
|> List.map Num.toU64
|> List.sum
|> Num.toStr
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/tests/cli/ingested-file-bytes.roc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import "ingested-file.roc" as license : _ # A type hole can also be used here.
import "test-file.txt" as testFile : _ # the _ is optional

main =
# Due to how license is used, it will be a List U8.
license
# Due to the functions we apply on testFile, it will be inferred as a List U8.
testFile
|> List.map Num.toU64
|> List.sum
|> Num.toStr
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/ingested-file.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import "ingested-file.roc" as ownCode : Str
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/tests/cli/parse-args.roc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br",
}

import pf.Arg
import pf.Stdout
import pf.Task exposing [Task]

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/cli/parser-letter-counts.roc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app [main] {
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br",
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.5.2/9VrPjwfQQ1QeSL3CfmWr2Pr9DESdDIXy97pwpuq84Ck.tar.br",
}

Expand Down
6 changes: 3 additions & 3 deletions crates/cli/tests/cli/parser-movies-csv.roc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br",
parser: "https://github.com/lukewilliamboswell/roc-parser/releases/download/0.5.2/9VrPjwfQQ1QeSL3CfmWr2Pr9DESdDIXy97pwpuq84Ck.tar.br",
}

import pf.Stdout
import pf.Stderr
import pf.Task exposing [Task]
import parser.Core exposing [Parser, map, keep]
import parser.Core exposing [map, keep]
import parser.String exposing [strFromUtf8]
import parser.CSV exposing [CSV]
import parser.CSV

input : Str
input = "Airplane!,1980,\"Robert Hays,Julie Hagerty\"\r\nCaddyshack,1980,\"Chevy Chase,Rodney Dangerfield,Ted Knight,Michael O'Keefe,Bill Murray\""
Expand Down
1 change: 1 addition & 0 deletions crates/cli/tests/cli/test-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Used by ingested-file-bytes.roc and ingested-file-bytes-no-ann.roc
39 changes: 4 additions & 35 deletions crates/cli/tests/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ mod cli_run {
#[derive(Debug, PartialEq, Eq)]
enum Arg<'a> {
ExamplePath(&'a str),
// allow because we may need PlainText in the future
#[allow(dead_code)]
PlainText(&'a str),
}

Expand Down Expand Up @@ -799,39 +801,6 @@ mod cli_run {
)
}

#[test]
#[ignore = "currently broken in basic-cli platform"]
#[cfg_attr(windows, ignore = "missing __udivdi3 and some other symbols")]
#[serial(cli_platform)]
fn cli_args() {
test_roc_app(
"examples/cli",
"argsBROKEN.roc",
&[],
&[
Arg::PlainText("log"),
Arg::PlainText("-b"),
Arg::PlainText("3"),
Arg::PlainText("--num"),
Arg::PlainText("81"),
],
&[],
"4\n",
UseValgrind::No,
TestCliCommands::Run,
)
}

// TODO: remove in favor of cli_args once mono bugs are resolved in investigation
#[test]
#[cfg_attr(windows, ignore = "missing __udivdi3 and some other symbols")]
#[serial(cli_platform)]
fn cli_args_check() {
let path = file_path_from_root("crates/cli/tests/cli", "argsBROKEN.roc");
let out = run_roc([CMD_CHECK, path.to_str().unwrap()], &[], &[]);
assert!(out.status.success());
}

// TODO: write a new test once mono bugs are resolved in investigation
#[test]
#[cfg(not(debug_assertions))] // https://github.com/roc-lang/roc/issues/4806
Expand Down Expand Up @@ -1030,7 +999,7 @@ mod cli_run {
&[],
&[],
&[],
"27101\n",
"6239\n",
UseValgrind::No,
TestCliCommands::Run,
)
Expand All @@ -1045,7 +1014,7 @@ mod cli_run {
&[],
&[],
&[],
"27101\n",
"6239\n",
UseValgrind::No,
TestCliCommands::Run,
)
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/load_internal/tests/test_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ fn roc_file_no_extension() {
indoc!(
r#"
app "helloWorld"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
imports [pf.Stdout]
provides [main] to pf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app [main] {
pf:
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
"https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br",
}

main =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Full {
],
platform_marker: None,
package_name: @17-132 PackageName(
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
"https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br",
),
},
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app [main] { pf:
"https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br"
"https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br"
}

main =
Expand Down
2 changes: 1 addition & 1 deletion examples/helloWorld.roc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import pf.Task
Expand Down
2 changes: 1 addition & 1 deletion examples/inspect-logging.roc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Shows how Roc values can be logged
#
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }

import pf.Stdout
import pf.Task
Expand Down
2 changes: 1 addition & 1 deletion www/content/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Something that sets Roc apart from other programming languages is its <span clas
Here is a Roc application that prints `"Hello, World!"` to the command line:

```roc
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
import pf.Task
Expand Down
8 changes: 4 additions & 4 deletions www/content/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Let's move out of the REPL and create our first Roc application!
Make a file named `main.roc` and put this in it:

```roc
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
import pf.Task
Expand Down Expand Up @@ -1454,7 +1454,7 @@ Besides being built into the compiler, the builtin modules are different from ot
Let's take a closer look at the part of `main.roc` above the `main` def:

```roc
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
```
Expand Down Expand Up @@ -1572,7 +1572,7 @@ We'll use these four operations to learn about tasks.
Let's start with a basic "Hello World" program.

```roc
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
Expand Down Expand Up @@ -1605,7 +1605,7 @@ Once this task runs, we'll end up with the [tag union](https://www.roc-lang.org/
Let's change `main` to read a line from `stdin`, and then print what we got:

```roc
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/Lb8EgiejTUzbggO2HVVuPJFkwvvsfW6LojkLR20kTVE.tar.br" }
import pf.Stdout
import pf.Stdin
Expand Down

0 comments on commit 7a288dd

Please sign in to comment.