Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Run tests
run: |
cargo test

#- name: Run cargo fmt --check
# run: cargo fmt --check

2 changes: 2 additions & 0 deletions tests/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
First example
Second row
Empty file added tests/empty.txt
Empty file.
31 changes: 31 additions & 0 deletions tests/wc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::process::Command;

#[test]
fn simple_wc() {
let result = Command::new("cargo")
.arg("build")
.arg("--release")
.output()
.expect("Could not run");
assert_eq!(result.status.code(), Some(0));


let result = Command::new("target/release/wc-rs")
.arg("tests/a.txt")
.output()
.expect("Could not run");
assert_eq!(result.status.code(), Some(0));
assert_eq!(std::str::from_utf8(&result.stdout).unwrap(), "2\t4\t25\t\u{1b}[2;32mtests/a.txt\u{1b}[0m\n");
assert_eq!(std::str::from_utf8(&result.stderr).unwrap(), "");


let result = Command::new("target/release/wc-rs")
.arg("tests/empty.txt")
.output()
.expect("Could not run");
assert_eq!(result.status.code(), Some(0));
assert_eq!(std::str::from_utf8(&result.stdout).unwrap(), "0\t0\t0\t\u{1b}[2;32mtests/empty.txt\u{1b}[0m\n");
assert_eq!(std::str::from_utf8(&result.stderr).unwrap(), "");

}