Skip to content

Commit db427c7

Browse files
committed
chore: fix eof newline
1 parent 59cf35c commit db427c7

File tree

9 files changed

+39
-31
lines changed

9 files changed

+39
-31
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ jobs:
7272
steps:
7373
# Manually check the status of all dependencies. `if: failure()` does not work.
7474
- name: check if any dependency failed
75-
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
75+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This code is still highly experimental and not ready for production use.
1414
In the root directory of the project, run the following command:
1515

1616
```bash
17-
./y rustc example/example.rs
18-
./build/example
17+
./y rustc examples/basic_math.rs
18+
./build/basic_math
1919
```
2020

2121
The usage of `./y` can be viewed from `./y help`.

bootstrap/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Run for FmtCommand {
2323
.args(["--manifest-path", "crates/Cargo.toml"])
2424
.arg("--all"),
2525
);
26-
for file in glob("example/**/*.rs").unwrap() {
26+
for file in glob("examples/**/*.rs").unwrap() {
2727
self.perform(Command::new("rustfmt").args(["--edition", "2021"]).arg(file.unwrap()));
2828
}
2929
for file in glob("tests/**/*.rs").unwrap() {

bootstrap/src/test.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Run for TestCommand {
3737
TestType::FileCheck => {
3838
cprint!("File checking {}...", testcase.name);
3939
testcase.build(manifest);
40-
filechecker.run(&testcase.source, &testcase.output);
40+
filechecker.run(&testcase.source, &testcase.output_file);
4141
}
4242
TestType::Compile => {
4343
cprint!("Compiling {}...", testcase.name);
@@ -57,35 +57,31 @@ impl TestCommand {
5757
pub fn collect_testcases(&self, manifest: &Manifest) -> Vec<TestCase> {
5858
let mut result = vec![];
5959

60+
// Test auxiliary (should compile first)
61+
for case in glob("tests/auxiliary/*.rs").unwrap() {
62+
let case = case.unwrap();
63+
let filename = case.file_stem().unwrap();
64+
let name = format!("auxiliary/{}", filename.to_string_lossy());
65+
let output_file = manifest.out_dir.join(filename);
66+
result.push(TestCase { name, source: case, output_file, test: TestType::CompileLib })
67+
}
68+
6069
// Examples
61-
for case in glob("example/*.rs").unwrap() {
70+
for case in glob("examples/*.rs").unwrap() {
6271
let case = case.unwrap();
6372
let filename = case.file_stem().unwrap();
64-
if filename == "mini_core" {
65-
// First compile mini_core
66-
result.insert(
67-
0,
68-
TestCase {
69-
name: "mini_core".into(),
70-
source: case.clone(),
71-
output: manifest.out_dir.join(Path::new(filename)),
72-
test: TestType::CompileLib,
73-
},
74-
);
75-
continue;
76-
}
77-
let name = format!("example/{}", filename.to_string_lossy());
78-
let output = manifest.out_dir.join("example").join(filename);
79-
result.push(TestCase { name, source: case, output, test: TestType::Compile })
73+
let name = format!("examples/{}", filename.to_string_lossy());
74+
let output_file = manifest.out_dir.join("examples").join(filename);
75+
result.push(TestCase { name, source: case, output_file, test: TestType::Compile })
8076
}
8177

8278
// Codegen tests
8379
for case in glob("tests/codegen/*.rs").unwrap() {
8480
let case = case.unwrap();
8581
let filename = case.file_stem().unwrap();
8682
let name = format!("codegen/{}", filename.to_string_lossy());
87-
let output = manifest.out_dir.join("tests/codegen").join(filename);
88-
result.push(TestCase { name, source: case, output, test: TestType::FileCheck })
83+
let output_file = manifest.out_dir.join("tests/codegen").join(filename);
84+
result.push(TestCase { name, source: case, output_file, test: TestType::FileCheck })
8985
}
9086

9187
result
@@ -102,33 +98,35 @@ pub enum TestType {
10298
pub struct TestCase {
10399
pub name: String,
104100
pub source: PathBuf,
105-
pub output: PathBuf,
101+
pub output_file: PathBuf,
106102
pub test: TestType,
107103
}
108104

109105
impl TestCase {
110106
pub fn build(&self, manifest: &Manifest) {
111-
std::fs::create_dir_all(self.output.parent().unwrap()).unwrap();
107+
let output_dir = self.output_file.parent().unwrap();
108+
std::fs::create_dir_all(output_dir).unwrap();
112109
let mut command = manifest.rustc();
113110
command
114111
.args(["--crate-type", "bin"])
115112
.arg("-O")
116113
.arg(&self.source)
117114
.arg("-o")
118-
.arg(&self.output);
115+
.arg(&self.output_file);
119116
log::debug!("running {:?}", command);
120117
command.status().unwrap();
121118
}
122119

123120
pub fn build_lib(&self, manifest: &Manifest) {
124-
std::fs::create_dir_all(self.output.parent().unwrap()).unwrap();
121+
let output_dir = self.output_file.parent().unwrap();
122+
std::fs::create_dir_all(output_dir).unwrap();
125123
let mut command = manifest.rustc();
126124
command
127125
.args(["--crate-type", "lib"])
128126
.arg("-O")
129127
.arg(&self.source)
130128
.arg("--out-dir")
131-
.arg(self.output.parent().unwrap());
129+
.arg(self.output_file.parent().unwrap());
132130
log::debug!("running {:?}", command);
133131
command.status().unwrap();
134132
}
File renamed without changes.
File renamed without changes.

tests/codegen/filename.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test that the generated code has the filename and function name in it
2+
13
// CHECK: filename
24

35
#![feature(no_core)]

tests/codegen/params_count.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
//! Test that the generated code has the right number of parameters
2+
13
#![feature(no_core)]
24
#![no_core]
35
#![no_main]
46

57
extern crate mini_core;
68

9+
// CHECK-LABEL: foo
10+
// CHECK-LABEL: main
11+
712
// expect three int params
8-
// CHECK: {{((int32_t .*,?\s?){3})}}
13+
// CHECK-LABEL: foo
14+
// CHECK: (int32_t {{[a-zA-Z_][a-zA-Z0-9_]*}}, int32_t {{[a-zA-Z_][a-zA-Z0-9_]*}}, int32_t {{[a-zA-Z_][a-zA-Z0-9_]*}})
15+
// CHECK: return 0;
916
#[no_mangle]
1017
pub fn foo(_x: i32, _y: i32, _z: i32) -> i32 {
1118
0

tests/codegen/ret_value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
//! Test that we can return a value from a function
12
#![feature(no_core)]
23
#![no_core]
34
#![no_main]
45

56
extern crate mini_core;
67

7-
// expect three int params
8+
// CHECK-LABEL: main
89
// CHECK: 42
910
#[no_mangle]
1011
pub fn main() -> i32 {

0 commit comments

Comments
 (0)